环境背景:CentOS 7.2 本机IP 10.1.0.26
php
1、Nginx+Fastcgimysql
1、yum安装nginx,php-fpm,mariadb-server,php-mysql,php-gd php-mbstring php-mcryptnginx
#由于我以前都装好了,因此显示已安装 [root@localhost conf.d]# yum install nginx php-fpm mariadb-server php-mysql php-gd php- mbstring php-mcrypt Loaded plugins: fastestmirror, langpacks base | 3.6 kB 00:00:00 epel | 4.3 kB 00:00:00 Determining fastest mirrors Package matching 1:nginx-1.6.3-6.el7.x86_64 already installed. Checking for update. Package php-fpm-5.4.16-36.el7_1.x86_64 already installed and latest version Package 1:mariadb-server-5.5.44-2.el7.centos.x86_64 already installed and latest version Package php-mysql-5.4.16-36.el7_1.x86_64 already installed and latest version Package php-gd-5.4.16-36.el7_1.x86_64 already installed and latest version Package php-mbstring-5.4.16-36.el7_1.x86_64 already installed and latest version Package php-mcrypt-5.4.16-3.el7.x86_64 already installed and latest version Nothing to do
2、更改/etc/php-fpm.d/www.confsql
更改几项配置centos user和group改成nginx浏览器 user = nginx缓存 ; RPM: Keep a group allowed to write in log dir.bash group = nginxsession 打开ping、pang和statuside |
3、建立/var/lib/php/session,而且更改属组属主
[root@localhost conf.d]# mkidr /var/lib/php/session [root@localhost conf.d]# chown -R nginx:nginx /var/lib/php/session
4、更改/etc/nginx/conf.d/default.conf
5、启动mariadb,php-fpm,以及nginx服务,而后测试!
2、Nginx+Cache+FastCGI
1、建立缓存文件并更改属主属组
[root@localhost conf.d]# mkdir /var/cache/nginx/fastcgi_cache
2、配置nginx主配置文件
3、编辑/etc/nginx/conf.d/default.conf
4、从新启动Nginx服务并经过外界访问测试
注意:因为上面的cache在location 以.php结尾配置断中,因此并不会缓存ping和status的状态结果
3、Nginx+SSL
注意:/etc/nginx/conf.d/default.conf重置为最原始的状态。
1、建立Nginx的SSL配置文件
2、配置ssl证书即私钥文件
[root@localhost ~]# cd /etc/pki/CA/
[root@localhost CA]# touch index.txt [root@localhost CA]# echo 01 > serial [root@localhost CA]# cd /etc/nginx/ [root@localhost nginx]# mkdir ssl [root@localhost nginx]# cd ssl [root@localhost ssl]# (umask 077;openssl genrsa -out nginx.key 2048) Generating RSA private key, 2048 bit long modulus ..+++ ..........................................................+++ e is 65537 (0x10001) [root@localhost ssl]#
#本身给本身颁发证书 [root@localhost ssl]# openssl ca -in nginx.csr -out nginx.crt
3、重启服务并使用浏览器测试
注意:由于443和80端口为两个不一样的端口,http://10.1.0.26和https://101.0.26的结果是不同的,若是想让客户端输入http://10.1.0.26直接转到https,能够使用rewrite语句
谢谢浏览...