Nginx + PHP installation and integration

Source: Internet
Author: User
Tags mcrypt

Environment:

Linux moban 2.6.32-431.el6.x86_64 #1 SMP Fri Nov 03:15:09 UTC x86_64 x86_64 x86_64 gnu/linux

1, we use PHP is 5.3.27 version, in the enterprise is generally 5.2.17 this relatively classic version.
2, before the installation we have to confirm that MySQL and Nginx has been installed, run without problems, it is best to check again.

3, check if the relevant package is installed:
    rpm-qa zlib libxml Libjpeg freetype libpng gd  Curl libiconv  zlib-devel libxml2-devel     libjpeg-devel Freetype-devel libpng-devel gd-devel curl-devel
     does not affect the installation, But in the future the use of the site will be problematic
    yum install zlib libxml libjpeg freetype libpng gd  Curl libiconv  zlib-devel         libxml2-devel libjpeg-devel Freetype-devel libpng-devel gd-devel curl-devel-y

4, install character set conversion Library related, is a command; Note: devel must exist
Tar zxf libiconv-1.14.tar.gz
CD libiconv-1.14
./configure--prefix=/usr/local/libiconv
Make
Make install
Cd.. /

5. Add an encryption-related library
wget "Http://downloads.sourceforge.net/mcrypt/libmcrypt-2.5.8.tar.gz?modtime=1171868460&big_mirror=0"
Tar zxf libmcrypt-2.5.8.tar.gz
CD libmcrypt-2.5.8
./configure
Make
Make install
Sleep 2
/sbin/ldconfig
CD libltdl/
./configure--enable-ltdl-install
Make
Make install
Cd.. /.. /

6. Install mhash Encryption Extension Library

wget "Http://downloads.sourceforge.net/mhash/mhash-0.9.9.9.tar.gz?modtime=1175740843&big_mirror=0"
Tar zxf mhash-0.9.9.9.tar.gz
CD mhash-0.9.9.9/
./configure
Make
Make install
Sleep 2
Cd.. /

Rm-f/usr/lib64/libmcrypt.*
Rm-f/usr/lib64/libmhash*
Ln-s/usr/local/lib64/libmcrypt.la/usr/lib64/libmcrypt.la
Ln-s/usr/local/lib64/libmcrypt.so/usr/lib64/libmcrypt.so
Ln-s/usr/local/lib64/libmcrypt.so.4/usr/lib64/libmcrypt.so.4
Ln-s/usr/local/lib64/libmcrypt.so.4.4.8/usr/lib64/libmcrypt.so.4.4.8
Ln-s/USR/LOCAL/LIB64/LIBMHASH.A/USR/LIB64/LIBMHASH.A
Ln-s/usr/local/lib64/libmhash.la/usr/lib64/libmhash.la
Ln-s/usr/local/lib64/libmhash.so/usr/lib64/libmhash.so
Ln-s/usr/local/lib64/libmhash.so.2/usr/lib64/libmhash.so.2
Ln-s/usr/local/lib64/libmhash.so.2.0.1/usr/lib64/libmhash.so.2.0.1
Ln-s/usr/local/bin/libmcrypt-config/usr/bin/libmcrypt-config

7. Another encryption library
wget "http://downloads.sourceforge.net/mcrypt/mcrypt-2.6.8.tar.gz?modtime=1194463373& big_mirror=0"
Tar zxf mcrypt-2.6.8.tar.gz
CD mcrypt-2.6.8/
/sbin/ldconfig
./configure Ld_library_path=/usr/local/lib
Make
Make install
Cd.. /
Sleep 2

8. Yum Install libxslt*-y

----------------------------------------the above preparations have been completed-------------------------------


9, decompression Php:tar XF php-5.3.27.tar.gz
Pwd
/root/php-5.3.27
With Nginx compile:./configure \
--prefix=/application/php5.3.27 \
--with-mysql=/application/mysql \
--with-iconv-dir=/usr/local/libiconv \
--with-freetype-dir \
--with-jpeg-dir \
--with-png-dir \
--with-zlib \
--WITH-LIBXML-DIR=/USR \
--enable-xml \
--disable-rpath \
--enable-safe-mode \
--enable-bcmath \
--ENABLE-SHMOP \
--enable-sysvsem \
--enable-inline-optimization \
--with-curl \
--with-curlwrappers \
--enable-mbregex \
--ENABLE-FPM \
--enable-mbstring \
--with-mcrypt \
--WITH-GD \
--ENABLE-GD-NATIVE-TTF \
--WITH-OPENSSL \
--with-mhash \
--ENABLE-PCNTL \
--enable-sockets \
--WITH-XMLRPC \
--enable-zip \
--ENABLE-SOAP \
--enable-short-tags \
--enable-zend-multibyte \
--enable-static \
--with-xsl \
--with-fpm-user=nginx \
--with-fpm-group=nginx \
--enable-ftp

Attention: Thank you to using PHP. Indicates no problem.

Continue: Make && make install

Error: Libmysqlclient.so.18:cannot open Shared object file:no such file or directory
Make: * * * [ext/phar/phar.php] Error 127

FIX: Find/-name "libmysqlclient.so.18"
/home/oldboy/tools/mysql-5.5.32-linux2.6-x86_64/lib/libmysqlclient.so.18
/application/mysql-5.5.32-linux2.6-x86_64/lib/libmysqlclient.so.18

Append path/home/oldboy/tools/mysql-5.5.32-linux2.6-x86_64/lib/,/application/mysql-5.5.32-linux2.6-x86_64/lib/to/etc/ Ld.so.conf with Ldconfig in force.

Error: Generating Phar.phar
CHMOD: Unable to access "Ext/phar/phar.phar":

Solution: MkDir ext/phar/phar.phar-p

such as: Echo $? Returns to 0 that compiles successfully.

10. Create a soft link: ln-s/application/php5.3.27//application/php

11. Copy configuration file: CP Php.ini-production/application/php/lib/php.ini

12. Start File Rename: Mv/application/php/etc/php-fpm.conf.defult php-fpm.conf

13. Start PHP:/APPLICATION/PHP/SBIN/PHP-FPM
(-t check syntax)

14. Check if PHP Port 9000 is successful: Netstat-lntup|grep PHP-FPM



-----------------------------------Integrated Nginx------------------------------------

To edit the Nginx configuration file:


VI.. /nginx-1.6.2/conf/extra/blog.conf

server {
Listen 8000;
server_name blog.etiantian.org;
Root Html/blog;
Index index.php index.html index.htm;
Access_log Logs/blog_access.log;
Location ~. *\. (PHP|PHP5)? $
{
Fastcgi_pass 127.0.0.1:9000;
Fastcgi_index index.php;
Include fastcgi.conf;

}
}

VI nginx.conf

server {
Listen 80;
server_name blog.etiantian.org;
Root Html/blog;
Index index.php index.html index.htm;
Access_log Logs/blog_access.log;
Location ~. *\. (PHP|PHP5)? $
{
Fastcgi_pass 127.0.0.1:9000;
Fastcgi_index index.php;
Include fastcgi.conf;
}
}

Create a index.php file.

<?php
Phpinfo ();
?>

Check the syntax to restart the Nginx service.

Access. ~

This article from "As always" blog, declined reprint!

Nginx + PHP installation and integration

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.