CentOS搭建PHP服务器环境(LAMP)

安装httpd mysql mysql-server php:

yum install -y httpd mysql mysql-server php php-devel

安装php的扩展

yum install -y php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring

启动apache、mysql:

/etc/init.d/httpd start
/etc/init.d/mysqld start
chkconfig httpd on
chkconfig mysqld on

初始化数据库:

$ mysql_secure_installation
Enter current password for root
Set root password? [Y/n]
New password:
Remove anonymous users? [Y/n] y
Disallow root login remotely? [Y/n] n
Remove test database and access to it? [Y/n] y
Reload privilege tables now? [Y/n] 回车

新建一个 PHP 页面进行测试:

$ vi /var/www/html/info.php
<?php
phpinfo();
?>

  重启httpd服务:

/etc/init.d/httpd restart

访问测试地址:http://ip/info.php

部署过程遇到的问题:php网页空白。

解决方法:修改相应文件读写权限:

 chmod -R 777 /var/www/html/test/config/
原文地址:https://www.cnblogs.com/BuildingHome/p/4672777.html