Description
 
Operating System: CentOS 5.10 64-bit
 
Prepare the article:
 
First, configure the IP, DNS, gateway, ensure that the remote connection tool can connect the server, the server time is set correctly
 
 
Second, configure the firewall, open 80 ports, 3306 ports
 
Vi/etc/sysconfig/iptables #编辑
 
-A rh-firewall-1-input-m state--state new-m tcp-p TCP--dport 80-j ACCEPT #允许80端口通过防火墙
 
-A rh-firewall-1-input-m state--state new-m tcp-p TCP--dport 3306-j ACCEPT #允许3306端口通过防火墙
 
Special Note: If these two rules are added to the last line of the firewall configuration, the firewall startup fails, the correct one should be added to the default 22 port under this rule, after you have added the firewall rules as follows:
 
#########################################################
 
# Firewall configuration written by System-config-securitylevel
 
# Manual Customization of this file is not recommended.
 
*filter
 
: INPUT ACCEPT [0:0]
 
: FORWARD ACCEPT [0:0]
 
: OUTPUT ACCEPT [0:0]
 
: Rh-firewall-1-input-[0:0]
 
-A input-j Rh-firewall-1-input
 
-A forward-j Rh-firewall-1-input
 
-A rh-firewall-1-input-i lo-j ACCEPT
 
-A rh-firewall-1-input-p ICMP--icmp-type any-j ACCEPT
 
-A rh-firewall-1-input-p 50-j ACCEPT
 
-A rh-firewall-1-input-p 51-j ACCEPT
 
-A rh-firewall-1-input-p UDP--dport 5353-d 224.0.0.251-j ACCEPT
 
-A rh-firewall-1-input-p udp-m UDP--dport 631-j ACCEPT
 
-A rh-firewall-1-input-p tcp-m tcp--dport 631-j ACCEPT
 
-A rh-firewall-1-input-m state--state established,related-j ACCEPT
 
-A rh-firewall-1-input-m state--state new-m tcp-p TCP--dport 22-j ACCEPT
 
-A rh-firewall-1-input-m state--state new-m tcp-p TCP--dport 80-j ACCEPT
 
-A rh-firewall-1-input-m state--state new-m tcp-p TCP--dport 3306-j ACCEPT
 
-A rh-firewall-1-input-j REJECT--reject-with icmp-host-prohibited
 
COMMIT
 
#########################################################
 
/etc/init.d/iptables Restart #最后重启防火墙使配置生效
 
Third, close SELinux
 
Vi/etc/selinux/config
 
#SELINUX =enforcing #注释掉
 
#SELINUXTYPE =targeted #注释掉
 
selinux=disabled #增加
 
: wq! #保存退出
 
Setenforce 0 #使配置立即生效
 
Iv. System Agreement
 
Software source code Package storage location:/USR/LOCAL/SRC
 
Source Package Compile Installation location:/usr/local/software name + version number
 
Add Soft connection: ln-s/usr/local/software name + version number/usr/local/software name
 
V. Download packages
 
1, download Nginx(currently stable version)
 
Http://nginx.org/download/nginx-1.4.4.tar.gz
 
2, download Pcre (support nginx pseudo static)
 
Ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.34.tar.gz
 
3, download MySQL
 
Http://cdn.mysql.com/Downloads/MySQL-5.5/mysql-5.5.35.tar.gz
 
4, download PHP
 
Http://cn2.php.net/distributions/php-5.3.28.tar.gz
 
5, download CMake(MySQL compiler Tool)
 
Http://www.cmake.org/files/v2.8/cmake-2.8.12.1.tar.gz
 
6, download Libmcrypt(phplibmcrypt module)
 
Http://nchc.dl.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz
 
7, download the GD Library installation package (PHP page image Verification code support)
 
Https://phpsqq.googlecode.com/files/gd-2.0.36RC1.tar.gz
 
8. Download Zend Guard (accelerate php execution efficiency)
 
Http://downloads.zend.com/guard/5.5.0/ZendGuardLoader-php-5.3-linux-glibc23-x86_64.tar.gz #64位
 
9. Download Eaccelerator(accelerate php execution efficiency)
 
http://acelnmp.googlecode.com/files/eaccelerator-0.9.6.1.tar.bz2
 
upload the above packages to /usr/local/src Directory
 
VI. installation of compilation tools and library files (installed using CentOS yum command)
 
Yum install-y make apr* autoconf automake Curl curl-devel gcc gcc-c++ gtk+-devel zlib-devel OpenSSL openssl-devel Vel gd kernel keyutils patch perl kernel-headers compat* cpp glibc libgomp libstdc++-devel keyutils-libs-devel libsepol-d Evel Libselinux-devel krb5-devel libxpm* freetype freetype-devel freetype* fontconfig fontconfig-devel libjpeg* libpng* Php-common php-gd gettext gettext-devel ncurses* libtool* libxml2 libxml2-devel patch Policycoreutils Bison
 
Installation article
 
The following is an SSH telnet to the server, operating below the command line
 
I. Installation of CMake
 
Cd/usr/local/src
 
Tar zxvf cmake-2.8.12.1.tar.gz
 
CD cmake-2.8.12.1
 
./configure
 
Make #编译
 
Make install #安装
 
Second, the installation of MySQL
 
Groupadd MySQL #添加mysql组
 
useradd-g MySQL mysql-s/bin/false #创建用户mysql并加入到mysql组, MySQL users are not allowed to log on directly to the system
 
Mkdir-p/data/mysql #创建MySQL数据库存放目录
 
Chown-r mysql:mysql/data/mysql #设置MySQL数据库目录权限
 
Mkdir-p/usr/local/mysql-5.5.35 #创建MySQL安装目录
 
Ln-s/usr/local/mysql-5.5.35/usr/local/mysql #创建软连接到mysql目录, convenient for later configuration
 
Cd/usr/local/src
 
Tar zxvf mysql-5.5.35.tar.gz #解压
 
CD mysql-5.5.35
 
CMake. -dcmake_install_prefix=/usr/local/mysql-dmysql_datadir=/data/mysql-dsysconfdir=/etc #配置
 
Make #编译
 
Make install #安装
 
Cd/usr/local/mysql
 
CP./SUPPORT-FILES/MY-HUGE.CNF/ETC/MY.CNF #拷贝配置文件(Note: If the/etc directory has a my.cnf under the default, direct coverage can be) 
 
VI/ETC/MY.CNF #编辑配置文件, added in [mysqld] section
 
DataDir =/data/mysql #添加MySQL数据库路径
 
./scripts/mysql_install_db--user=mysql #生成mysql系统数据库
 
CP./SUPPORT-FILES/MYSQL.SERVER/ETC/RC.D/INIT.D/MYSQLD #把Mysql加入系统启动
 
chmod 755/etc/init.d/mysqld #增加执行权限
 
Chkconfig mysqld on #加入开机启动
 
Vi/etc/rc.d/init.d/mysqld #编辑
 
Basedir =/usr/local/mysql #MySQL程序安装路径
 
DataDir =/data/mysql #MySQl数据库存放目录
 
Service mysqld start #启动
 
Vi/etc/profile #把mysql服务加入系统环境变量: Add the following line at the end
 
Export path= $PATH:/usr/local/mysql/bin
 
Source/etc/profile #使配置立即生效
 
The following two lines link the MYSLQ library file to the default location of the system, so that you can compile software such as PHP without specifying MySQL's library file address.
 
Ln-s/usr/local/mysql/lib/mysql/usr/lib/mysql
 
Ln-s/usr/local/mysql/include/mysql/usr/include/mysql
 
Mkdir/var/lib/mysql #创建目录
 
Ln-s/tmp/mysql.sock/var/lib/mysql/mysql.sock #添加软链接
 
Mysql_secure_installation #设置Mysql密码, enter 2 times password according to the prompts Y return
 
/usr/local/mysql/bin/mysqladmin-u root-p Password "123456" #或者直接修改密码
 
To this end, MySQL installation is complete!
 
Iii. installation of Pcre
 
Cd/usr/local/src
 
Mkdir/usr/local/pcre #创建安装目录
 
Tar zxvf pcre-8.34.tar.gz
 
CD pcre-8.34
 
./configure--prefix=/usr/local/pcre #配置
 
Make
 
Make install
 
System Yun-wei Www.111cn.net warm reminder: qihang01 original content copyright, reproduced please indicate the source and the original link
 
Iv. installation of Nginx
 
Cd/usr/local/src
 
Groupadd www #添加www组
 
Useradd-g www www-s/bin/false #创建nginx运行账户www并加入到www组, www users are not allowed to log on directly to the system
 
Mkdir-p/usr/local/nginx-1.4.4 #创建nginx安装目录
 
Ln-s/usr/local/nginx-1.4.4/usr/local/nginx #创建软连接到nginx
 
Tar zxvf nginx-1.4.4.tar.gz
 
CD nginx-1.4.4
 
./configure--prefix=/usr/local/nginx--without-http_memcached_module--user=www--group=www--with-http_stub_ Status_module--with-openssl=/usr/--with-pcre=/usr/local/src/pcre-8.34
 
Note:--with-pcre=/usr/local/src/pcre-8.34 points to the source package decompression path, not the installation path, otherwise it will be an error
 
Make
 
Make install
 
/usr/local/nginx/sbin/nginx #启动nginx
 
Set Nginx to open boot
 
Vi/etc/rc.d/init.d/nginx #编辑启动文件添加下面内容
 
=======================================================
 
#!/bin/sh
 
#
 
# Nginx-this script starts and stops the Nginx daemon
 
#
 
# Chkconfig:-85 15
 
# Description:nginx is a HTTP (s) server, HTTP (s) reverse
 
# Proxy and IMAP/POP3 proxy server
 
# Processname:nginx
 
# config:/etc/nginx/nginx.conf
 
# config:/usr/local/nginx/conf/nginx.conf
 
# Pidfile:/usr/local/nginx/logs/nginx.pid
 
# Source function library.
 
. /etc/rc.d/init.d/functions
 
# Source Networking configuration.
 
. /etc/sysconfig/network
 
# Check that networking are up.
 
["$NETWORKING" = "no"] && exit 0
 
nginx= "/usr/local/nginx/sbin/nginx"
 
prog=$ (basename $nginx)
 
Nginx_conf_file= "/usr/local/nginx/conf/nginx.conf"
 
[-f/etc/sysconfig/nginx] &&. /etc/sysconfig/nginx
 
Lockfile=/var/lock/subsys/nginx
 
Make_dirs () {
 
# Make required Directories
 
User= ' $nginx-v 2>&1 | grep "Configure arguments:" | Sed ' s/[^*]*--user= ([^]*). */1/g '-'
 
If [-Z "' grep $user/etc/passwd ']"; Then
 
Useradd-m-s/bin/nologin $user
 
Fi
 
Options= ' $nginx-v 2>&1 | grep ' Configure arguments: '
 
for opt in $options; Todo
 
If [' Echo $opt | grep '. *-temp-path ']; Then
 
Value= ' echo $opt | Cut-d "=" F 2 '
 
if [!-D "$value"]; Then
 
# echo "Creating" $value
 
Mkdir-p $value && chown-r $user $value
 
Fi
 
Fi
 
Done
 
}
 
Start () {
 
[x $nginx] | | Exit 5
 
[f $NGINX _conf_file] | | Exit 6
 
Make_dirs
 
Echo-n $ "Starting $prog:"
 
Daemon $nginx-C $NGINX _conf_file
 
Retval=$?
 
Echo
 
[$retval-eq 0] && Touch $lockfile
 
Return $retval
 
}
 
Stop () {
 
Echo-n $ "Stopping $prog:"
 
Killproc $prog-quit
 
Retval=$?
 
Echo
 
[$retval-eq 0] && rm-f $lockfile
 
Return $retval
 
}
 
Restart () {
 
#configtest | | Return $?
 
Stop
 
Sleep 1
 
Start
 
}
 
Reload () {
 
#configtest | | Return $?
 
Echo-n $ "Reloading $prog:"
 
Killproc $nginx-hup
 
Retval=$?
 
Echo
 
}
 
Force_reload () {
 
Restart
 
}
 
Configtest () {
 
$nginx-T-C $NGINX _conf_file
 
}
 
Rh_status () {
 
Status $prog
 
}
 
Rh_status_q () {
 
Rh_status >/dev/null 2>&1
 
}
 
Case "$" in
 
Start
 
Rh_status_q && Exit 0
 
$
 
;;
 
Stop
 
Rh_status_q | | Exit 0
 
$
 
;;
 
Restart|configtest)
 
$
 
;;
 
Reload
 
Rh_status_q | | Exit 7
 
$
 
;;
 
Force-reload)
 
Force_reload
 
;;
 
Status
 
Rh_status
 
;;
 
Condrestart|try-restart)
 
Rh_status_q | | Exit 0
 
;;
 
*)
 
echo $ "Usage: $ {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
 
Exit 2
 
Esac
 
=======================================================
 
: wq! #保存退出
 
chmod 775/etc/rc.d/init.d/nginx #赋予文件执行权限
 
Chkconfig nginx on #设置开机启动
 
/etc/rc.d/init.d/nginx Restart #重新启动Nginx
 
Service Nginx Restart
 
=======================================================
 
V. Installation of Libmcrypt
 
Cd/usr/local/src
 
Tar zxvf libmcrypt-2.5.8.tar.gz #解压
 
CD libmcrypt-2.5.8 #进入目录
 
./configure #配置
 
Make #编译
 
Make install #安装
 
VI. Installation of GD library
 
Cd/usr/local/src
 
Tar zxvf gd-2.0.36rc1.tar.gz
 
CD GD-2.0.36RC1
 
./configure--enable-m4_pattern_allow--prefix=/usr/local/gd--with-jpeg=/usr/lib--with-png=/usr/lib--with-xpm=/ Usr/lib--with-freetype=/usr/lib--with-fontconfig=/usr/lib #配置
 
Make #编译
 
Make install #安装
 
Seven, install PHP
 
Cd/usr/local/src
 
TAR-ZVXF php-5.3.28.tar.gz
 
CD php-5.3.28
 
Mkdir-p/usr/local/php-5.3.28 #建立php安装目录
 
Ln-s/usr/local/php-5.3.28/usr/local/php #创建软连接
 
./configure--prefix=/usr/local/php--with-config-file-path=/usr/local/php/etc--with-mysql=/usr/local/mysql-- With-mysqli=/usr/local/mysql/bin/mysql_config--with-mysql-sock=/tmp/mysql.sock--with-pdo-mysql=/usr/local/ MySQL--with-gd=/usr/local/gd--with-png-dir=/usr/lib--with-jpeg-dir=/usr/lib--with-freetype-dir=/usr/lib-- With-iconv--with-zlib--enable-xml--enable-magic-quotes--enable-safe-mode--enable-bcmath-- Enable-sysvsem--enable-inline-optimization--with-curlwrappers--enable-mbregex--enable-fpm--enable-mbstring-- Enable-ftp--enable-gd-native-ttf--with-openssl--enable-pcntl--enable-sockets--with-xmlrpc-- Enable-soap--without-pear--with-gettext--enable-session--with-mcrypt--with-curl--enable-ctype #配置
 
Make #编译
 
Make install #安装
 
CP Php.ini-production/usr/local/php/etc/php.ini #复制php配置文件到安装目录
 
Rm-rf/etc/php.ini #删除系统自带配置文件
 
Ln-s/usr/local/php/etc/php.ini/etc/php.ini #添加软链接
 
cp/usr/local/php/etc/php-fpm.conf.default/usr/local/php/etc/php-fpm.conf # Copy template file for php-fpm configuration file
 
vi/usr/local/php/etc/php-fpm.conf #编辑
 
user = www #设置php-fpm running account is www 
 
Group = www #设置php-fpm run Group is www 
 
PID = run/php-fpm.pid #取消前面的分号
 
Set PHP-FPM boot
 
CP/USR/LOCAL/SRC/PHP-5.3.28/SAPI/FPM/INIT.D.PHP-FPM/ETC/RC.D/INIT.D/PHP-FPM #拷贝php-fpm to startup directory
 
chmod +x/etc/rc.d/init.d/php-fpm #添加执行权限
 
Chkconfig php-fpm on #设置开机启动
 
Vi/usr/local/php/etc/php.ini #编辑配置文件
 
find:disable_functions =
 
modified to:disable_functions = passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_ Status,ini_alter,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server, Escapeshellcmd,dll,popen,disk_free_space,checkdnsrr,checkdnsrr,getservbyname,getservbyport,disk_total_space, POSIX_CTERMID,POSIX_GET_LAST_ERROR,POSIX_GETCWD, Posix_getegid,posix_geteuid,posix_getgid, Posix_getgrgid,posix_ Getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid, Posix_getppid,posix_getpwnam, Posix_getpwuid, Posix_getrlimit, Posix_getsid,posix_getuid,posix_isatty, Posix_kill,posix_mkfifo,posix_setegid, Posix_seteuid,posix_setgid, Posix_setpgid,posix_setsid,posix_setuid,posix_strerror,posix_times,posix_ttyname, Posix_uname
 
#列出PHP可以disabled function, if some programs need to use this function, you can delete, cancel disable
 
find:;d ate.timezone =
 
modified as:Date.timezone = PRC #设置时区
 
find:expose_php = On
 
modified to:expose_php = off #禁止显示php版本的信息
 
find:Short_open_tag = Off
 
modified to:Short_open_tag = on #支持php短标签
 
System Yun-wei Www.111cn.net warm reminder: qihang01 original content copyright, reproduced please indicate the source and the original link
 
Eight, configure Nginx support PHP
 
Vi/usr/local/nginx/conf/nginx.conf
 
Modifying the/usr/local/nginx/conf/nginx.conf configuration file requires the following modifications
 
User www www. #首行user去掉注释, modify Nginx running group is www www; must be with User,group in /usr/local/php/etc/php-fpm.conf  configuration is the same, otherwise PHP runs wrong
 
Index index.php index.html index.htm; #添加index. PHP
 
# 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;
 
}
 
#取消FastCGI the comments in the Location Server section, note the arguments for the Fastcgi_param row, change to $document _root$fastcgi_script_name, or use an absolute path
 
/etc/init.d/nginx Restart #重启nginx
 
Nine, configure PHP support Zend Guard
 
Install Zend Guard
 
Cd/usr/local/src
 
Mkdir/usr/local/zend #创建安装目录
 
Tar xvfz zendguardloader-php-5.3-linux-glibc23-x86_64.tar.gz #解压
 
CP zendguardloader-php-5.3-linux-glibc23-x86_64/php-5.3.x/zendguardloader.so/usr/local/zend/ #拷贝文件到安装目录
 
Vi/usr/local/php/etc/php.ini #编辑文件
 
Add the following at the last location
 
[Zend Guard]
 
Zend_extension=/usr/local/zend/zendguardloader.so
 
Zend_loader.enable=1
 
Zend_loader.disable_licensing=0
 
Zend_loader.obfuscation_level_support=3
 
Zend_loader.license_path=
 
X. Installation eaccelerator accelerate PHP execution efficiency
 
CD/USR/LOCAL/SRC #进入软件包存放目录
 
Tar xjf eaccelerator-0.9.6.1.tar.bz2 #解压
 
CD eaccelerator-0.9.6.1 #进入安装目录
 
/usr/local/php/bin/phpize #用phpize生成configure配置文件
 
./configure-enable-eaccelerator=shared--with-php-config=/usr/local/php/bin/php-config #配置
 
Make #编译
 
Make install #安装
 
After the installation is complete, remember the following path, which will be used later
 
/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/ #eaccelerator模块路径
 
Mkdir/tmp/eaccelerator #创建目录
 
chmod 777/tmp/eaccelerator #设置目录权限为完全控制
 
Vi/usr/local/php/etc/php.ini #编辑配置文件, add the following before the Zendguardloader configuration section
 
[Eaccelerator]
 
zend_extension= "/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/eaccelerator.so"
 
Eaccelerator.cache_dir= "/tmp/eaccelerator"
 
Eaccelerator.shm_size= "8"
 
eaccelerator.enable= "1"
 
Eaccelerator.optimizer= "1"
 
Eaccelerator.check_mtime= "1"
 
eaccelerator.debug= "0"
 
Eaccelerator.filter= ""
 
eaccelerator.shm_max= "0"
 
Eaccelerator.shm_ttl= "3600"
 
eaccelerator.shm_prune_period= "3600"
 
eaccelerator.shm_only= "0"
 
eaccelerator.compress= "1"
 
Eaccelerator.compress_level= "9"
 
Eaccelerator.keys = "Disk_only"
 
Eaccelerator.sessions = "Disk_only"
 
Eaccelerator.content = "Disk_only"
 
Note: If configuration information such as Zendguardloader is already available in the configuration file, in order to avoid conflicts, the above configuration information needs to be written before the Zendguardloader configuration
 
Test article
 
cd/usr/local/nginx/html/ #进入nginx默认网站根目录
 
rm-rf/usr/local/nginx/html/* #删除默认测试页
 
VI index.php #新建index. php file
 
<?php
 
Phpinfo ();
 
?>
 
: wq! #保存退出
 
Chown www.www/usr/local/nginx/html/-R #设置目录所有者
 
chmod 700/usr/local/nginx/html/-R #设置目录权限
 
Open the server IP address in the browser and see the following interface
 
 
thus far, CentOS 5.x -bit installation Lnmp Basic Environment completed. 
 
Server-related Operations command
 
Service nginx Restart #重启nginx
 
Service mysqld Restart #重启mysql
 
/USR/LOCAL/PHP/SBIN/PHP-FPM #启动php-fpm
 
/ETC/RC.D/INIT.D/PHP-FPM Restart #重启php-fpm
 
/ETC/RC.D/INIT.D/PHP-FPM Stop #停止php-fpm
 
/ETC/RC.D/INIT.D/PHP-FPM start #启动php-fpm
 
#####################################################################
 
Note:
 
Nginx Default Site Directory is:/usr/local/nginx/html/
 
Permission settings: Chown www.www/usr/local/nginx/html/-R
 
MySQL database directory is:/data/mysql
 
Permission settings: Chown mysql.mysql-r/data/mysql