(1)关闭防火墙
Service iptables stop关闭防火墙服务
Chkconfig iptables off关闭开机启动防火墙
(2)安装开发包和库文件
yum -y install ntp make openssl openssl-devel pcre pcre-devel libpnglibpng-devel libjpeg-6b libjpeg-devel-6b freetype freetype-devel gd gd-devel zlib zlib-develgcc gcc-c++ libXpm libXpm-devel ncurses ncurses-devel libmcrypt libmcrypt-devel libxml2libxml2-devel imake autoconf automake screen sysstatcompat-libstdc++-33 curl curl-devel
(3)安装NGINX:
Yum install -y nginx
Service nginx start开启NGINX服务
Chkconfig nginx on设置开机启动
详见笔记2
(4)安装mysql:
Yum install mysql mysql-server mysql-devel
Service mysqld start开启mysql服务
Chkconfig mysqld on设置开机启动
(5)安装php:
yum install php lighttpd-fastcgi php-cli php-mysql php-gd php-imap php-ldapphp-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-mssql php-snmp php-soap
(6)安装php和所需组件使PHP支持MySQL、FastCGI模式
yum install php-tidy php-common php-devel php-fpm php-mysql
Service php-fpm start开启php-fpm服务
Chkconfig php-fpm on
(7)配置NGINX支持php:
mv /etc/nginx/nginx.conf/etc/nginx/nginx.confbak
//将配置文件改为备份文件
cp /etc/nginx/nginx.conf.default /etc/nginx/nginx.conf
//由于原配置文件要自己去写因此可以使用默认的配置文件作为配置文件
vi /etc/nginx/nginx.conf
index index.php index.html index.htm;
//加入index.php
location ~ \.php$ {
root/usr/share/nginx/html;
fastcgi_pass127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME/usr/share/nginx/html$fastcgi_script_name;
include fastcgi_params;
}
//将以上代码注释去掉,并修改成nginx默认路径
(8)配置PHP:
vi /etc/php.ini
//编辑文件php.ini,在文件末尾添加cgi.fix_pathinfo = 1
(9)测试:
新建info.PHP文件
vi /usr/share/nginx/html/info.php
phpinfo();
?>
然后访问http://IP/info.php 显示PHP环境则搭建成功。