码迷,mamicode.com
首页 > Web开发 > 详细

centos中将nginx和php整合,nginx调优

时间:2018-04-19 20:02:45      阅读:197      评论:0      收藏:0      [点我收藏+]

标签:php   nginx   

首先yum安装插件,需花去根目录/大概2.2G的大小
#yum install gcc make pcre* openssl gd-devel libjpeg-devel libpng-devel libxml2-devel bzip2-devel libcurl-devel freetype-devel.x86_64 autoconf automake imake libxml2-devel expat-devel cmake gcc-c++ libaio libaio-devel bzr bison libtool ncurses5-devel net-snmp-devel libxml2-devel libcurl-devel -y

上传软件至/opt目录
1、编译nginx
解压并编译

cd /tmp &&tar -xzvf /tmp/nginx-1.13.0.tar.gz

#cd /tmp/nginx-1.13.0&&./configure --prefix=/usr/local/nginx-1.13.0 --with-http_ssl_module --with-pcre
#make && make install

添加nginx为系统服务

vi /etc/init.d/nginxd

内容如下

chmod 755 /etc/init.d/nginxd# chkconfig --add nginxd

2、配置PHP
#cp ?/tmp/php-7.1.4/php.ini-production /usr/local/php-7.1.4/etc/php.ini#cp /usr/local/php-7.1.4/etc/php-fpm.conf.default /usr/local/php-7.1.4/etc/php-fpm.conf#cp /usr/local/php-7.1.4/etc/php-fpm.d/www.conf.default /usr/local/php-7.1.4/etc/php-fpm.d/www.conf

vi /usr/local/php-7.1.4/etc/php.ini
参数改为以下数值:
max_execution_time = 300
memory_limit = 128M
post_max_size = 16M
upload_max_filesize = 2M
max_input_time = 300
date.timezone = PRC
启动,重启,终止操作
启动
#/usr/local/php-7.1.4/sbin/php-fpm
查看master进程

ps aux |grep php

3、关联nginx和php
worker_processes 2; 修改工作时的核心数error_log logs/error.log; 打开日志功能error_log logs/error.log notice;error_log logs/error.log info;pid logs/nginx.pid;events { use epoll; worker_connections 65530;}

   location ~ \.php$ {            root           html;            fastcgi_pass   127.0.0.1:9000;            fastcgi_index  index.php;            fastcgi_param  SCRIPT_FILENAME  /usr/local/nginx-1.13.0/html$fastcgi_script_name;      此处加上nginx的目录路径            include        fastcgi_params;        }

centos中将nginx和php整合,nginx调优

标签:php   nginx   

原文地址:http://blog.51cto.com/12131824/2105513

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!