安装必要的工具
rpm -qa|grep libxml2 查看下工具是不是有装
yum list | grep libxml2
yum install libxml2-devel
//yum install libxml2
yum install libtool
yum install gcc-c++
yum list|grep pcre
yum install pcre-devel
groupaddwww-data
useradd -gwww-datawww-data
----安装PHP
PHP官网下载 wget http://PHP.net/distributions/PHP-7.1.2.tar.gz
解压 tar -zvxf PHP-7.1.2.tar.gz
进入源码目录 cd ./PHP-7.1.2
./configure --prefix=/usr/local/PHP --enable-fpm --enable-MysqLnd
(1)
cp/usr/local/PHP/etc/PHP-fpm.conf.default/usr/local/PHP/etc/PHP-fpm.conf
vi /usr/local/PHP/etc/PHP-fpm.conf
user = www-data
group = www-data
pid = run/PHP-fpm.pid (这行前面的分号去掉)
(2)
cp/usr/local/PHP/etc/PHP-fpm.d/@L_403_0@/usr/local/PHP/etc/PHP-fpm.d/www.conf
vi /usr/local/PHP/etc/PHP-fpm.d/www.conf
pm.start_servers = 10 (启动fpm时子进程数量)
listen = 127.0.0.1:9000 (监听ip和端口 跟Nginx 的配置文件里的fastcgi_pass对应上)
user = www-data
group = www-data
(3)
在命令行下执行PHP或PHPize会提示命令找不到,要设置环境变量
export PATH=$PATH:/usr/local/PHP/bin
(4)
PHP-fpm -c /usr/local/PHP/PHP.ini 启动时加载指定PHP.ini
/usr/local/PHP/sbin/PHP-fpm -c /usr/local/PHP/etc/PHP.ini -y /usr/local/PHP/etc/PHP-fpm.conf -t
kill -INT 'cat /usr/local/PHP/var/run/PHP-fpm.pid'(这个会报错不知道为什么,pid文件也是存在的)
PHP-fpm 重启:
kill -USR2 'cat /usr/local/PHP/var/run/PHP-fpm.pid'
----安装Nginx
wgethttp://nginx.org/download/nginx-1.11.13.tar.gz
tar -zxvf Nginx-1.11.13.tar.gz
./configure --prefix=/usr/local/Nginx
whereis Nginx
echo "/usr/local/Nginx/sbin/Nginx" >> /etc/rc.local (设置成开机启动)
vi /usr/local/Nginx/conf/Nginx.conf
user www-data;
location / {
root html;
index index.html index.htm index.PHP;
}
location ~ \.PHP$ {
root /usr/local/Nginx/html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.PHP;
fastcgi_param SCRIPT_FILENAME (代码路径)$fastcgi_script_name;
include fastcgi_params;
}
修改完保存,重启