(1)關(guān)閉防火墻
Service iptables stop關(guān)閉防火墻服務(wù)
Chkconfig iptables off關(guān)閉開(kāi)機(jī)啟動(dòng)防火墻
(2)安裝開(kāi)發(fā)包和庫(kù)文件
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開(kāi)啟NGINX服務(wù)
Chkconfig nginx on設(shè)置開(kāi)機(jī)啟動(dòng)
詳見(jiàn)筆記2
(4)安裝mysql:
Yum install mysql mysql-server mysql-devel
Service mysqld start開(kāi)啟mysql服務(wù)
Chkconfig mysqld on設(shè)置開(kāi)機(jī)啟動(dòng)
(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開(kāi)啟php-fpm服務(wù)
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
//由于原配置文件要自己去寫(xiě)因此可以使用默認(rèn)的配置文件作為配置文件
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默認(rèn)路徑
(8)配置PHP:
vi /etc/php.ini
//編輯文件php.ini晌涕,在文件末尾添加cgi.fix_pathinfo = 1
(9)測(cè)試:
新建info.PHP文件
vi /usr/share/nginx/html/info.php
phpinfo();
?>
然后訪(fǎng)問(wèn)http://IP/info.php 顯示PHP環(huán)境則搭建成功栈顷。