First, minimize the installation of the system.
I. system conventions
Storage location of software source code package |
/Usr/local/src |
Source code package compilation and installation location (prefix) |
/Usr/local/software_name |
Script and maintenance program storage location |
/Usr/local/sbin |
MySQL database location |
/Var/lib/mysql (which can be set as needed) |
Nginx website root directory |
/Home/www/wwwroot (can be set as needed) |
Nginx virtual host log root directory |
/Home/www/logs (can be set as needed) |
Nginx Running Account |
Www: www |
Ii. System Environment Initialization
1. Check whether the system is normal
# More/var/log/messages (check for system-level error messages)
# Dmesg (check whether the hardware device has an error message)
# Cat/proc/cpuinfo (check whether the CPU frequency is normal)
# Top (check whether the number of CPU cores is normal and the memory size is normal by 1)
# Ifconfig (check whether Nic settings are correct)
# Ping www.163.com (check whether the network is normal)
2. disable unnecessary services
# Ntsysv
Only the services to be started are listed below. We recommend that you disable all services not listed:
Atd
Crond
Irqbalance
Microcode_ctl
Network
Sendmail
Sshd
Syslog
Disable SElinux: Modify selinux = to disabled in the/etc/SELINUX/config file.
3. Change the quick source
# Cd/etc/yum. repos. d/
# Mv CentOS-Base.repo CentOS-Base.repo.old
# Wget http://centos.ustc.edu.cn/CentOS-Base.repo.5
# Mv CentOS-Base.repo.5 CentOS-Base.repo
# Yum update
4. Use the yum program to install the required development kit (The following is the standard RPM package name)
# Yum-y install ntp make openssl-devel pcre-devel libpng-devel libjpeg-6b libjpeg-devel-6b freetype-devel gd-devel zlib-devel gcc-c ++ xlibpm libXpm-devel ncurses-devel libmcrypt-devel libxml2 libxml2-devel imake autoconf automake screen sysstat compat-libstdc ++-33 curl-devel
5. Timing correction server clock, timing synchronization with the Chinese National Time Service Center Time Service Server
# Crontab-e
Add a row:
*/30 * ntpdate 210.72.145.44>/dev/null 2> & 1
6. Download the package
Download the latest stable version from the official website of each program and store it in the/usr/local/src/directory.
Nginx
Current stable version 0.7.65http: // wiki.nginx.org/NginxChs
PHP
Current stable version 5.2.13http: // cn.php.net/releases/
Php fpm patch current stable version 0.5.14
Http://php-fpm.org/downloads/
Mysql
Current stable version 5.0.86http: // dev. mysql. coml/
Zend
Current stable version 3.3.3http: // www.zend.com/
Memcache
Current stable version 2.2.5http: // pecl.php.net/package/memcache/
Memcached
Current stable version 1.4.5
Http://memcached.googlecode.com
Libiconv
Current stable version 1.13.1
Http://www.gnu.org/software/libiconv/
Libevent
Current stable version 1.4.13
Http://www.monkey.org /~ Provos/libevent/
The configuration files and scripts in this article are limited by space. Please download them at the following address:
Nginx control script
Http://c.sihost.net/jb/nginx
Php fpm configuration file
Http://c.sihost.net/jb/php-fpm.conf
Nginx configuration file
Http://c.sihost.net/jb/nginx.conf
FCGI configuration file
Http://c.sihost.net/jb/fcgi.conf
Download list of the latest stable version of the program listed above
Http://c.sihost.net/Lnmp_tools.list
Run the following command in the/usr/local/src directory:
WgetHttp://c.sihost.net/Lnmp_tools.list
Wget-I lnmp_tools.list
7. Create a web running user
# Groupadd www
# Useradd-g www
# Mkdir-p/home/www/wwwroot
# Chmod + w/home/www/wwwroot
# Chown www: www/home/www/wwwroot-R
8. Restart
# Init 6
Iii. Compile and install the environment
1. Install MySQL
# Cd/usr/local/src
# Tar zxvf mysql-5.0.86-linux-i686-icc-glibc23.tar.gz
# Music mysql-5.0.86-linux-i686-icc-glibc23/usr/local/
# Ln-s/usr/local/mysql-5.0.86-linux-i686-icc-glibc23 // usr/local/mysql
# Groupadd mysql
# Useradd-g mysql-d/home/mysql-s/sbin/nologin
# Chown-R mysql: mysql/usr/local/mysql
# Chown-R mysql: mysql/usr/local/mysql-5.0.86-linux-i686-icc-glibc23/
# Cd/usr/local/mysql
#./Scripts/mysql_install_db -- user = mysql
# Cp./support-files/mysql. server/etc/rc. d/init. d/mysqld
# Chmod 755/etc/rc. d/init. d/mysqld
# Chkconfig -- add mysqld
# Chkconfig -- level 3 mysqld on
# Cp./support-files/my-huge.cnf/etc/my. cnf
# Mv/usr/local/mysql/data/var/lib/mysql
# Chown-R mysql: mysql/var/lib/mysql
Edit/etc/my. cnf
Add in [mysqld]
Datadir =/var/lib/mysql
Skip-innodb
Wait-timeout = 10
Max_connections = 512
Max_connect_errorrs = 10000000
Modify in the [mysqld] Section
Max_allowed_packet = 16 M
Thread_cache_size = number of CPUs * 2
Comment out log-bin
Service mysqld start
# Bin/mysqladmin-u root password
The red password indicates the root password to be set.
2. Compile and install Nginx
# Cd/usr/local/src/
# Tar zxvf nginx-0.7.65.tar.gz
# Cd nginx-0.7.65
#. /Configure -- prefix =/usr/local/nginx -- conf-path =/usr/local/nginx/conf/nginx. conf -- with-http_realip_module -- with-http_addition_module -- with-http_gzip_static_module -- with-http_random_index_module -- with-http_stub_status_module -- with-http_sub_module -- with-http_dav_module --
# Make
# Make install clean
# Cp/usr/local/src/nginx/etc/init. d/nginx
# Chmod 755/etc/init. d/nginx
# Chkconfig -- add nginx
# Chkconfig nginx on
3. Compile and install the supported libraries required by PHP
Libiconv
# Cd/usr/local/src/
# Tar zxvf libiconv-1.13.1.tar.gz
# Cd libiconv-1.13.1/
#./Configure -- prefix =/usr/local
# Make
# Make install
# Cd ..
Libmcrypt
# 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/usr/local/src/
Mhash
# Tar zxvf mhash-0.9.9.9.tar.gz
# Cd mhash-0.9.9.9/
#./Configure
# Make
# Make install
# Cd ..
# 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.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
# Tar zxvf mcrypt-2.6.8.tar.gz
# Cd mcrypt-2.6.8
#/Sbin/ldconfig
#./Configure
# Make
# Make install
4. Compile and install PHP
# Cd/usr/local/src
# Tar zxvf php-5.2.13.tar.gz
# Gzip-cd php-5.2.13-fpm-0.5.14.diff.gz | patch-d php-5.2.13-p1
# Cd php-5.2.13
#. /Configure -- prefix =/usr/local/php -- with-config-file-path =/usr/local/etc/cgi -- with-mysql =/usr/local/mysql -- with-mysqli =/usr/local/mysql/bin/mysql_config -- with-iconv-dir =/usr/local -- with-freetype-dir =/usr -- with-jpeg-dir =/usr -- with-png-dir =/usr -- with-zlib -- with-libxml-dir =/usr -- with-xmlrpc -- enable-xml -- enable-mbstring -- enable- ftp -- with-gd -- enable-magic-quotes -- with-pear -- enable-sockets -- with-ttf -- enable-gd-native-ttf -- enable-sysvsem -- enable-sysvshm -- enable-shmop -- enable-force-cgi-redirect -- enable-fastcgi -- enable-zip -- enable-fpm -- with-mhash -- with-mcrypt -- enable-discard-path -- enable- bcmath -- enable-inline-optimization -- with-curl -- with-curlwrappers -- enable-mbregex -- with-openssl
# Make ZEND_EXTRA_LIBS = '-liconv'
# Make install
# Mkdir-p/usr/local/etc/cgi/
# Cp php. ini-dist/usr/local/etc/cgi/php. ini
# Mv-f/usr/local/src/php-fpm.conf/usr/local/php/etc/php-fpm.conf
# Echo 'ulimit-SHn 65535 '>/etc/rc. local
# Echo '/usr/local/php/sbin/php-fpm start'>/etc/rc. local
5. Install the PHP extension module (this function is required for Discuz! X optional Users)
Memcache
# Cd/usr/local/src
# Tar zxvf memcache-2.2.5.tgz
# Cd memcache-2.2.5/
#/Usr/local/php/bin/phpize
#./Configure -- with-php-config =/usr/local/php/bin/php-config
# Make
# Make install
Modify the php. ini file, path:/usr/local/etc/cgi/
Search: extension_dir = "./"
Changed to: extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613 /"
Next line
Add: extension = "memcache. so"
Search: output_buffering = Off
Change to: output_buffering = On
Save.
Memcached
# Cd/usr/local/src
# Tar zxvf libevent-1.4.13-stable.tar.gz
# Cd libevent-1.4.13-stable
#./Configure -- prefix =/usr/lib
# Make
# Make install
# Cd ../
# Tar zxvf memcached-1.4.5.tar.gz
# Cd memcached-1.4.5
#./Configure -- prefix =/usr/local -- with-libevent =/usr/lib/
# Make
# Make install
#/Usr/local/bin/memcached-d-u www-m 128
-P <num>
TCP port of the listener (default: 11211)
-D
Run Memcached in daemon mode
-U <username>
The account running Memcached is not a root user.
-M <num>
The maximum memory usage unit is MB. The default value is 64 MB.
-C <num>
The default number of soft connections is 1024.
-V
Output warning and error messages
-Vv
Print client requests and returned information
-H
Print help information
-I
Print the copyright information of memcached and libevent
6. Install ZendOptimizer
# Cd ..
# Tar zxvf ZendOptimizer-3.3.3-linux-glibc23-i386.tar.gz
# Cd ZendOptimizer-3.3.3-linux-glibc23-i386
#./Install
Please specify the location for installing
Zend Optimizer:
Enter the Zend installation path and write it as follows.
/Usr/local/Zend
Confirm the location of your
Php. ini file:
Enter the php. ini path, and write it as follows.
/Usr/local/etc/cgi
Are you using Apache Web server?
Select No here
7. Start Nginx and PHP
# Mv-f/usr/local/src/fcgi. conf/usr/local/nginx/conf/
# Cp-f/usr/local/src/nginx. conf/usr/local/nginx/conf/nginx. conf
# Ulimit-shn65535
#/Usr/local/php/sbin/php-fpm start
# Service nginx start
8. Security Settings
Find
; Cgi. fix_pathinfo = 0
Remove the semicolon before this sentence and change it
Cgi. fix_pathinfo = 0