This article describes how to compile and install nginxphp in Centos6.4. For more information, see the following article.
1. prepare the dependent database
Install make:
yum -y install gcc automake autoconf libtool make
Install g ++:
yum install gcc gcc-c++
2. Compile and install pcre
Pcre is a library of regular expressions. to compile nginx, you must rely on this library to implement 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
Compile and install
cd pcre-8.33./configuremakemake install
3. Compile and install the zlib library
Zlib is implemented by gzip
Download source code
cd /usr/local/srcwget #tar -zxvf zlib-1.2.8.tar.gz
Compile and install
cd zlib-1.2.8./configuremakemake install
4. install openssl
Check whether 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 #tar -zxvf openssl-1.0.1c.tar.gz
Compile and install
./configuremakemake install
5. Compile and install nginx
cd /usr/local/srcwget #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 whether the installation is successful after the installation is complete.
/usr/local/nginx/nginx netstat -alptn|grep 80
6. Compile and install php
Php-fpm has been integrated into the new version of php.
1. preparations
yum -y install libmcrypt-devel mhash-devel libxslt-devel\ libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel\ zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel\ ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel\ krb5 krb5-devel libidn libidn-devel openssl openssl-devel
2. Compile and install libmcrypt with source code
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 source code
wget #tar zvxf php-5.4.7.tar.gz
4. Compile and install 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 the following error is reported:
configure: error: Don't know how to define struct flock on 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 # run the following command chmod gu + x/etc/ld. so. conf. d/local. conf # execute the following command to make ldconfig-v take effect
Execute the command again
After successful compilation and installation
7. 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 to support php-fpm
Open nginx. conf
The following configuration is added to the server segment. pay attention to the configuration in red; otherwise, No input file specified will occur.
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000#location ~ \.php$ {root html;fastcgi_pass 127.0.0.1:9000;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 in/usr/local/nginx/html and enter the following content:
Start php-fpm and nginx
/Usr/local/php/sbin/php-fpm (manual patching startup method/usr/local/php/sbin/php-fpm start)/usr/local/nginx
The above is a detailed description of the sample method for compiling and installing nginx php code in Centos6.4. For more information, see The PHP Chinese website (www.php1.cn )!