1,安装epel源
yum install -y epel-release
2,更新
yum update -y
3,添加nginx源
cd /etc/yum.rep.d/
vi nginx.repo
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=0
enabled=1
3,安装nginx
yum install -y nginx
4,安装php及其相关库
yum install -y php php-mysql php-fpm php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-snmp php-soap curl curl-devel
5,增加PHP加密扩展模块
wget http://www.dmasoftlab.com/cont/download/ioncube_loaders_lin_x86-64.tar.gz
tar zxvf ioncube_loaders_lin_x86-64.tar.gz
cp -rf ioncube /usr/local/
6,配置PHP
cp /etc/php.ini /etc/php.ini.bk
sed -i 's/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/g' /etc/php.ini
sed -i 's/post_max_size = 8M/post_max_size = 50M/g' /etc/php.ini
sed -i 's/upload_max_filesize = 2M/upload_max_filesize = 50M/g' /etc/php.ini
sed -i 's/;date.timezone =/date.timezone = PRC/g' /etc/php.ini
sed -i 's/max_execution_time = 30/max_execution_time = 300/g' /etc/php.ini
sed -i 's/disable_functions =.*/disable_functions = passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,popen,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server/g' /etc/php.ini
echo "zend_extension=/usr/local/ioncube/ioncube_loader_lin_5.4.so" >> /etc/php.ini
cp /etc/php-fpm.d/www.conf /etc/php-fpm.d/www.conf.bk
vi /etc/php-fpm.d/www.conf
#修改用户为nginx
user = nginx
#修改组为nginx
group = nginx
7,设置开机启动
systemctl enable php-fpm.service
开启php-fpm服务
systemctl start php-fpm
8,配置nginx
vi /etc/nginx/conf.d/default.conf
#location / {
root /usr/share/nginx/html;
index index.php index.html index.htm;
#}
修改以下代码
# location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
去掉除root行外的#,/scripts 改成$document_root
9,开机自启
systemctl enable nginx.service
systemctl restart nginx
10,测试
vi /usr/share/nginx/html/index.php
<?php
phpinfo();
?>
http://YOURSERVERIP看到php配置信息就OK了。