安装必要的工具
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
groupadd www-data
useradd -g www-data www-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/www.conf.default /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
killall php-fpm 关闭进程
php-fpm 关闭:
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
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;
}
修改完保存,重启
/usr/local/nginx/sbin/nginx -s restart