php70wfpm,CentOS 7 安裝 Nginx、PHP7、PHP-FPM

修改 PHP-FPM listen 的方式

若想將 PHP-FPM listen 的方式,改成 unix socket,可以編輯 /etc/php-fpm.d/www.conf

listen = 127.0.0.1:9000

改成

listen = /var/run/php-fpm/php-fpm.sock

然後重新啟動 php-fpm

systemctl restart php-fpm

註:不要改成 listen = /tmp/php-fcgi.sock (將 php-fcgi.sock 設定在 /tmp 底下), 因為系統產生 php-fcgi.sock 時,會放在 /tmp/systemd-private-*/tmp/php-fpm.sock 隨機私有目錄下, 除非把 /usr/lib/systemd/system/ 裡面的 PrivateTmp=true 設定改成 PrivateTmp=false, 但還是會產生其他問題,所以還是換個位置最方便

删除之前的版本

# yum remove php*

rpm 安装 Php7 相应的 yum源

CentOS/RHEL 7.x:

# rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm # rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

CentOS/RHEL 6.x:

# rpm -Uvh https://mirror.webtatic.com/yum/el6/latest.rpm

yum安装php7

yum install php70w php70w-opcache

安装其他插件(选装)

注:如果安装pear,需要安装php70w-devel

php70w

php70w-bcmath

php70w-cli

php70w-common

php70w-dba

php70w-devel

php70w-embedded

php70w-enchant

php70w-fpm

php70w-gd

php70w-imap

php70w-interbase

php70w-intl

php70w-ldap

php70w-mbstring

php70w-mcrypt

php70w-mysql

php70w-mysqlnd

php70w-odbc

php70w-opcache

php70w-pdo

php70w-pdo_dblib

php70w-pear

php70w-pecl-apcu

php70w-pecl-imagick

php70w-pecl-xdebug

php70w-pgsql

php70w-phpdbg

php70w-process

php70w-pspell

php70w-recode

php70w-snmp

php70w-soap

php70w-tidy

php70w-xml

php70w-xmlrp

编译安装php7

配置(configure)、编译(make)、安装(make install)

使用configure --help

编译安装一定要指定定prefix,这是安装目录,会把所有文件限制在这个目录,卸载时只需要删除那个目录就可以,如果不指定会安装到很多地方,后边删除不方便。

Configuration: --cache-file=FILE cache test results in FILE --help print this message --no-create do not create output files --quiet, --silent do not print `checking...' messages --version print the version of autoconf that created configure Directory and file names: --prefix=PREFIX install architecture-independent files in PREFIX [/usr/local] --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX

注意

内存小于1G安装往往会出错,在编译参数后面加上一行内容--disable-fileinfo

其他配置参数

--exec-prefix=EXEC-PREFIX

可以把体系相关的文件安装到一个不同的位置,而不是PREFIX设置的地方.这样做可以比较方便地在不同主机之间共享体系相关的文件

--bindir=DIRECTORY

为可执行程序声明目录,缺省是 EXEC-PREFIX/bin

--datadir=DIRECTORY

设置所安装的程序需要的只读文件的目录.缺省是 PREFIX/share

--sysconfdir=DIRECTORY

用于各种各样配置文件的目录,缺省为 PREFIX/etc

--libdir=DIRECTORY

库文件和动态装载模块的目录.缺省是 EXEC-PREFIX/lib

--includedir=DIRECTORY

C 和 C++ 头文件的目录.缺省是 PREFIX/include

--docdir=DIRECTORY

文档文件,(除 “man(手册页)”以外, 将被安装到这个目录.缺省是 PREFIX/doc

--mandir=DIRECTORY

随着程序一起带的手册页 将安装到这个目录.在它们相应的manx子目录里. 缺省是PREFIX/man

注意: 为了减少对共享安装位置(比如 /usr/local/include) 的污染,configure 自动在 datadir, sysconfdir,includedir, 和 docdir 上附加一个 “/postgresql” 字串, 除非完全展开以后的目录名字已经包含字串 “postgres” 或者 “pgsql”.比如,如果你选择 /usr/local 做前缀,那么 C 的头文件将安装到 /usr/local/include/postgresql, 但是如果前缀是 /opt/postgres,那么它们将 被放进 /opt/postgres/include

--with-includes=DIRECTORIES

DIRECTORIES 是一系列冒号分隔的目录,这些目录将被加入编译器的头文件 搜索列表中.如果你有一些可选的包(比如 GNU Readline)安装在 非标准位置,你就必须使用这个选项,以及可能还有相应的 --with-libraries 选项.

--with-libraries=DIRECTORIES

DIRECTORIES 是一系列冒号分隔的目录,这些目录是用于查找库文件的. 如果你有一些包安装在非标准位置,你可能就需要使用这个选项 (以及对应的--with-includes选项)

--enable-XXX

打开XXX支持

--with-XXX

制作XXX模块

PHP FPM設定參考

[global]

pid = /usr/local/php/var/run/php-fpm.pid

error_log = /usr/local/php/var/log/php-fpm.log

[www]

listen = /var/run/php-fpm/php-fpm.sock

user = www

group = www

pm = dynamic

pm.max_children = 800

pm.start_servers = 200

pm.min_spare_servers = 100

pm.max_spare_servers = 800

pm.max_requests = 4000

rlimit_files = 51200

listen.backlog = 65536

;設 65536 的原因是-1 可能不是unlimited

;說明 http://php.net/manual/en/install.fpm.configuration.php#104172

slowlog = /usr/local/php/var/log/slow.log

request_slowlog_timeout = 10

nginx.conf 設定參考

user nginx;

worker_processes 8;

error_log /var/log/nginx/error.log warn;

pid /var/run/nginx.pid;

events {

use epoll;

worker_connections 65535;

}

worker_rlimit_nofile 65535;

#若沒設定,可能出現錯誤:65535 worker_connections exceed open file resource limit: 1024

http {

include /etc/nginx/mime.types;

default_type application/octet-stream;

log_format main '$remote_addr - $remote_user [$time_local] "$request" '

'$status $body_bytes_sent "$http_referer" '

'"$http_user_agent" "$http_x_forwarded_for"';

access_log /var/log/nginx/access.log main;

sendfile on;

tcp_nopush on;

keepalive_timeout 65;

server_names_hash_bucket_size 128;

client_header_buffer_size 32k;

large_client_header_buffers 4 32k;

client_max_body_size 8m;

server_tokens off;

client_body_buffer_size 512k;

# fastcgi

fastcgi_connect_timeout 300;

fastcgi_send_timeout 300;

fastcgi_read_timeout 300;

fastcgi_buffer_size 64k;

fastcgi_buffers 4 64k;

fastcgi_busy_buffers_size 128k;

fastcgi_temp_file_write_size 128k;

fastcgi_intercept_errors on;

#gzip (說明 http://nginx.org/en/docs/http/ngx_http_gzip_module.html)

gzip off;

gzip_min_length 1k;#1k以上才壓縮

gzip_buffers 32 4k;

#http://stackoverflow.com/questions/4888067/how-to-get-linux-kernel-page-size-programatically

#使用 getconf PAGESIZE 取得系統 one memory page size,

gzip_http_version 1.0;

gzip_comp_level 2;

gzip_types text/css text/xml application/javascript application/atom+xml application/rss+xml text/plain application/json;

#查看 nginx 的 mime.types 檔案(/etc/nginx/mime.types),裡面有各種類型的定義

gzip_vary on;

include /etc/nginx/conf.d/*.conf;

}

若出現出現錯誤:setrlimit(RLIMIT_NOFILE, 65535) failed (1: Operation not permitted)

先查看目前系統的設定值

ulimit -n

若設定值太小,修改 /etc/security/limits.conf

vi /etc/security/limits.conf

加上或修改以下兩行設定

* soft nofile 65535

* hard nofile 65535

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值