Operating Environment
Operating system: Mac OS Lion
Virtual Host: VMware Fusion
Virtual system: Centos 5.5+
Action User: Root
To achieve the goal: to build LNMP environment.
Installing dependent libraries and development environments
Copy Code code as follows:
Yum-y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-deve L zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel Curl curl-devel e2fsprogs E2 Fsprogs-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 Packages
Copy Code code as follows:
#创建目录
Mkdir/web
Cd/web
#PHP5.3.7
wget http://cn.php.net/distributions/php-5.3.8.tar.bz2
#PHP库文件
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
installing MySQL
Copy Code code as follows:
#安装cmake
TAR-ZXVF cmake-2.8.6.tar.gz
CD cmake-2.8.6/
./configure
Gmake && gmake install && CD. /
#添加mysql用户
/usr/sbin/groupadd MySQL
/usr/sbin/useradd-g MySQL MySQL
Mkdir-p/data/mysql
Chown-r Mysql:mysql/data/mysql
#安装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
#设置Mysql
There are five configuration information files in the #在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
#在 [MYSQLD] paragraph increased
DataDir =/data/mysql
Wait-timeout = 30
Max_connections = 512
Default-storage-engine = MyISAM
#在 [MYSQLD] paragraph modification
Max_allowed_packet = 16M
#生成授权表
Cd/usr/local/mysql
./scripts/mysql_install_db--user=mysql
#更改密码
/usr/local/mysql/bin/mysqladmin-u Root Password 123456
#开启mysql
/usr/local/mysql/bin/mysqld_safe &
#测试连接mysql
/usr/local/mysql/bin/mysql-u root-p 123456
show databases;
Exit
#设置开机启动
Vi/etc/rc.d/rc.local
#加入
/usr/local/mysql/bin/mysqld_safe &
Installing PHP
Copy Code code as follows:
#1
TAR-ZXVF libiconv-1.14.tar.gz && CD libiconv-1.14/
./configure--prefix=/usr/local
Make && make install && CDs. /
#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 && CDs. /
#3
TAR-ZXVF mhash-0.9.9.9.tar.gz && cd mhash-0.9.9.9/&&/configure
Make && make install && CDs. /
#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 && CDs. /
#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 '
#注意这里容易出现 Make: * * * [ext/phar/phar.php] Error 127
#出现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
#或者chmod: Cannot Access "Ext/phar/phar.phar": No file or directory
#make: [Ext/phar/phar.phar] Error 1 (ignored)
#解决方法在编译的时候加--without-pear Parameters
#如果还不行, make does not add the zend_extra_libs= '-liconv ' parameter
Make install
#选择PHP. ini configuration file
CP Php.ini-production/usr/local/php/etc/php.ini
Change PHP-FPM
Copy code code as follows:
#添加WWW用户
/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.co nf.default/usr/local/php/etc/php-fpm.conf the
vi/usr/local/php/etc/php-fpm.conf
#去掉/Change the configuration file;
Pm.max_children = $
Pm.start_servers =
Pm.min_spare_servers = 5
pm.max_spare_servers = km
pm.max_requests = 1024
user = www
Group = www
#检查语法是否正确
/usr/local/php/sbin/php-fpm-t
#出现NOTICE: Configuration file/usr/local/php/etc/php-fpm.conf test is successful successful
/USR/LOCAL/PHP/SBIN/PHP-FPM &
#设置开机启动
vi/etc/rc.d/rc.local
#在行末加入
/usr/local/php/sbin/php-fpm &
#返回安装包目录
Cd/web
Install Nginx
Copy Code code as follows:
#安装pcre库
TAR-ZXVF pcre-8.13.tar.gz && cd pcre-8.13/&&/configure
Make && make install && CDs. /
#安装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 && CDs. /
#更改配置
Vi/usr/local/nginx/conf/nginx.conf
#修改一些参数, do not replace files directly, this is only part of
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;
}
#注意这里
# $document _root$fastcgi_script_name; #检测配置文件
/usr/local/nginx/sbin/nginx-t
#提示表示成功
#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
#开启Nginx
/usr/local/nginx/sbin/nginx# Smooth Restart Nginx
/usr/local/nginx/sbin/nginx-s Reload
#添加开机启动
Vi/etc/rc.d/rc.local
#最后移行加入
/usr/local/nginx/sbin/nginx
#测试
cd/usr/local/nginx/html/
Touch index.php
vi/usr/local/nginx/html/index.php
<?php
Phpinfo ();
?>
Author: Wu Bai Qing