Operating Environment
Operating System: Mac OS Lion
VM: VMware Fusion
Virtual System: Centos 5.5 +
Operation User: Root
Objective: To build an LNMP environment.
Install dependency libraries and development environments
Copy codeThe Code is as follows: yum-y install gcc-c ++ autoconf libjpeg-devel libpng-devel freetype-devel libxml2 libxml2-devel zlib-devel glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses- devel curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn-devel openssl-devel 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-c ++ autoconf automake zlib * libxml * ncurses-devel libtool-ltdl-devel * mysql-devel
Download Software Package
Copy codeThe Code is as follows: # 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
Copy codeThe Code is as follows: # Install cmake
Tar-zxvf cmake-2.8.6.tar.gz
Cd cmake-2.8.6/
./Configure
Gmake & gmake install & cd ../
# Add a mysql user
/Usr/sbin/groupadd mysql
/Usr/sbin/useradd-g 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
# Setting Mysql
# The support-files directory contains five configuration files:
# My-small.cnf (memory <= 64 M)
# My-medium.cnf (memory 128 M)
# My-large.cnf (memory 512 M)
# My-huge.cnf (memory 1G-2G)
# My-innodb-heavy-4G.cnf (memory 4 GB)
Cd/usr/local/mysql
Cp./support-files/my-medium.cnf/etc/my. cnf
Vi/etc/my. cnf
# Add in [mysqld]
Datadir =/data/mysql
Wait-timeout = 30
Max_connections = 512
Default-storage-engine = MyISAM
# Modify in the [mysqld] Section
Max_allowed_packet = 16 M
# Generating an authorization table
Cd/usr/local/mysql
./Scripts/mysql_install_db -- user = mysql
# Change Password
/Usr/local/mysql/bin/mysqladmin-u root password 123456
# Enable mysql
/Usr/local/mysql/bin/mysqld_safe &
# Test connection to mysql
/Usr/local/mysql/bin/mysql-u root-p 123456
Show databases;
Exit;
# Set startup
Vi/etc/rc. d/rc. local
# Join
/Usr/local/mysql/bin/mysqld_safe &
Install PHP Copy codeThe Code is as follows: #1
Tar-zxvf libiconv-1.14.tar.gz & libiconv-1.14/cd/
./Configure -- prefix =/usr/local
Make & make install & cd ../
#2
Tar-zxvf libmcrypt-2.5.8.tar.gz & libmcrypt-2.5.8/cd/
./Configure & 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.
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 & mcrypt-2.6.8/cd/
/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-sasl \
-- Enable-fpm \
-- With-xmlrpc -- enable-zip -- enable-soap \
-- Without-pear \
Make ZEND_EXTRA_LIBS = '-liconv'
# Note that make: *** [ext/phar. php] Error 127 may occur.
# Mysql client Solution
# 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": No file or directory
# Make: [ext/phar. phar] Error 1 (ignore)
# Solution: add the -- without-pear parameter during compilation.
# If not, do not add the ZEND_EXTRA_LIBS = '-liconv' parameter to make.
Make install
# Select the PHP. ini configuration file
Cp php. ini-production/usr/local/php/etc/php. ini
Change PHP-FPMCopy codeThe Code is as follows: # Add a WWW user
/Usr/sbin/groupadd www &/usr/sbin/useradd-g 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
6/usr/local/php/etc/php-fpm.conf
# Remove/modify the configuration file;
Pm. max_children = 64
Pm. start_servers = 20
Pm. min_spare_servers = 5
Pm. max_spare_servers = 35
Pm. max_requests = 1024
User = www
Group = www
# Check whether the syntax is correct
/Usr/local/php/sbin/php-fpm-t
# NOTICE: configuration file/usr/local/php/etc/php-fpm.conf test is successful test successful
/Usr/local/php/sbin/php-fpm &
# Set startup
Vi/etc/rc. d/rc. local
# Add at the end of a row
/Usr/local/php/sbin/php-fpm &
# Return to the installation package directory
Cd/web
Install NginxCopy codeThe Code is as follows: # 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. do not replace the file directly. This is only part of it.
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:
# $ Document_root $ fastcgi_script_name; # Check the configuration file
/Usr/local/nginx/sbin/nginx-t
# The prompt indicates that the operation is successful.
# 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 # restart Nginx smoothly
/Usr/local/nginx/sbin/nginx-s reload
# Add boot start
Vi/etc/rc. d/rc. local
# Final transfer
/Usr/local/nginx/sbin/nginx
# Test
Cd/usr/local/nginx/html/
Touch index. php
Vi/usr/local/nginx/html/index. php
<? Php
Phpinfo ();
?>
Author: Wu Xiaoqing