Linux-rhel6.4 compilation installs PHP,Nginx and php connection
Determine the dependency package installation
Gcc gcc-c++ libxml2 libxml2-devel bzip2 bzip2-devel libmcrypt libmcrypt-devel openssl openssl-devel libcurl-devel libjpeg-devel libpng-devel freetype-devel readline readline-devel libxslt-devel perl perl-devel psmisc.x86_64 recode recode-devel libtidy libtidy-devel
If there is no installation, mount the system image and find the installation package in the Packages folder, or you can install yum install directly if you have a yum source.
You can use the image to make your own local Yum source: http://kurol.blog.51cto.com/11433546/1927721
Get it from the official website, compile and install
[root@kurolz] # wget http://de2.php.net/get/php-5.5.38.tar.gz/from/this/mirror [root@kurolz] # tar-zxvf php-5.5.38.tar.gz [root@kurolz php-5.5.38] #. / configure-- prefix=/usr/local/php-5.5.0-- with-config-file-path=/usr/local/php-5.5.0/etc-- with-bz2-- With-curl-enable-ftp-enable-sockets-disable-ipv6-with-gd-with-jpeg-dir=/usr/local-with-png-dir=/usr/local-with-freetype-dir=/usr/local-enable-gd-native-ttf-with-iconv-dir=/usr/local-enable-mbstring-enable-calendar-with-gettext with-libxml-dir=/usr/local with-zlib with-pdo-mysql=mysqlnd with-mysqli=mysqlnd- -with-mysql=mysqlnd-enable-dom-enable-xml-enable-fpm-with-libdir=lib64.creating main/internal_functions_cli.c+----+ | License: | | This software is subject to the PHP License | Available in this | | distribution in the file LICENSE. By continuing this installation | | process, you are bound by the terms of this license agreement. | | If you do not agree with the terms of this license, you must abort | | the installation process at this point. | | | +-+ Thank you for using PHP.config.status: creating php5.specconfig.status: creating main/build-defs.hconfig.status: creating scripts/phpizeconfig.status: creating scripts/man1/phpize.1config.status: creating scripts/php- | Configconfig.status: creating scripts/man1/php-config.1config.status: creating sapi/cli/php.1config.status: creating sapi/fpm/php-fpm.confconfig.status: creating sapi/fpm/init.d.php-fpmconfig.status: creating sapi/fpm/php-fpm.serviceconfig.status: creating sapi/fpm/php-fpm.8config.status: creating sapi/fpm/status.htmlconfig.status: creating sapi/cgi/php-cgi.1config.status: creating ext/phar/phar.1config.status: creating ext/ Phar/phar.phar.1config.status: creating main/php_config.hconfig.status: executing default commands [root@kurolz ~] # make [root@kurolz ~] # make install [root@kurolz ~] # cd php-5.5.38 [root@kurolz php-5.5.38] # cp php.ini-production / usr/local/php-5.5.0/etc/php.ini [root@kurolz php-5.5.38] # cd / usr/local/php-5.5.0/ Etc/ [root@kurolz etc] # cp php-fpm.conf.default php-fpm.conf [root@kurolz etc] # cd / usr/local/php-5.5.0/sbin [root@kurolz sbin] #. / php-fpm
Nginx connects with php
Main points:
1:Nginx supports fastcgi by default
2:php compilation enables the module:
-- enable-fpm
Connection:
[root@kurolz ~] # vim / usr/local/nginx/conf/nginx.conf server {listen 80; server_name localhost; location / {root html; index index.html index.php;}. Location ~\ .php$ {root html; fastcgi_pass 127.0.0.1 root html; fastcgi_pass 9000; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params;}
Restart nginx:
[root@kurolz ~] # cd / usr/local/nginx/sbin [root@kurolz sbin] #. / nginx-s reload
Add a php test file:
[root@kurolz ~] # cd / usr/local/nginx/html [root@kurolz ~] # touch info.php [root@kurolz ~] # vim info.php
Browser test:
Save the pid file in var/run
[root@kurolz ~] # vim / usr/local/php-5.5.0/etc/php-fpm.confpid = run/php-fpm.pid
Configure Boot boot php-fpm
You can use service php-fpm [start | restart | stop] to enable, restart, and shut down.
[root@kurolz ~] # vim / etc/init.d/php-fpm
Write the following script to / etc/init.d/php-fpm, and modify the path of lines 12-15 yourself.
#! / bin/sh # # php-fpm-this script starts and stops the php-fpm daemin # # chkconfig:-85 15 # processname: php-fpm # config: / usr/local/php/etc/php-fpm.conf set-e PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin DESC= " Php-fpm daemon "NAME=php-fpm DAEMON=/usr/local/php-5.5.0/sbin/php-fpm CONFIGFILE=/usr/local/php-5.5.0/etc/php-fpm.conf PIDFILE=/usr/local/php-5.5.0/var/run/php-fpm.pid SCRIPTNAME=/etc/init.d/php-fpm # If the daemon file is not found Terminate the script. Test-x $DAEMON | | exit 0 d_start () {$DAEMON-y $CONFIGFILE | | echo-n "already running"} d_stop () {kill-QUIT `cat $PIDFILE` | | echo-n "no running"} d_reload () {kill-HUP `cat $PIDFILE` | echo-n "could not reload"} case "$1" in start) Echo-n "Starting $DESC: $NAME" d_start echo. " ; stop) echo-n "Stopping $DESC: $NAME" d_stop echo ".;; reload) echo-n" Reloading $DESC configuration... " D_reload echo "Reloaded."; restart) echo-n "Restarting $DESC: $NAME" d_stop # Sleep for two seconds before starting again, this should give the nginx daemon some time to perform a graceful stop sleep 2 d_start echo "." *) echo "Usage: $SCRIPTNAME {start | stop | restart | force-reload)" > & 2 exit 3;; esac exit 0
Give any user executable permission to php-fpm
[root@kurolz ~] # chmod aquiw / etc/init.d/php-fpm
Set up boot boot
[root@kurolz ~] # chkconfig php-fpm on