一、nginx 安装
1. 在nginx官网下载nginx源码
提供一个nginx官网下载地址:
http://nginx.org/download/nginx-1.12.2.tar.gz
注意:请先确认 是否已经安装过 pcre pcre-devel openssl openssl-devel zlib zlib-devel
如果没有,请先安装这些依赖文件
sudo yum install pcre pcre-devel openssl openssl-devel zlib zlib-devel
./configure --prefix=/usr/local/nginx
sudo make && make install
创建www-data用户
useradd -s /sbin/nologin -M www-data
配置文件
sudo vim /usr/local/nginx/conf/nginx.conf
location / {
root web根目录;
index index.html index.htm index.php;
}
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;#$document_root?=web根目录
include fastcgi_params;
}
注意:web根目录 /develop/nginx/html/
启动nginx
nginx/sbin/nginx -s reload //平滑重启nginx
nginx/sbin/nginx -c /nginx.conf //启动
nginx/sbin/nginx -t //检查配置文件是否正确
kill -QUIT nginx的pid //从容关闭nginx
二、php-fpm安装
需要先安装依赖 libxml2
yum install libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel gmp gmp-devel libmcrypt libmcrypt-devel readline readline-devel libxslt libxslt-devel libicu-devel
php7.2.16下载地址
https://www.php.net/distributions/php-7.2.16.tar.gz
--enable-maintainer-zts //关闭线程安全的使用,通常都不需要线程安全
在php官网下载php源码,解压 开始安装
./configure --prefix=/usr/local/php72 --with-mysqli=shared,mysqlnd --enable-fpm --enable-opcache --enable-bcmath --enable-calendar --enable-intl --enable-mbstring --enable-pcntl --enable-soap --enable-sockets --enable-zip --with-pdo-mysql=mysqlnd --with-curl
开启所有基础扩展
./configure \
--prefix=/usr/local/php \
--with-mhash \
--with-openssl \
--with-config-file-path=/usr/local/php/etc \
--enable-fpm \
--with-fpm-user=php-fpm \
--with-fpm-group=php-fpm \
--enable-bcmath \
--enable-calendar \
--enable-intl \
--enable-mbstring \
--enable-pcntl \
--enable-soap \
--enable-sockets \
--enable-zip \
--enable-mysqlnd \
--enable-mysqlnd-compression-support \
--with-mysqli=shared,mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-pdo-pgsql=
--enable-ftp \
--with-curl \
--with-xsl \
--with-iconv \
--with-zlib \
--with-xmlrpc \
--with-gettext \
--enable-opcache \
./configure --prefix=/usr/local/php56 --with-mysqli=shared,mysqlnd --enable-fpm --enable-maintainer-zts
sudo make && make install
解释:
--enable-maintainer-zts 表示安装的线程安全版
--enable-opcache 开启opcache
提供一个php5.5.38官网下载地址
http://cn2.php.net/get/php-5.5.38.tar.gz/from/this/mirror
提供一个php-5.6.34下载地址
http://php.net/get/php-5.6.38.tar.gz/from/this/mirror //更快
http://cn2.php.net/get/php-5.6.38.tar.gz/from/this/mirror
https://www.php.net/distributions/php-5.6.38.tar.gz
复制安装目录下 php.ini-develop 到 安装目录 php/lib/php.ini
配置php-fpm
/php7/etc
sudo mv /php7/etc/php-fpm.conf.default /php7/etc/php-fpm.conf
sudo vim php-fpm.conf
;pid = run/php-fpm.pid 去掉前面的 ;
sudo mv /etc/php-fpm.d/www.conf.default /etc/php-fpm.d/www.conf
sudo vim www.conf
user = www-data
group = www-data
扩展目录的路径
/php5/lib/php/extensions/no-debug-zts-20121212/
//待确认
listen.owner = nobody
listen.group = nobody
listen.mode = 0660
启动php-fpm
/develop/php7/sbin/php-fpm
关闭php-fpm服务
ps -ef|grep php-fpm
找到 php-fpm master主进程
结束进程 sudo kill php-fpm的进程ID
sudo kill -TERM PID