Centos6.4 compile and install the Nginx PHP code sample method of the detailed introduction

Source: Internet
Author: User
Tags mcrypt
This article mainly introduces the Centos6.4 compiler to install Nginx PHP method, the need for friends can refer to the following

I. Preparing a dependent library

Install Make:

Yum-y install gcc automake autoconf libtool make

Install g++:

Yum Install gcc gcc-c++

Two. Compile and install Pcre

Pcre is a library of regular expressions, the compiler needs to rely on the library to implement the URL rewrite

Download source code

Cd/usr/local/srcwget Ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.33.tar.bz2tar JXVF pcre-8.33.tar.bz2

Compiling the installation

CD Pcre-8.33./configuremakemake Install

Three. Compile and install the Zlib library

ZLIB is gzip implemented

Download source code

Cd/usr/local/srcwget HTTP://WWW.PHP.CN/TAR-ZXVF zlib-1.2.8.tar.gz

Compiling the installation

CD Zlib-1.2.8./configuremakemake Install

Four. Installing OpenSSL

Check if SSL is installed

# Rpm-qa|grep Opensslopenssl-devel-1.0.1e-16.el6_5.14.x86_64openssl-1.0.1e-16.el6_5.14.x86_64

If not installed

Download source code

Cd/usr/local/srcwget HTTP://WWW.PHP.CN/TAR-ZXVF openssl-1.0.1c.tar.gz

Compiling the installation

./configuremakemake Install

Five. Compile and install Nginx

Cd/usr/local/srcwget http://www.php.cn/tar-zxvf nginx-1.2.8.tar.gzcd nginx-1.2.8./configure--sbin-path=/usr/local /nginx/nginx \--conf-path=/usr/local/nginx/nginx.conf \--pid-path=/usr/local/nginx/nginx.pid \--with-http_ssl_ module \--with-pcre=/usr/local/src/pcre-8.33 \--with-zlib=/usr/local/src/zlib-1.2.8 \--with-openssl=/usr/local/ src/openssl-1.0.1c make make Install

Verify the installation succeeds after the installation is complete

/usr/local/nginx/nginx Netstat-alptn|grep 80

Six. Compiling and installing PHP

The new version of PHP has integrated the PHP-FPM

1. Preparatory work

Yum-y Install libmcrypt-devel mhash-devel libxslt-devel\ libjpeg libjpeg-devel libpng libpng-devel freetype Freetype-dev El libxml2 libxml2-devel\ zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel\ ncurses ncurses-devel cur L curl-devel e2fsprogs e2fsprogs-devel\ krb5 krb5-devel libidn libidn-devel OpenSSL openssl-devel

2. Source code Compilation Installation Libmcrypt

wget FTP://MCRYPT.HELLUG.GR/PUB/CRYPTO/MCRYPT/ATTIC/LIBMCRYPT/LIBMCRYPT-2.5.7.TAR.GZTAR-ZXVF libmcrypt-2.5.7.tar.gz CD libmcrypt-2.5.7./configuremakemake Install

3. Download the source code

wget Http://www.php.cn/tar zvxf php-5.4.7.tar.gz

4. Compiling the installation CD php-5.4.7

./configure--prefix=/usr/local/php      \   --enable-fpm         \   --enable-mbstring        \   -- Enable-sockets        \   --enable-sysvsem        \   --enable-sysvshm        \   --enable-pcntl         \   -- Enable-mbregex        \   --enable-zip         \   --enable-inline-optimization     \   --disable-pdo         \   --disable-debug        \   --disable-rpath        \   --with-mcrypt         \   --with-zlib         \   --with-bz2          \   --with-mhash         \   --with-curl         \   --with-mysql         \   --WITH-GD          \   --with-pcre-regex        \   --with-libdir=lib64

If you report the following error

Configure:error:Don ' t know how to define struct flock on the This system, set--enable-opcache=no

Modify the/etc/ld.so.conf file

vi/etc/ld.so.conf.d/local.conf# Add 2 lines/usr/local/lib64//64 system/usr/local/src/libmcrypt-2.5.7/lib/.libs# Execute the following command chmod gu+x/etc/ld.so.conf.d/local.conf# execute the following command to make it effective ldconfig-v

Execute the command again

Compile and install after success

Seven. Configure startup

1. Configure PHP-FPM

Cd/usr/local/phpcp/etc/php-fpm.conf.default/etc/php-fpm.confvi/etc/php-fpm.conf

Modify
user = Llong
Group = Llong

2. Modify Nginx Support PHP-FPM

Open nginx.conf

Where the server segment adds the following configuration, note the Red content configuration, otherwise there will be no input file specified. Error

# Pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000#location ~ \.php$ {root Html;fastcgi_pass 127.0.0.1:9 000;fastcgi_index index.php;fastcgi_param script_filename $document _root$fastcgi_script_name;include fastcgi_ params;}

3. Test whether the configuration is successful

Create the index.php file under/usr/local/nginx/html, and enter the following:

<? Echo Phpinfo ();?>

Start PHP-FPM and Nginx

/USR/LOCAL/PHP/SBIN/PHP-FPM (Manual patching start mode/usr/local/php/sbin/php-fpm start)/usr/local/nginx/nginx

The above is Centos6.4 compiler installation Nginx PHP code sample method of the details of the content, more relevant content please pay attention to topic.alibabacloud.com (www.php.cn)!

  • 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.