Linux based CentOS LNMP Server Deployment Standard Novice concise version _linux

Source: Internet
Author: User
Tags chmod curl fpm install php mcrypt openssl centos zend
Minimize the installation of the system first.

First, the system agreement

Software source code Package storage location


/usr/local/src


Source Package compilation Installation Location (prefix)


/usr/local/software_name


Scripts and where maintenance programs are stored


/usr/local/sbin


MySQL Database Location


/var/lib/mysql (can be set according to the situation)


Nginx site root directory


/home/www/wwwroot (can be set according to the situation)


Nginx Virtual Host log root directory


/home/www/logs (can be set according to the situation)


Nginx Run Account


Www:www

second, the system environment initialization
1. Check if the system is normal
# more/var/log/messages (Check for system-level error messages)
# DMESG (check if the hardware device has an error message)
# cat/proc/cpuinfo (check CPU frequency is normal)
# Top (1 to detect CPU core is normal, memory size is normal)
# ifconfig (check that the NIC settings are correct)
# ping www.163.com (check that the network is OK)
2. Turn off unwanted services
# NTSYSV
Only the services that need to be started are listed below, and services not listed are recommended for shutdown:
Atd
Crond
Irqbalance
Microcode_ctl
Network
SendMail
Sshd
Syslog
Close SELinux: Modify the selinux= in the/etc/selinux/config file to Disabled
3. Replace 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 kits (hereinafter the standard RPM package name)
# yum-y Install NTP make OpenSSL openssl-devel pcre pcre-devel libpng libpng-devel libjpeg-6b libjpeg-devel-6b FreeType F Reetype-devel gd gd-devel zlib zlib-devel gcc gcc-c++ libxpm libxpm-devel ncurses ncurses-devel libmcrypt libmcrypt-devel LIBXML2 libxml2-devel imake autoconf automake screen sysstat compat-libstdc++-33 Curl Curl-devel
5. Timed calibration server clock, timing server with China National Time Service Center synchronization
# CRONTAB-E
Join a line:
*/30 * * * * * ntpdate 210.72.145.44 >/dev/null 2>&1
6. Download Package
Please go to the official website to download the latest stable version to the/usr/local/src/directory

Nginx
Current Stable edition 0.7.65 HTTP://WIKI.NGINX.ORG/NGINXCHS

Php
Current Stable edition 5.2.13 http://cn.php.net/releases/

PHP FPM Patches Current stable version 0.5.14

http://php-fpm.org/downloads/

Mysql
Current Stable edition 5.0.86 http://dev.mysql.coml/

Zend
Current Stable edition 3.3.3 http://www.zend.com/

Memcache
Current Stable edition 2.2.5 http://pecl.php.net/package/memcache/

Memcached
Current Stable edition 1.4.5

Http://memcached.googlecode.com

Libiconv
Current Stable edition 1.13.1

http://www.gnu.org/software/libiconv/

Libevent
Current Stable edition 1.4.13

http://www.monkey.org/~provos/libevent/

The configuration files and scripts in this article are limited to space, please go to the following address to download

Nginx Control Scripts

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

The latest stable downloads list for the programs listed above

http://c.sihost.net / lnmp_tools.list

in the /usr/local/src the directory executes

wget http://c.sihost.net/lnmp_tools.list

Wget-i lnmp_tools.list
7. Create a Web run user
# Groupadd www
# useradd-g www www
# mkdir-p/home/www/wwwroot
# chmod +w/home/www/wwwroot
# chown Www:www/home/www/wwwroot-r
8. Reboot
# init 6
Iii. compiling the installation environment
1. Install MySQL

# CD/USR/LOCAL/SRC
# tar ZXVF mysql-5.0.86-linux-i686-icc-glibc23.tar.gz
# MV 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 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
Increase in [mysqld] Paragraph
DataDir =/var/lib/mysql
Skip-innodb
Wait-timeout = 10
Max_connections = 512
Max_connect_errors = 10000000
Modify in [mysqld] section
Max_allowed_packet = 16M
Thread_cache_size = number of CPUs *2
The Log-bin annotation
Service mysqld Start
# bin/mysqladmin-u Root password password
Where the red password is 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 the support library required to install 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.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
# 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-- 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 (discuz! that requires this feature) x User Selection)
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 php.ini file, path/usr/local/etc/cgi/
Find: Extension_dir = "./"
Modified into: Extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/"
Line below this sentence
Add: Extension = "memcache.so"
Find: output_buffering = Off
Modified 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>
Listening TCP port (default: 11211)
-D
Run as a daemon in a daemon way Memcached Memcached
-U <username>
Run memcached account is not root user
-M <num>
The largest memory usage unit is MB, the default is 64MB
-C <num>
The number of soft connections defaults to 1024
-V
Output warnings and error messages
-vv
Print the client's request and return information
-H
Printing Help information
-I.
Print copyright information for 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:
Here to fill in the Zend installation path, press the following write can
/usr/local/zend
Confirm the location of your
php.ini file:
Here is the php.ini of the path, press the following write can
/usr/local/etc/cgi
Are you using Apache Web server?
Choose 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-shn 65535
#/USR/LOCAL/PHP/SBIN/PHP-FPM Start
# service Nginx Start
8. About security Settings
Find the/usr/local/etc/cgi/php.ini in the
; Cgi.fix_pathinfo=0
Remove the semicolon before the sentence and turn it into
Cgi.fix_pathinfo=0

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.