nginx+php5.5 Environmental Assembly

Source: Internet
Author: User
nginx+php5.5 Environment Installation
1. Installing dependent Packages
Yum install-y gcc gcc-c++ make  cmake* autoconf* Apr apr-util libcurl* libxml2 libxml2-devel gd gd-devel  Bzip2-dev El freetype* ncurse*  bison*  openssl* libjpeg*


2. Download php5.5
Http://www.php.net/downloads.phpwget http://cn2.php.net/distributions/php-5.5.22.tar.gz


3. Compiling the installation
TAR-XVF php-5.5.22.tar.gzcd php-5.5.22./configure--prefix=/usr/local/php5--with-config-file-path=/usr/local/php5 /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= Lib64makemake Install

Note: This parameter supports, FTP, image function, PDO and other support, because the use of PHP comes with mysqlnd, so there is no need to install the MySQL Lib library.
If you are a 64-bit system, add--with-libdir=lib64 after the parameters
If PHP does not require the support of curl and FTP, the above –with-curl–enable-ftp can be removed.

4. Configure PHP
CP php.ini-production/usr/local/php5/etc/php.inicp/usr/local/php5/etc/php-fpm.conf.default/usr/local/php5/etc/ Php-fpm.conf


5. Start PHP-FPM
/usr/local/php5/sbin/php-fpm

Execute the above command, if no error is normally said to start normal, if not at ease, can also be judged by the port is php no boot
# NETSTAT-LNT | grep 9000tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN


6. Installing Nginx
Reference http://running.iteye.com/blog/326873

7. Configure Nginx
vi/usr/local/nginx/conf/nginx.conf    Server {        listen       ;        #server_name  127.0.0.1;        Root         /data/www/test/;        CharSet Utf-8;        Index   index.html index.php;        Location/{                try_files $uri $uri//index.php? $args;        }        # Pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000        # location        ~ \.php$ {                EXPIRES-1S;
  try_files $uri =404;                Fastcgi_split_path_info ^ (. +\.php) (/.+) $;                Include Fastcgi_params;                Fastcgi_param path_info $fastcgi _path_info;                Fastcgi_index index.php;                Fastcgi_param script_filename $document _root$fastcgi_script_name;                Fastcgi_pass 127.0.0.1:9000;        }        Location ~. *\. (Jpg| Jpg|jpeg| Jpeg|css|bmp|gif| Gif|png| PNG) $ {                access_log off;        }    }



8. Writing Test files
cd/data/www/phptest/vi/data/www/phptest/index.php
 
  


9. Start PHP-FPM and Nginx test
PHP-FPM start
/usr/local/php5/sbin/php-fpm

Nginx Boot
/usr/local/nginx/sbin/nginx


10.PHP-FPM Common Commands
INT, term immediately terminates
QUIT Smooth Termination
USR1 Reopen log file
USR2 smoothly overloads all worker processes and reloads the configuration and binary modules
Example:
PHP-FPM off:
Kill-int ' Cat/usr/local/php/var/run/php-fpm.pid '

PHP-FPM Restart:
KILL-USR2 ' Cat/usr/local/php/var/run/php-fpm.pid '

To view the number of PHP-FPM processes:
PS aux | Grep-c PHP-FPM


11. Change to Stock
Nginx will connect the loopback address 9000 port to execute PHP files, need to use the TCP/IP protocol, the speed is slow. We recommend that you switch to connect using the socket.
Create socket file
#touch/tmp/php-cgi/php-cgi.socket

Vim nginx.conf
Modify:
# Fastcgi_pass 127.0.0.1:9000;fastcgi_pass Unix:/tmp/php-cgi/php-cgi.socket;

In php-fpm.conf, modify the configuration to:
#listen = 127.0.0.1:9000listen =/tmp/php-cgi/php-cgi.socket
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.