CentOS7 The biggest change is systemd instead of the past SYSTEMV service, so the configuration of services changed, with Systemctl replace the past service, Chkconfig and other commands.
Site relocation server, new server of course with the new system, so installed on the CentOS7.
PHP5.4 Compile Parameters:
./configure --build=x86_64-redhat-linux-gnu --host=x86_64-redhat-linux-gnu --with-layout=gnu --prefix=/usr/local --exec-prefix=/usr/local --sysconfdir=/etc --libdir=/usr/ Local/lib/php --sbindir=/usr/local/sbin --sharedstatedir=/usr/com --datadir=/usr/local/share --includedir=/usr/local/include --libexecdir=/usr/local/libexec --localstatedir=/run -- mandir=/usr/local/share/man --infodir=/usr/local/share/info --with-config-file-path=/etc -- With-config-file-scan-dir=/etc/php.d --with-pic --with-curl --with-freetype-dir --with-png-dir --with-gettext=shared --with-gmp=shared --with-iconv -- with-jpeg-dir --with-png-dir --with-openssl --with-libxml-dir --with-pcre-regex -- with-mcrypt --with-zlib --with-mhash --with-pear --with-gd -- enable-gd-native-ttf --enable-calendar=shared --enable-exif --enable-ftp --enable-sockets --enable-bcmath=shared --enable-pcntl -- enable-intl --enable-mbstring --enable-zip --with-bz2 --without-unixodbc -- enable-mbregex --enable-fpm --with-fpm-user=www --with-fpm-group=www -- disable-tokenizer --disable-phar --enable-sysvsem --enable-sysvshm --enable-sysvmsg - -disable-cgi --with-pgsql=/usr/pgsql-9.4 --with-pdo-pgsql=/usr/pgsql-9.4 -- With-pdo-mysql --with-mysql --with-mysql-sock=/var/lib/mysql/mysql.sock --with-mysqli= Shared --enable-mysqlnd \
nginx1.8.0 Compilation Parameters
./configure --prefix=/usr/local/nginx --conf-path=/etc/nginx/nginx.conf --sbin-path =/usr/local/sbin/nginx --user=nginx --group=www --with-http_ssl_module -- With-http_realip_module --with-http_stub_status_module --with-file-aio --pid-path=/run/nginx.pid --lock-path=/run/nginx/nginx.lock --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --http-client-body-temp-path=/run/nginx/client --http-proxy-temp-path=/run/ nginx/proxy --http-fastcgi-temp-path=/run/nginx/fcgi --with-debug --without-http_ssi_module --without-http_scgi_module -- Without-http_uwsgi_module --without-http_autoindex_module --without-http_ Memcached_module --withOut-http_proxy_module --without-http_map_module --without-http_geo_module --without-http_auth_basic_module --without-http_upstream_ip_hash_module --without-http_split_clients_module --without-select_module \
/etc/php-fpm.conf content
[global]pid = /run/php-fpm/php-fpm.piderror_log = /var/log/php-fpm.loglog_level = warningemergency_restart_threshold = 10emergency_restart_interval = 60process_ control_timeout = 300sdaemonize = yesrlimit_files = 10240[www0]prefix = /run/php-fpm/pools/$poollisten = /run/php-fpm/php-fpm0.socklisten.backlog = 2048listen.owner = wwwlisten.group = wwwlisten.mode = 0666user = wwwgroup = wwwpm = staticpm.max_children = 30pm.max_requests = 500pm.status_path = /statusrequest_terminate_timeout = 600request_slowlog_timeout = 30slowlog = /var/log/nginx/slow.logenv[tmp] = /run/php-fpm/tmpenv[tmpdir] = /run/php-fpm/tmpenv[temp] = /run/php-fpm/tmp [www1]prefix = /run/php-fpm/pools/ $poollisten = /run/php-fpm/php-fpm1.socklisten.backlog = 2048listen.owner = wwwlisten.group = wwwlisten.mode = 0666user = wwwgroup = wwwpm = staticpm.max_children = 10pm.max_ Requests = 500pm.status_path = /statusrequest_terminate_timeout = 600request_ slowlog_timeout = 30slowlog = /var/log/nginx/slow.logenv[tmp] = /run/php-fpm/ Tmpenv[tmpdir] = /run/php-fpm/tmpenv[temp] = /run/php-fpm/tmp
Edit php-fpm startup configuration file/etc/systemd/system/php-fpm.service
[Unit] Description=the PHP FastCGI Process managerafter=syslog.target network.targetbefore=nginx.service[service]type= FORKING#TYPE=NOTIFYPIDFILE=/RUN/PHP-FPM/PHP-FPM.PIDEXECSTART=/USR/LOCAL/SBIN/PHP-FPM--fpm-config/etc/ php-fpm.conf EXECRELOAD=/BIN/KILL-USR2 $MAINPIDPrivateTmp =true[install]wantedby=multi-user.target
Nginx Service Configuration/etc/systemd/system/nginx.service
[Unit] Description=the nginx HTTP and reverse proxy server @ifxdbAfter =network.target remote-fs.target nss-lookup.target php-fpm.service[service]type=forkingpidfile=/run/nginx.pidexecstartpre=/usr/local/sbin/nginx-texecstart=/usr/ Local/sbin/nginxexecreload=/bin/kill-s HUP $MAINPIDExecStop =/bin/kill-s QUIT $MAINPIDKillMode =processkillsignal= Sigquittimeoutstopsec=5privatetmp=true[install]wantedby=multi-user.target
Edit the virtual file configuration (Centos7/run is hooked up with TMPFS, the directory disappears after reboot and the specified default is regenerated)
/etc/tmpfiles.d/php-fpm.conf
# systemd tmpfile settings for php-fpm and nginx# see TMPFILES.D (5) for detailsd /run/nginx 0755 nginx root - -d /run/ nginx/client 0755 nginx root 10d -d /run/nginx/fcgi 0755 nginx root 10d -d /run/nginx/proxy 0755 nginx root 10d -d /run/nginx/ Cache0 0755 nginx root 10d -d /run/nginx/cache1 0755 nginx root 10d -d /run/nginx/cache2 0755 nginx root 10d -d /run/nginx/ cache3 0755 nginx root 10d -d /run/php-fpm 0755 www www 10d -d /run/php-fpm/tmp 0755 www www 3d -d /run/php-fpm/session 0755 www www 1d -d /run/php-fpm/pools 0755 www www 3d -d / Run/php-fpm/pools/www0 0755 www www - -d /run/php-fpm/pools/www1 0755 www www - -d /run/php-fpm/pools/www2 0755 www www - -d /run/php-fpm/pools/www3 0755 www www - -d /run/pear 0755 www www 3d -d /run/ pear/tmp 0755 www www 3d -
The compilation configuration is complete. Enabling and starting Services
sudo systemctl daemon-reloadsudo systemctl enable Nginx Php-fpmsudo systemctl start Nginx php-fpm
---------------------------------------------------------------------
PHP5.4 is a bit old, ready to install the latest stable version of 5.6 try and prepare for the upcoming PHP7. Used to run tests on a separate server, now how do I set it up on a single server?
First compile the PHP5.6, notice that the prefix becomes/OPT
./configure --build=x86_64-redhat-linux-gnu --host=x86_64-redhat-linux-gnu --with-layout=gnu --prefix=/opt/local --exec-prefix=/opt/local --sysconfdir=/etc --libdir=/opt/ Local/lib/php --sbindir=/opt/local/sbin --sharedstatedir=/usr/com --datadir=/opt/local/share --includedir=/opt/local/include --libexecdir=/opt/local/libexec --localstatedir=/run -- mandir=/opt/local/share/man --infodir=/opt/local/share/info --with-config-file-path=/opt -- with-config-file-scan-dir=/opt/php.d --enable-opcache --with-fpm-acl --with-pic -- with-curl --with-freetype-dir --with-png-dir --with-gettext=shared --with-gmp= Shared --with-iconv --with-jpeg-dir --with-png-dir --with-openssl --with-libxml-dir --with-pcre-regex --with-mcrypt --with-zlib --with-mhash --with-pear -- With-gd --enable-gd-native-ttf --enable-calendar=shared --enable-exif --enable-ftp --enable-sockets -- enable-bcmath=shared --enable-pcntl --enable-intl --enable-mbstring --enable-zip -- with-bz2 --without-unixodbc --enable-mbregex --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-fpm-systemd --disable-tokenizer --disable-phar -- enable-sysvsem --enable-sysvshm --enable-sysvmsg --disable-cgi --with-pgsql=/usr/ pgsql-9.4 --with-pdo-pgsql=/usr/pgsql-9.4 --with-pdo-mysql --with-mysql -- With-mysql-sock=/var/lib/mysql/mysql.sock --enable-mysqlnd \
Then edit/etc/php-fpm2.conf, note php-fpm2.pid
pid = /run/php-fpm/php-fpm2.pid; ....... other unchanging [www2]prefix = /run/php-fpm/pools/$ poollisten = /run/php-fpm/php-fpm2.socklisten.backlog = 2048listen.owner = wwwlisten.group = wwwlisten.mode = 0666user = wwwgroup = wwwpm = staticpm.max_children = 10pm.max_requests = 500pm.status_path = / statusrequest_terminate_timeout = 600request_slowlog_timeout = 30slowlog = /var/ log/nginx/slow.logenv[tmp] = /run/php-fpm/tmpenv[tmpdir] = /run/php-fpm/tmpenv[temp] = /run/php-fpm/tmp [www3]prefix = /run/php-fpm/pools/$poollisten = /run/php-fpm/ php-fpm3.socklisten.backlog = 2048listen.owner = wwwlisten.group = Wwwlisten.mode = 0666user = wwwgroup = wwwpm = staticpm.max_children = 10pm.max_requests = 500pm.status_path = /statusrequest_terminate_timeout = 600request_slowlog_timeout = 30slowlog = /var/log/nginx/slow.logenv[tmp] = /run/php-fpm/tmpenv[tmpdir] = /run/php-fpm/tmpenv[temp] = /run/php-fpm/tmp
Then copy the php.ini
sudo cp-p/etc/php.ini/opt/php56.ini
php5.6 Configuration Relative 5.4 does not change, except default_charset = "UTF-8" This need to set
===============================
The key comes, how to configure the PHP-FPM service?
Edit/etc/systemd/system/php-fpm2.service
[Unit] Description=the PHP FastCGI Process Manager @developAfter =syslog.target network.targetbefore=nginx.service[service]# Type=forkingtype=notifypidfile=/run/php-fpm/php-fpm2.pidexecstart=/opt/local/sbin/php-fpm-c/opt/php56.ini-- fpm-config/etc/php-fpm2.conf EXECRELOAD=/BIN/KILL-USR2 $MAINPIDPrivateTmp =truewatchdogsec=30restart=always[ Install]wantedby=multi-user.target
Notice above pidfile, execstart parameter changed. In addition the type with the original forking also line, but change to notify has a benefit below said.
Modify the/etc/nginx/nginx.conf file
http { upstream php_servers{ server unix:/run/php-fpm/php-fpm0.sock; server unix:/run/php-fpm/php-fpm1.sock; #server unix:/run/php-fpm/php-fpm2.sock ; #server unix:/run/php-fpm/php-fpm3.sock ; } upstream php_servers2{ #server unix:/run/php-fpm/ php-fpm0.sock; #server unix:/run/php-fpm/php-fpm1.sock; server unix:/run/php-fpm/php-fpm2.sock ; server unix:/run/php-fpm/php-fpm3.sock ; }
Then modify the Nginx site configuration, specify the use of PHP_SERVERS2 as the resolution in the test site
Location ~ \.php$ {try_files $uri = 404; # Primary script unknown access_log off in the masking log; Log_not_found off; #fastcgi_pass php_servers; Fastcgi_pass php_servers2; Include fastcgi.conf; }
Restart Service
sudo systemctl daemon-reloadsudo systemctl start Php-fpm2sudo systemctl Reload Nginx
So many versions of PHP are running at the same time.
Look at the state of Php-fpm2.service.
$ sudo systemctl status php-fpm2php-fpm2.service - the php fastcgi Process Manager -develop Loaded: loaded (/etc/systemd/system/ php-fpm2.service; enabled) Active: active (running) since Thu 2015-09-24 16:19:08 cst; 1 day 4h ago main pid: 21928 ( PHP-FPM) Status: "processes active: 1, idle: 89, requests: 197553, slow: 0, traffic: 17.2req/sec " cgroup: /system.slice/ PHP-FPM2.SERVICE           ├─ 2841 PHP-FPM: pool www3 ├─ 2845 php-fpm: pool www3 ├─ 2846 php-fpm: pool www3 &nbsP; ├─ 2847 php-fpm: pool www3
Did you see this line?
Status: "Processes active:1, idle:89, requests:197553, slow:0, traffic:17.2req/sec"
This is the feature of the Notify type, which provides real-time statistics.
Finish the call, the word is not more than ~ ~
9,977 characters are currently entered, you can also enter 23 characters
Compile multiple versions of PHP on CentOS7 and run and SYSTEMD settings at the same time