centos中将nginx和php整合,nginx调优
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了centos中将nginx和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调优的主要内容,如果未能解决你的问题,请参考以下文章
夺命雷公狗---linux NO:33 linux下的nginx和php的整合