安装必要的工具
rpm -qa|grep libxml2 查看下工具是不是有装
yum list | grep libxml2
yum install libxml2-devel
ubuntu/debian:
apt-get install libxml2-dev
apt-get install autoconf
//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
make
make install
(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
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)
cp ./php.ini-development /usr/local/php/lib
./php -i|grep php.ini 可以查看php.ini在那个哪里目录下,要把上行配置文件cp到这个目录下
php-fpm -c /usr/local/php/php.ini 启动时加载指定php.ini (可以忽略这样默认就是)
echo "/usr/local/php/sbin/php-fpm" >> /etc/rc.local (设置成开机启动)
/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.conf这个文件设置路径一样)
php-fpm 重启:
kill -USR2 'cat /usr/local/php/var/run/php-fpm.pid'
----安装nginx
wget http://nginx.org/download/nginx-1.11.13.tar.gz
tar -zxvf nginx-1.11.13.tar.gz
./configure --prefix=/usr/local/nginx
make
make install
whereis nginx
echo "/usr/local/nginx/sbin/nginx" >> /etc/rc.local (设置成开机启动)
vi /usr/local/nginx/conf/nginx.conf
#include server/demo.com(可以根据项目include配置不同站点)
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