Operating Environment
Operating system: Mac OS Lion
Virtual Hosting: VMware Fusion
Virtual system: Centos 5.5+
Operation User: Root
Achieve the goal: build LNMP environment.
Installing dependent libraries and development environments
#Dependencies and development tools
yum -y install gcc gcc-c ++ autoconf 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 e2fspro e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers
#Nginx
yum -y install pcre-devel zlib-devel
#Php
yum -y install gd-devel libjpeg-devel libpng-devel freetype-devel libxml2-devel curl-devel freetype-devel
#Mysql
yum -y install bison gcc gcc-c ++ autoconf automake zlib * libxml * ncurses-devel libtool-ltdl-devel * mysql-devel
Download package
#Create a directory
Mkdir / web
Cd / web
# PHP5.3.7
wget http://cn.php.net/distributions/php-5.3.8.tar.bz2
#PHP library files
wget http://ncu.dl.sourceforge.net/project/mcrypt/MCrypt/2.6.8/mcrypt-2.6.8.tar.gz
wget http://ncu.dl.sourceforge.net/project/mhash/mhash/0.9.9.9/mhash-0.9.9.9.tar.gz
wget http://ncu.dl.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz
wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
# Nginx1.0.9
wget http://www.nginx.org/download/nginx-1.0.9.tar.gz
#Nginx (Pcre)
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.13.tar.gz
# Mysql5.5.17
wget http://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.17.tar.gz/from/http://mysql.ntu.edu.tw/
#Mysql (CMake)
wget http://www.cmake.org/files/v2.8/cmake-2.8.6.tar.gz
Install MySQL
#Install cmake
TAR-ZXVF cmake-2.8.6.tar.gz
CD cmake-2.8.6 /
./configure
Gmake && gmake install && CD. /
#Add mysql user
/ usr / sbin / groupadd MySQL
/ usr / sbin / useradd-g MySQL MySQL
Mkdir-p / data / mysql
Chown-r Mysql: mysql / data / mysql
#Install Mysql
TAR-ZXVF mysql-5.5.17.tar.gz
CD mysql-5.5.17
CMake. -Dcmake_install_prefix = / usr / local / mysql-dmysql_datadir = / data / mysql-dsysconfdir = / etc /
Make && make install
#Set Mysql
There are five configuration information files in the #in support-files directory:
# my-small.cnf (Memory <= 64m)
# my-medium.cnf (Memory 128M)
# my-large.cnf (Memory 512M)
# my-huge.cnf (Memory 1g-2g)
# my-innodb-heavy-4g.cnf (Memory 4GB)
Cd / usr / local / mysql
CP./SUPPORT-FILES/MY-MEDIUM.CNF/ETC/MY.CNF
Vi / etc / my.cnf
#In [MYSQLD] segment increased
DataDir = / data / mysql
Wait-timeout = 30
Max_connections = 512
Default-storage-engine = MyISAM
#In [MYSQLD] paragraph modification
Max_allowed_packet = 16M
#Generate authorization form
Cd / usr / local / mysql
./scripts/mysql_install_db--user=mysql
#change the password
/ usr / local / mysql / bin / mysqladmin-u Root Password 123456
#Enable mysql
/ usr / local / mysql / bin / mysqld_safe &
#Test connection mysql
/ usr / local / mysql / bin / mysql-u root-p 123456
show databases;
Exit
#Set up boot
Vi / etc / rc.d / rc.local
#Join
/usr/local/mysql/bin/mysqld_safe &
Install PHP
#1
TAR-ZXVF libiconv-1.14.tar.gz && CD libiconv-1.14/
./configure--prefix=/usr/local
Make && make install && CD. /
#2
TAR-ZXVF libmcrypt-2.5.8.tar.gz && CD libmcrypt-2.5.8/
./configure && make && make install
/sbin/ldconfig && cd libltdl/&&./configure--enable-ltdl-install
Make && make install && CD. /
#3
TAR-ZXVF mhash-0.9.9.9.tar.gz && cd mhash-0.9.9.9/&&./configure
Make && make install && CD. /
#4
Ln-s/usr/local/lib/libmcrypt.la/usr/lib/libmcrypt.la
Ln-s/usr/local/lib/libmcrypt.so/usr/lib/libmcrypt.so
Ln-s/usr/local/lib/libmcrypt.so.4/usr/lib/libmcrypt.so.4
Ln-s/usr/local/lib/libmcrypt.so.4.4.8/usr/lib/libmcrypt.so.4.4.8
Ln-s/USR/LOCAL/LIB/LIBMHASH.A/USR/LIB/LIBMHASH.A
Ln-s/usr/local/lib/libmhash.la/usr/lib/libmhash.la
Ln-s/usr/local/lib/libmhash.so/usr/lib/libmhash.so
Ln-s/usr/local/lib/libmhash.so.2/usr/lib/libmhash.so.2
Ln-s/usr/local/lib/libmhash.so.2.0.1/usr/lib/libmhash.so.2.0.1
Ln-s/usr/local/bin/libmcrypt-config/usr/bin/libmcrypt-config
#5
TAR-ZXVF mcrypt-2.6.8.tar.gz &&CD mcrypt-2.6.8/
/sbin/ldconfig
./configure
Make && make install && CD. /
#6
TAR-XJVF php-5.3.8.tar.bz2
CD php-5.3.8
./configure--prefix=/usr/local/php \
--WITH-CONFIG-FILE-PATH=/USR/LOCAL/PHP/ETC \
--with-iconv-dir=/usr/local/--with-freetype-dir \
--with-mysql=/usr/local/mysql \
--with-mysqli=/usr/local/mysql/bin/mysql_config \
--with-jpeg-dir--with-png-dir--with-zlib \
--with-mhash--enable-sockets--enable-ftp \
--with-libxml-dir--enable-xml--disable-rpath \
--enable-safe-mode--enable-bcmath \
--enable-shmop--enable-sysvsem \
--enable-inline-optimization--with-curl \
--with-curlwrappers \
--enable-mbregex \
--enable-mbstring--with-mcrypt--with-gd \
--enable-gd-native-ttf--with-openssl--with-mhash \
--enable-pcntl--enable-sockets--with-ldap--WITH-LDAP-SASL \
--ENABLE-FPM \
--with-xmlrpc--enable-zip--enable-soap \
--without-pear \
Make zend_extra_libs= '-liconv '
#Note here is prone to Make: * * [ext / phar / phar.php] Error 127
#Appear mysql Client Solutions
# ln-S / usr / local / mysql / lib / libmysqlclient.so / usr / lib /
# ln-S / usr / local / mysql / lib / libmysqlclient.so.18 / usr / lib / libmysqlclient.so.18
#Or chmod: Unable to access "Ext / phar / phar.phar": No file or directory
#make: [Ext / phar / phar.phar] Error 1 (ignored)
#Workaround Add --without-pear Parameters when compiling
#If not yet, make does not add zend_extra_libs = '-liconv' arguments
Make install
#Select PHP. Ini configuration file
CP Php.ini-production/usr/local/php/etc/php.ini
Change PHP-FPM
#Add WWW user
/ usr / sbin / groupadd www && / usr / sbin / useradd-g www www
Mkdir-p / var / log / nginx && chmod + w / var / log / nginx && chown-r Www: www / var / log / nginx
Mkdir-p / data / www && chmod + w / data / www && chown-r www: www / data / www
Cp / usr / local / php / etc / php-fpm.conf.default / usr / local / php / etc / php-fpm.conf
Vi / usr / local / php / etc / php-fpm.conf
# Remove / Change the configuration file;
Pm.start_servers = 20
Pm.min_spare_servers = 5
Pm.max_spare_servers = 35
Pm.max_requests = 1024
user = www
Group = www
#Check if the syntax is correct
/ usr / local / php / sbin / php-fpm-t
#Appears NOTICE: Configuration file / usr / local / php / etc / php-fpm.conf test is successful tested successfully
/ USR / LOCAL / PHP / SBIN / PHP-FPM &
#Set up boot
Vi / etc / rc.d / rc.local
#Join at the end of the line
/ USR / LOCAL / PHP / SBIN / PHP-FPM &
#Return to the installation package directory
Cd/web
Installing Nginx
#Install the pcre library
TAR-ZXVF pcre-8.13.tar.gz && cd pcre-8.13 /&&./ configure
Make && make install && CD. /
#Install Nginx
TAR-ZXVF nginx-1.0.9.tar.gz && CD nginx-1.0.9 &&
./configure--user=www--group=www \
--prefix = / usr / local / nginx \
--sbin-path = / usr / local / nginx / sbin / nginx \
--conf-path = / usr / local / nginx / conf / nginx.conf \
--with-http_stub_status_module \
--with-http_ssl_module \
--with-pcre \
--lock-path = / var / run / nginx.lock \
--pid-path = / var / run / nginx.pid
Make && make install && CD. /
#Change configuration
Vi / usr / local / nginx / conf / nginx.conf
#Modify some parameters, don't replace the file directly, it's only part
User www
Events {
Use Epoll;
Worker_connections 1024;
}
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;
}
#Note here # $ document _root $ fastcgi_script_name;
#Detect configuration files
/ usr / local / nginx / sbin / nginx-t
#Prompt indicates success
#nginx: The configuration file / usr / local / nginx / conf / nginx.conf syntax is OK
#nginx: Configuration file / usr / local / nginx / conf / nginx.conf test is successful
#Enable Nginx
/ usr / local / nginx / sbin / nginx &
#Smooth restart Nginx
/ usr / local / nginx / sbin / nginx-s Reload
#Add boot up
Vi / etc / rc.d / rc.local
#Finally added
/ usr / local / nginx / sbin / nginx
#test
cd/usr/local/nginx/html/
Touch index.php
vi/usr/local/nginx/html/index.php
<?php
Phpinfo ();
Allow anyone to reprint, help more people, solve the problems encountered:
Original link Address: http://www.cnblogs.com/wubaiqing/archive/2011/11/08/2241195.html
CentOS Build php5.3.8+nginx1.0.9+mysql5.5.17