Unlike lamp, the N in Lnmp refers to the Nginx (a Web service software similar to Apache). At present this kind of environment application is also very many. Nginx Design is designed to provide a fast and efficient and multiple concurrent Web services software. In the static page processing Nginx really wins Apache, however, in the dynamic page processing Nginx no more than Apache advantages. However, there are still many enthusiasts are more enthusiastic about nginx, with the Nginx technology gradually mature, it in the field of Web services software more and more high.
"MySQL Installation"
1. Download MySQL to/usr/local/src/
cd/usr/local/src/
wget http://syslab.comsenz.com/downloads/linux/mysql-5.0.86-linux-i686-icc-glibc23.tar.gz
2. Decompression
Tar zxvf/usr/local/src/mysql-5.0.86-linux-i686-icc-glibc23.tar.gz
3. Move the extracted data to the/usr/local/mysql
MV Mysql-5.0.86-linux-i686-ii-glibc23/usr/local/mysql
4. Establish MySQL User
Useradd MySQL
5. Initializing the database
Cd/usr/local/mysql
Mkdir/data/mysql; Chown-r Mysql:mysql/data/mysql
./scripts/mysql_install_db--user=mysql--datadir=/data/mysql
--user defines the owner of the database,--datadir defines where the database is installed, and recommends placing it on a large-space partition that needs to be created by itself.
6. Copy configuration file
CP SUPPORT-FILES/MY-LARGE.CNF/ETC/MY.CNF
7. Copy startup script file and modify its properties
CP Support-files/mysql.server/etc/init.d/mysqld
chmod 755/etc/init.d/mysqld
8. Modify the startup script
Vim/etc/init.d/mysqld
Where you need to modify is Datadir=/data/mysql (the directory defined before initializing the database)
9. Add the boot script to the system service and set boot up and start MySQL
Chkconfig--add mysqld
Chkconfig mysqld on
Service mysqld Start
If it does not start, check the error log under/data/mysql/, which is the hostname. Err.
" installation of PHP"
Here to declare, for nginx PHP installation and for the Apache PHP installation is a difference, because Nginx PHP is fastcgi way to combine nginx, can be understood as nginx agent of PHP fastcgi, And Apache is the use of PHP as its own module to invoke.
Useradd www
cd/usr/local/src/
wget http://syslab.comsenz.com/downloads/linux/php-5.2.10.tar.gz
wget http://syslab.comsenz.com/downloads/linux/php-5.2.10-fpm-0.5.13.diff.gz
Download the second package php-5.2.10-fpm-0.5.13.diff.gz is used to patch PHP, by default, PHP is unable to compile the fastcgi.
Tar zxvf php-5.2.10.tar.gz
GZIP-CD php-5.2.10-fpm-0.5.13.diff.gz | Patch-d PHP-5.2.10-P1
CD php-5.2.10
./configure--prefix=/usr/local/php--with-config-file-path=/usr/local/php/etc--with-mysql=/usr/local/mysql-- With-mysql-sock=/tmp--with-libxml-dir--with-gd--with-jpeg-dir--with-png-dir--with-freetype-dir --with-zlib-dir--with-mcrypt=/usr/local/libmcrypt--enable-soap--enable-gd-native-ttf--enable-ftp-- Enable-mbstring--enable-exif--enable-zend-multibyte--disable-ipv6--enable-fastcgi--enable-fpm
Make && make install
Mkdir/usr/local/php/etc
CP Php.ini-dist/usr/local/php/etc/php.ini
Vim/usr/local/php/etc/php-fpm.conf
<value name= "listen_address" >/tmp/php-fcgi.sock</value> this line to be changed to do so, here so modified, in the configuration of nginx when you need to pay attention to this path.
Modify the names of users and groups as "www"
Remove the annotation and change to this:
Unix User of processes
<value name= "User" >www</value>
Unix Group of processes
<value name= "group" >www</value>
/USR/LOCAL/PHP/SBIN/PHP-FPM start
Other extensions for PHP expansion module installation Please refer to:
Eaccelerator Installation and Configuration
The application of memcache and memcached in PHP
Compilation of Ming in PHP
About PHP configuration file php.ini and php-frpm.conf related information:
Some functions are prohibited in php.ini to increase security
Php-fpm.conf parameter Description
php-fpm.conf two critical parameters
In addition, if you have some errors in compiling PHP, please refer to:
Errors and solutions that may occur when compiling PHP
"nginx Installation and Configuration "
1. Nginx Source code installation
cd/usr/local/src/
wget http://syslab.comsenz.com/downloads/linux/nginx-0.9.6.tar.gz
Tar zxvf nginx-0.9.6.tar.gz
CD nginx-0.9.6
./configure--prefix=/usr/local/nginx--sbin-path=/usr/local/nginx/sbin/nginx--conf-path=/usr/local/nginx/conf/ nginx.conf--error-log-path=/usr/local/nginx/logs/error.log--http-log-path=/usr/local/nginx/logs/access.log-- Pid-path=/usr/local/nginx/var/nginx.pid--lock-path=/usr/local/nginx/var/nginx.lock--http-client-body-temp-path =/dev/shm/nginx_temp/client_body--http-proxy-temp-path=/dev/shm/nginx_temp/proxy--http-fastcgi-temp-path=/dev/ shm/nginx_temp/fastcgi--user=www--group=www--with-cpu-opt=pentium4f--without-select_module--without-poll_ Module--with-http_realip_module--with-http_sub_module--with-http_gzip_static_module--with-http_stub_status_ Module--without-http_ssi_module--without-http_userid_module--without-http_geo_module--without-http_memcached_ Module--without-http_map_module--without-mail_pop3_module--without-mail_imap_module--without-mail_smtp_module- -with-pcre
Make && make install
Mkdir/dev/shm/nginx_temp
Some nginx version will be compiled because Pcre compiler, need to modify the--with-pcre=/usr/local/src/pcre-7.8, provided that the PCRE source package has been downloaded pcre-7.8.tar.gz, and extracted to the/usr/ local/src/pcre-7.8, no need to compile Pcre
2. write nginx startup scripts and join the system services
Vi/etc/init.d/nginx writes the following:
#!/bin/bash
# Chkconfig:-30 21
# Description:http Service.
# Source Function Library
. /etc/init.d/functions
# Nginx Settings
Nginx_sbin= "/usr/local/nginx/sbin/nginx"
nginx_conf= "/usr/local/nginx/conf/nginx.conf"
Nginx_pid= "/usr/local/nginx/var/nginx.pid"
Retval=0
Prog= "Nginx"
Start () {
Echo-n $ "Starting $prog:"
Mkdir-p/dev/shm/nginx_temp
Daemon $NGINX _sbin-c $NGINX _conf
Retval=$?
Echo
Return $RETVAL
}
Stop () {
Echo-n $ "Stopping $prog:"
Killproc-p $NGINX _pid $NGINX _sbin-term
Rm-rf/dev/shm/nginx_temp
Retval=$?
Echo
Return $RETVAL
}
Reload () {
Echo-n $ "Reloading $prog:"
Killproc-p $NGINX _pid $NGINX _sbin-hup
Retval=$?
Echo
Return $RETVAL
}
Restart () {
Stop
Start
}
Configtest () {
$NGINX _sbin-c $NGINX _conf-t
return 0
}
Case "$" in
Start
Start
;;
Stop
Stop
;;
Reload
Reload
;;
Restart)
Restart
;;
Configtest)
Configtest
;;
*)
echo $ "Usage: $ {start|stop|reload|restart|configtest}"
Retval=1
Esac
Exit $RETVAL
After saving, change the permissions of the/etc/init.d/nginx
chmod 755/etc/init.d/nginx
Chkconfig--add Nginx
Chkconfig Nginx on
3. configuration of Nginx
Vim/usr/local/nginx/conf/nginx.conf
Empty the original file and paste the following:
User www www.
Worker_processes 2;
Error_log/usr/local/nginx/logs/nginx_error.log Crit;
Pid/usr/local/nginx/var/nginx.pid;
#Specifies the value for maximum file descriptors the can is opened by this process.
Worker_rlimit_nofile 51200;
Events
{
Use Epoll;
Worker_connections 6000;
}
http
{
Include Mime.types;
Default_type Application/octet-stream;
Server_names_hash_bucket_size 3023;
Server_names_hash_max_size 4096;
Log_format combined_realip ' $remote _addr $http _x_forwarded_for [$time _local] '
' $host ' $request _uri ' $status '
' $http _referer ', ' $http _user_agent ';
Sendfile on;
Tcp_nopush on;
Keepalive_timeout 30;
Client_header_timeout 3m;
Client_body_timeout 3m;
Send_timeout 3m;
Connection_pool_size 256;
Client_header_buffer_size 1k;
Large_client_header_buffers 8 4k;
Request_pool_size 4k;
Output_buffers 4 32k;
Postpone_output 1460;
Client_max_body_size 10m;
Client_body_buffer_size 256k;
Client_body_temp_path/usr/local/nginx/client_body_temp;
Proxy_temp_path/usr/local/nginx/proxy_temp;
Fastcgi_temp_path/usr/local/nginx/fastcgi_temp;
Fastcgi_intercept_errors on;
Tcp_nodelay on;
gzip on;
Gzip_min_length 1k;
Gzip_buffers 4 8k;
Gzip_comp_level 5;
Gzip_http_version 1.1;
Gzip_types text/plain application/x-javascript text/css text/htm application/xml;
Server
{
Listen 80;
server_name www.example.com;
Index index.html index.htm index.php;
root/data/www;
Location ~ \.php$ {
Include Fastcgi_params;
Fastcgi_pass Unix:/tmp/php-fcgi.sock;
Fastcgi_index index.php;
Fastcgi_param Script_filename/data/www$fastcgi_script_name;
}
}
}
After you save it, you can start Nginx, and before you reboot, it's a good idea to check for problems.
/USR/LOCAL/NGINX/SBIN/NGINX-T If you display information such as "syntax is OK and nginx.conf was tested successfully," The configuration is no problem, otherwise you will need to modify it as prompted.
Service Nginx Start
If not, please check the Nginx_error.log log file in the/usr/local/nginx/logs/directory. If you do not have this log file, it is most likely that the directory does not write permissions, please perform
chmod +w/usr/local/nginx/logs/
Service Nginx Restart
Refer to the following posts for detailed configuration of the Nginx configuration file:
Nginx Main configuration file
Nginx Virtual Host configuration file
More Nginx-related configuration
" test whether to parse php files "
vim/data/www/1.ph