[root@rehl6802 conf]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 6.8 (Santiago)
[root@rehl6802 conf]# /usr/local/nginx/sbin/nginx -v
Tengine version: Tengine/2.2.3 (nginx/1.8.1)
[root@rehl6802 conf]# php-fpm -v
PHP 5.6.40 (fpm-fcgi) (built: Jan 16 2019 05:55:21)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
setenforce 0
sed -i -r "/^SELINUX=/c SELINUX=disabled" /etc/selinux/config
which systemctl && systemctl stop firewalld
which systemctl && systemctl disable firewalld
which systemctl && systemctl stop iptables || service iptables stop
which systemctl && systemctl disable iptables || chkconfig iptables off
mkdir /mnt/cdrom
mount /dev/cdrom /mnt/cdrom
cat </etc/yum.repos.d/local.repo
[local]
name=local
baseurl=file:///mnt/cdrom
gpgcheck=0
enabled=1
EOF
yum clean all #清理本地缓存
yum clean plugins #清理插件缓存
yum makecache #构建缓存
yum groupinstall -y "Development Tools"
curl -o /home/pcre-8.42.tar.gz https://ftp.pcre.org/pub/pcre/pcre-8.42.tar.gz
tar vxzf pcre-8.42.tar.gz
cd pcre-8.42
./configure && echo $?
make && make install && echo $?
wget http://www.zlib.net/zlib-1.2.11.tar.gz
tar vxzf zlib-1.2.11.tar.gz
cd zlib-1.2.11
./configure && echo $?
make && make install && echo $?
wget https://www.openssl.org/source/openssl-1.1.1a.tar.gz
tar vxzf openssl-1.1.1a.tar.gz
cd openssl-1.1.1a
./config
make && make install && echo $? && echo $?
ln -s /usr/local/lib/libpcre.so.1 /lib64
ln -s /usr/local/lib64/libssl.so.1.1 /usr/lib64/libssl.so.1.1
ln -s /usr/local/lib64/libcrypto.so.1.1 /usr/lib64/libcrypto.so.1.1
openssl version
curl -o /home/tengine-2.2.3.tar.gz http://tengine.taobao.org/download/tengine-2.2.3.tar.gz
tar -vxf tengine-2.2.3.tar.gz
cd tengine-2.2.3
./configure --with-http_ssl_module && echo $?
make && make install && echo $?
默认安装路径:/usr/local/nginx
# 启动Nginx
/usr/local/nginx/sbin/nginx
# 优雅的重启(重载配置文件,如果配置文件有错误的话,会继续使用之前配置运行)
/usr/local/nginx/sbin/nginx -s reload
-s stop 快速停止
-s quit 优雅的退出
-s reopen 重新打开日志文件
-s reload 重新加载配置文
# 测试配置文件是否正确
/usr/local/nginx/sbin/nginx -t
yum install -y cyrus-sasl-2.1.23-15.el6_6.2.x86_64.rpm \
cyrus-sasl-devel-2.1.23-15.el6_6.2.x86_64.rpm \
freetype-devel-2.3.11-17.el6.x86_64.rpm \
libjpeg-turbo-devel-1.2.1-3.el6_5.x86_64.rpm \
libpng-1.2.49-2.el6_7.x86_64.rpm \
libpng-devel-1.2.49-2.el6_7.x86_64.rpm \
libxml2-2.7.6-21.el6.x86_64.rpm \
libxml2-devel-2.7.6-21.el6.x86_64.rpm \
openldap-2.4.40-16.el6.x86_64.rpm \
openldap-devel-2.4.40-16.el6.x86_64.rpm \
zlib-devel-1.2.3-29.el6.x86_64.rpm
wget http://101.96.10.63/cn2.php.net/distributions/php-5.6.40.tar.gz
tar -vxf php-5.6.40.tar.gz
cp -frp /usr/lib64/libldap* /usr/lib/
cd php-5.6.40
./configure --enable-bcmath --enable-mbstring --enable-fpm --enable-mbstring \
--enable-sockets --with-mysql --with-gettext \
--with-ldap --with-png-dir --with-jpeg-dir --with-freetype-dir --with-gd \
&& echo $?
make && make install && echo $?
cp php.ini-development /usr/local/php/php.ini
cp /usr/local/etc/php-fpm.conf.default /usr/local/etc/php-fpm.conf
cp sapi/fpm/php-fpm /usr/local/bin
# It is important that we prevent Nginx from passing requests to the PHP-FPM backend if the file does not exists,
# 重要的是,如果文件不存在,我们阻止Nginx将请求传递给PHP-FPM后端
# allowing us to prevent arbitrarily script injection.
# 这样我们就可以防止任意脚本注入。
# We can fix this by setting the cgi.fix_pathinfo directive to 0 within our php.ini file.
# 我们可以通过在php.ini文件中将cgi.fix_pathinfo 指令设置为0来解决这个问题 。
vim /usr/local/php/php.ini
# 修改为:
cgi.fix_pathinfo=0
/usr/local/bin/php-fpm
vim /usr/local/nginx/conf/nginx.conf
# 增加以下内容
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
#fastcgi_param SCRIPT_NAME $fastcgi_script_name;
include fastcgi_params;
}
# 修改以下内容(增加index.php)
location / {
root html;
index index.html index.htm;
}
vim /usr/local/nginx/html/index.php
/usr/local/nginx/sbin/nginx -s reload
参考:http://php.net/manual/en/install.unix.nginx.php
PHP-5.6.40:https://pan.baidu.com/s/1pCeQj63vei-8HQsj2rkPJQ
Tengine-2.2.3:https://pan.baidu.com/s/1sR-39mw5RJ9q5mCu-Loupg