lamp搭建(散装)

安装:

1、安装Apache

卸载自带httpd: yum remove httpd
yum install httpd #根据提示,输入Y安装即可成功安装
/etc/init.d/httpd start #启动Apache

备注:Apache启动之后会提示错误:
正在启动 httpd:httpd: Could not reliably determine theserver’s fully qualif domain name, using ::1 for ServerName
解决办法:
vi /etc/httpd/conf/httpd.conf #编辑
找到 #ServerName www.example.com:80
修改为 ServerName www.osyunwei.com:80 #这里设置为你自己的域名,如果没有域名,可以设置为localhost
:wq! #保存退出
chkconfig httpd on #设为开机启动
/etc/init.d/httpd restart #重启Apache

2、安装MySQL

先卸载自带mysql:

yum remove mysql mysql-server mysql-libs compat-mysql51
rm -rf /var/lib/mysql
rm /etc/my.cnf

安装:

yum install mysql mysql-server #询问是否要安装,输入Y即可自动安装,直到安装完成
/etc/init.d/mysqld start #启动MySQL
chkconfig mysqld on #设为开机启动
cp /usr/share/mysql/my-medium.cnf /etc/my.cnf #拷贝配置文件(注意:如果/etc目录下面默认有一个my.cnf,直接覆盖即可)

为root账户设置密码:(如果不设置,密码为空)
mysql_secure_installation
回车,根据提示输入Y
输入2次密码,回车
根据提示一路输入Y
最后出现:Thanks for using MySQL!
MySql密码设置完成,重新启动 MySQL:
/etc/init.d/mysqld restart #重启
/etc/init.d/mysqld stop #停止
/etc/init.d/mysqld start #启动

3、安装PHP5
yum install php
根据提示输入Y直到安装完成

安装PHP组件,使 PHP5 支持 MySQL
yum install php-mysql php-gd libjpeg* php-imap php-ldap php-odbc php-pearphp-xml php-xmlrpc php-mbstring php-mcrypt php-bcmath php-mhash libmcrypt
这里选择以上安装包进行安装
根据提示输入Y回车
/etc/init.d/mysqld restart #重启MySql
/etc/init.d/httpd restart #重启Apche

原文地址:https://www.cnblogs.com/LF-place/p/10903924.html