LAMP yum install

本文涉及的产品
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
云数据库 RDS MySQL,集群系列 2核4GB
推荐场景:
搭建个人博客
RDS MySQL Serverless 高可用系列,价值2615元额度,1个月
简介:

Quick 'n' Easy LAMP Server For CentOS/RHEL

 

This tutorial shows a quick way of installing a LAMP server (Linux + Apache + MySQL + PHP/Perl together commonly known as LAMP Server.) on CentOS and RHEL server systems. 

  • Apache Web Server 2.0
  • MySQL Database Server 5.0
  • PHP Scripting Language 5.0
  • phpMyAdmin - Web based MySQL Administration Tool
  • Webmin - A free web based hosting control panel

 

Goal

To set up a LAMP server on a fresh VPS/Dedicated server running CentOS 5.0 with atleast 256mb of RAM. We will also be installing Webmin, a free server control panel for linux. If you are using a Debian/Ubuntu refer to this article.

 

Install Apache

Apache is the most popular Web HTTP server for a Linux servers.

yum install httpd httpd-devel

We might need the httpd-devel libraries to compile and install other modules from the sources, just to be on the safer side. /etc/httpd/conf/httpd.conf - Apache configuration file location.

/etc/init.d/httpd start

 

Install MySQL Database Server

MySQL is a widely used open source database server on most Linux servers and can very well integrate to PHP and Apache server on CentOS/RHEL.

yum install mysql mysql-server mysql-devel

If you attempt to type mysql in command prompt, you will be getting this nasty error.

ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’

This is because you are not running the mysqld daemon before launching the mysql client. The file /var/lib/mysql/mysql.sock will be automatically created upon running the first instance of mysql.

To fix:

First start the mysql daemon, then type mysql:

/etc/init.d/mysqld start
mysql

 

Changing MySQL Root Password

By default the root password is empty for the mysql database. It is a good idea to change the mysql root password to a new one from a security point of view.

mysql> USE mysql;
mysql> UPDATE user SET Password=PASSWORD('newpassword') WHERE user='root';
mysql> FLUSH PRIVILEGES;

Once done, check by logging in:

mysql -u root -p
Enter Password: <your new password>

 

To Create A New MySQL User

To create a new mysql user 'guest' with 'all privileges' on the database 'demo':

mysql > create database demo
mysql >GRANT ALL PRIVILEGES ON demo.* TO 'guest'@'localhost' IDENTIFIED BY 'guest' WITH GRANT OPTION;
mysql> UPDATE user SET Password=PASSWORD('guest') WHERE user='guest';

That's it! MySQL is ready! Don't forget to remember the root password as we might be using it with phpmyadmin.

 

Install PHP5 Scripting Language

Installing PHP5 with the necessary modules is so easy and can be configured for both the Apache and mysql environment.

yum install php php-mysql php-common php-gd php-mbstring php-mcrypt php-devel php-xml

Don't forget to install php-gd (gd library). It is very important if we plan to run captcha scripts on our server and so as other which are dependent on mysql and other functions.

Restart Apache to load php.

/etc/init.d/httpd restart

 

To Test If PHP Is Working Or Not:

Create a file named /var/www/html/test.php with the following phpinfo() function inside php quotes.

// test.php
  <?php
  phpinfo();
  ?>

Then point your browser to http://ip.address/test.php.

That's it! You should see a php configuration file displaying all kind of paths and installed modules.

Closely observe the installed configuration on your server.

* PHP Paths (php.ini path)
* Apache paths and Loaded Modules (mod_security, mod_evasive if installed_
* PHP GD Library
* MySQL paths and other information

 

Install phpMyAdmin

phpMyAdmin is a free web based MySQL database Administration Tool. Without phpMyAdmin it is almost impossible to mysql db operations in the command line. phpMyAdmin has become so convenient and it is absolutely sought by most webmasters to be present along with the mysql server.

yum install phpmyadmin

Point your browser to: http://ip.address/phpmyadmin.

 

Common Errors

You might encounter the following errors while configuring phpmyadmin.

Forbidden 
You don't have permission to access /phpmyadmin/ on this server.

To fix:

Edit the /etc/httpd/conf.d/phpmyadmin.conf and uncomment the line deny from all.

nano /etc/httpd/conf.d/phpmyadmin.conf

<Directory "/usr/share/phpmyadmin">
  Order Deny,Allow
  # Deny from all
  Allow from 127.0.0.1
  </Directory>

 

Error
The configuration file now needs a secret passphrase (blowfish_secret)

To fix:

nano /usr/share/phpmyadmin/conf.inc.php

Look for a line and enter any password. Just dont leave it empty!

$cfg['blowfish_secret'] = 'mydemopass'; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */

It worked for me using the above methods! 
Log into the phpmyadmin with the mysql root password we changed while installing the mysql database.

 

Install Webmin

Webmin a free server hosting control panel  for Linux. It is a web based hosting administration tool and can be handy to tweak settings in your server if you are a beginner to Linux! You can download webmin here. Since webmin cannot be installed using yum, we can download an RPM package and install it on our server.

wget <webmin rpm path>
rpm - i webmin-1.410-1.noarch.rpm

That should be a pretty easy installation! Remember webmin uses port 10000 and should not be blocked by your firewall.

Point your browser to: http://ip.address:10000

You should see a webmin login. But we don't know the login and password yet! To set up the webmin password run the script below...

/usr/libexec/webmin/changepass.pl /etc/webmin admin <newpasswd>

Log in with the admin username and new webmin password!
To uninstall webmin, just run:

/etc/webmin/uninstall.sh

 

Final Steps

We want the Apache and mysql to be loaded at every boot so we switch them on using chkconfig:

chkconfig httpd on
chkconfig mysqld on

You can also place comments in my blog. I would appreciate any feedbacks as well!

This tutorial was written and contributed to HowToForge by Mr.Balakrishnan  who currently runs MySQL-Apache-PHP.com. Permission is fully granted to copy/republish this tutorial in any form, provided a source is mentioned with a live link back to the authors site.

 

 

 

简单配置文件:
apache的配置文件是/etc/httpd/conf下
modules放在/usr/lib/httpd下
php的配置文件在/etc/php.d/下 和/etc/php.ini
php的modules放在/usr/lib/php/modules下

7. 安装Tomcat5
#yum -y install tomcat5 tomcat5-webapps tomcat5-admin-webapps
安装Tomcat5安装包和对应的依赖关系包

8. 启动Tomcat5
#service tomcat5 start
#chkconfig tomcat5 on


9. 在浏览器输入http://你的IP:8080/,可以看到Apache SoftWare Foundation页,如果看不到,请确认是否是防火墙问题
看到一个猫头 ------------------>tomcat5安装成功

10. Apache与Tomcat整合
如果网站需同时整合Apache与Tomcat可以使用JK或者Proxy方式
使用VI编辑proxy_ajp.conf文件
#vi /etc/httpd/conf.d/proxy_ajp.conf
输入以下内容
ProxyPass /tomcat/ ajp://localhost:8009/
存储文件后,重启Apache

#service httpd restart

在浏览器输入http://你的IP/tomcat/,可以看到Apache SoftWare Foundation页
As you may have guessed by now, this is the default Tomcat home page. It can be found on the local filesystem at:

$CATALINA_HOME/webapps/ROOT/index.jsp

这样就可以解析 .jsp文件。

本文转自 pk2008 51CTO博客,原文链接:http://blog.51cto.com/837244/901092


相关实践学习
如何快速连接云数据库RDS MySQL
本场景介绍如何通过阿里云数据管理服务DMS快速连接云数据库RDS MySQL,然后进行数据表的CRUD操作。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助 &nbsp; &nbsp; 相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
目录
打赏
0
0
0
0
344
分享
相关文章
LAMP YUM安装配置实战
LAMP YUM安装配置实战
118 3
yum install、localinstall和groupinstall区别
yum install、localinstall和groupinstall区别
475 0
|
2月前
|
yum install -y net-snmp-devel 安装不成功 zabbix项目安装,Errors during downloading metadata for repository ‘extras-common’:问题解决方案-优雅草卓伊凡
yum install -y net-snmp-devel 安装不成功 zabbix项目安装,Errors during downloading metadata for repository ‘extras-common’:问题解决方案-优雅草卓伊凡
71 13
yum install -y net-snmp-devel 安装不成功 zabbix项目安装,Errors during downloading metadata for repository ‘extras-common’:问题解决方案-优雅草卓伊凡
Ngnix09目录结构分析,使用tree工具可以Ngnix目录中以一个树的方式呈现出来,yum install -y tree,tail -f nginx/logs/access.log
Ngnix09目录结构分析,使用tree工具可以Ngnix目录中以一个树的方式呈现出来,yum install -y tree,tail -f nginx/logs/access.log
Linux部署实战前言,MySQL在CentOS安装【单机软件】,MySQL的安装需要root权限,yum install mysql,systemctl enable mysqld开机自启的意思
Linux部署实战前言,MySQL在CentOS安装【单机软件】,MySQL的安装需要root权限,yum install mysql,systemctl enable mysqld开机自启的意思
IP地址和主机名,ifconfig查看本机的ip地址,无法用,yum -y install net-tools,输入ifconfig之后还会列明网卡,ens33表明的是网卡,inet ip地址,000
IP地址和主机名,ifconfig查看本机的ip地址,无法用,yum -y install net-tools,输入ifconfig之后还会列明网卡,ens33表明的是网卡,inet ip地址,000
Linux软件安装-Linux系统靠yum命令安装软件,yum命令是一个RPM包软件管理器,用于自动化安装配置Linux软件,.rpm是Linux包下的软件,yum install下载 wget re
Linux软件安装-Linux系统靠yum命令安装软件,yum命令是一个RPM包软件管理器,用于自动化安装配置Linux软件,.rpm是Linux包下的软件,yum install下载 wget re
安装 LAMP 环境(yum 版本)
【4月更文挑战第29天】
113 5
yum install ansible无法直接安装Ansible的解决方法
准备三台机器: server.example.com node1.example.com node2.example.com 配置IP,主机名,/etc/hosts
809 0