1, Nginx
Version: 1.5
Download Address: http://nginx.org/download/nginx-1.5.2.tar.gz
2, MySQL
Version 5.5
Download Address: http://downloads.mysql.com/archives/mysql-5.0/mysql-5.5.30.tar.gz
3, PHP
Version 5.4
Download Address: Http://am1.php.net/get/php-5.4.34.tar.gz/from/this/mirror
One: Install Nginx
To install some dependent packages:
Yum-y install gcc gcc-c++ gcc-devel gcc-c++-devel SSL ssl-devel autoconf make aclocal libtool expat-devel libxml2-devel o Penssl openssl-devel zlib zlib-devel bzip2 bzip2-devel gd gd-devel libmcrypt libmcrypt-devel libxpm-devel curl-devel LIBG D-devel Gd-devel Openldap-devel
Enter a directory:
cd/opt/
Download and extract:
wget http://nginx.org/download/nginx-1.5.2.tar.gz
TAR-ZXF nginx-1.5.2.tar.gz
wget http://labs.frickle.com/files/ngx_cache_purge-2.1.tar.gz
TAR-ZXF ngx_cache_purge-2.1.tar.gz
wget http://sourceforge.net/projects/pcre/files/pcre/8.34/pcre-8.34.tar.gz
TAR-ZXF pcre-8.34.tar.gz
Enter the directory and compile:
CD nginx-1.5.2
./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/log/error.log--http-log-path=/usr/local/nginx /log/access.log--pid-path=/usr/local/nginx/run/nginx.pid --user=www--group=www--with-http_ssl _module--with-http_flv_module--with-http_stub_status_module--with-http_gzip_static_module-- Http-client-body-temp-path=/usr/local/nginx/tmp/client--http-proxy-temp-path=/usr/local/nginx/tmp/proxy/-- http-fastcgi-temp-path=/usr/local/nginx/tmp/fcgi/--add-module=. /ngx_cache_purge-2.1--with-pcre=. /pcre-8.34
make && make install
This completes the construction of the Nginx.
Run:/usr/local/nginx/sbin/nginx
Error: Nginx: [Emerg] Getpwnam ("www") failed
Remove the user nobody annotation from the nginx.conf and change it to www
Run again:/usr/local/nginx/sbin/nginx
Error: Nginx: [Emerg] Getpwnam ("www") failed in/usr/local/nginx/conf/nginx.conf:1
The reason for the error is that the WWW user group and user www should be added to the server system, such as the following command:
Groupadd-f www
Useradd-g www www
Third run:/usr/local/nginx/sbin/nginx
Error: Nginx: [Emerg] mkdir () "/usr/local/nginx/tmp/client" failed (2:no such file or directory)
Executive: Mkdir-p/usr/local/nginx/tmp/client
Then localhost access to see:
Get used to/etc/init.d/nginx start? Think/usr/local/nginx/sbin/nginx too long?
Vim/etc/init.d/nginx
#!/bin/bash
#
# Init file for Nginx server daemon
#
# chkconfig:234 99 99
# Description:nginx Server Daemon
#
# source Function Library
. /etc/rc.d/init.d/functions
# Pull in Sysconfig settings
[-f/etc/sysconfig/nginx] &&. /etc/sysconfig/nginx
Retval=0
Prog= "Nginx"
Pat=/usr/local/nginx
Nginxd=/usr/local/nginx/sbin/nginx
Pid_file=/usr/local/nginx/nginx.pid
Start ()
{
Echo-n $ "Starting $prog:"
$NGINXD 2>/dev/null $OPTIONS && Success | | Failure
Retval=$?
["$RETVAL" = 0] && Touch/var/lock/subsys/nginx
Echo
}
Stop ()
{
Echo-n $ "Shutting down $prog:"
Killproc Nginx
Retval=$?
Echo
[$RETVAL-eq 0] && rm-f/var/lock/subsys/nginx
Return $RETVAL
}
Reload ()
{
Echo-n $ "Reloading Nginx:"
Killproc Nginx-hup
Retval=$?
Echo
Return $RETVAL
}
Case "$" in
"Start")
Start
;;
"Stop")
Stop
;;
"Restart")
Stop
Start
;;
"Reload")
Reload
;;
"Status")
Status-p $PID _file Nginx
Retval=$?
;;
*)
echo $ "Usage: $ {Start|stop|restart|reload|status}"
Retval=1
Esac
Exit $RETVAL
Save, add x permissions.
If you need to boot:
Chkconfig Nginx on
Second, the installation of MySQL
Enter the installation directory:
Cd/opt
Download and extract:
wget http://downloads.mysql.com/archives/mysql-5.0/mysql-5.5.30.tar.gz
TAR-ZXF mysql-5.5.30.tar.gz
Compile Installation:
CMake \
-dcmake_install_prefix=/usr/local/mysql \
-dmysql_datadir=/usr/local/mysql/data \
-DSYSCONFDIR=/ETC \
-dwith_myisam_storage_engine=1 \
-dwith_innobase_storage_engine=1 \
-dwith_memory_storage_engine=1 \
-dwith_readline=1 \
-dmysql_unix_addr=/var/lib/mysql/mysql.sock \
-dmysql_tcp_port=3306 \
-denabled_local_infile=1 \
-dwith_partition_storage_engine=1 \
-dextra_charsets=all \
-ddefault_charset=utf8 \
-ddefault_collation=utf8_general_ci
Make && make install
If you have an error:
Rm-f CMakeCache.txt
Yum-y Install Ncurses-devel
To add a user and Modify permissions:
Groupadd MySQL
useradd-g MySQL MySQL
Chown-r Mysql:mysql/usr/local/mysql
Enter the installation path and execute the initialization configuration script to create the system's own database and tables
Cd/usr/local/mysql
scripts/mysql_install_db--basedir=/usr/local/mysql--datadir=/usr/local/mysql/data--user=mysql
Add service, Copy Service script to INIT.D directory, and set boot up:
CP Support-files/mysql.server/etc/init.d/mysql
CP support-files/my-medium.cnf/etc/my.cnf #copy conf
Chkconfig MySQL on
Service MySQL Start--Starting MySQL
Set path to support direct call to MySQL (Modify/etc/profile file, add at end of file):
Path=/usr/local/mysql/bin: $PATH
Export PATH
Close the file and run the following command to have the configuration take effect immediately
Source/etc/profile
Another: mysql5.5 began to support CMake. As for the difference between the two:
/configure is the execution of your current directory under a script called configure, generated by it makefile, after makefile, generally can be compiled through make, made install to install.
CMake is a compilation tool with make peers, except that it relies on makefile as a compilation rule and is compiled from CMakeLists.txt.
Cmake Control: http://dev.mysql.com/doc/refman/5.5/en/source-configuration-options.html
Another: Cmeke if there is no yum install CMake, if not yet please go: http://www.cmake.org/download
Third, the installation of PHP
Enter the installation directory:
Cd/opt
Download and extract:
wget Http://am1.php.net/get/php-5.4.34.tar.gz/from/this/mirror
TAR-ZXF php-5.4.34.tar.gz
Enter Directory compilation:
CD php-5.4.34
./configure--prefix=/usr/local/php--with-config-file-path=/usr/local/php/etc--with-mysql--with-mysqli=/usr/ Local/mysql/bin/mysql_config--with-iconv-dir--with-freetype-dir--with-jpeg-dir--with-png-dir--with-zlib-- With-libxml-dir--enable-xml--enable-bcmath--enable-shmop--enable-sysvsem--enable-inline-optimization-- With-curl--with-curlwrappers--enable-mbregex--enable-fpm--enable-mbstring--with-mcrypt=/usr/local/mcrypt-- WITH-GD--enable-gd-native-ttf--with-openssl--with-mhash--enable-pcntl--enable-sockets-- WITH-LDAP-SASL--with-xmlrpc--enable-zip--enable-soap--with-pear--enable-pdo- Enable-exif--enable-wddx--enable-calendar--enable-ftp--enable-dba--enable-sysvmsg-- Enable-debug--enable-maintainer-zts--enable-embed--with-pcre-regex--enable-gd-jis-conv--with-fpm-user=www-- With-fpm-group=www--enable-sockets
Error: Configure:error:mcrypt.h not found. Please reinstall Libmcrypt.
In http://sourceforge.net/projects/mcrypt/files/download Libmcrypt and mcrypt compilation (where compiling mcrypt requires mhash support, So after compiling libmcrypt need to download Mhash, compile the mhash before compiling mcrypt)
wget http://sourceforge.net/projects/mcrypt/files/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz/download
TAR-ZXVF libmcrypt-2.5.8.tar.gz
CD libmcrypt-2.5.8
./configure
Make && make install
wget http://sourceforge.net/projects/mhash/files/mhash/0.9.9.9/mhash-0.9.9.9.tar.gz/download
TAR-ZXVF mhash-0.9.9.9.tar.gz
CD mhash-0.9.9.9
./configure
Make && make install
wget http://sourceforge.net/projects/mcrypt/files/MCrypt/2.6.8/mcrypt-2.6.8.tar.gz/download
TAR-ZXVF mcrypt-2.6.8.tar.gz
CD mcrypt-2.6.8
Ld_library_path=/usr/local/lib./configure
Make && make install
Compile again at this time, through
[If you report configure:error:Cannot find LDAP libraries In/usr/lib
Solution: cp-frp/usr/lib64/libldap*/usr/lib/]
Make && make install
Since php5.4 has integrated php-fpm, we do not need to download the PHP-FPM for additional downloads.
Run directly:
/usr/local/php/sbin/php-fpm
Error: error:failed to open configuration file '/usr/local/php/etc/php-fpm.conf ': No such file or directory (2)
Cp/usr/local/php/etc/php-fpm.conf.default/usr/local/php/etc/php-fpm.conf
Solve. PS aux | grep php view, already started.
Another PHP configuration file copy: Cp/opt/php-5.4.34/php.ini-production/usr/local/php/etc/php.ini
Is it still not supported to create a new PHP file access at this time? ha [Bad laugh].
Modify Nginx.conf
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;
}
Restart Nginx, so far, all ended.
Then is there a hint of sadness? Think/usr/local/php/sbin/php-fpm too long? Got used to/etc/init.d/php-fpm start?
vim/etc/init.d/php-fpm
#! /bin/sh
### BEGIN INIT INFO
# PROVIDES:PHP-FPM
# Required-start: $remote _fs $network
# required-stop: $remote _fs $network
# Default-start:2 3 4 5
# default-stop:0 1 6
# Short-description:starts PHP-FPM
# description:starts The PHP FastCGI Process Manager Daemon
### End INIT INFO
prefix=/usr/local/php
Exec_prefix=${prefix}
php_fpm_bin=${exec_prefix}/sbin/php-fpm
Php_fpm_conf=${prefix}/etc/php-fpm.conf
Php_fpm_pid=${prefix}/var/run/php-fpm.pid
php_opts= "--fpm-config $php _fpm_conf--pid $php _fpm_pid"
Wait_for_pid () {
Try=0
While Test $try-LT 35; Todo
Case "$" in
' Created ')
If [-F "$"]; Then
Try= '
Break
Fi
;;
' Removed ')
if [!-f ' $ ']; Then
Try= '
Break
Fi
;;
Esac
Echo-n.
try= ' expr $try + 1 '
Sleep 1
Done
}
Case "$" in
Start
Echo-n "Starting PHP-FPM"
$php _fpm_bin--daemonize $php _opts
If ["$?"!= 0]; Then
echo "Failed"
Exit 1
Fi
Wait_for_pid created $php _fpm_pid
If [-N "$try"]; Then
echo "Failed"
Exit 1
Else
echo "Done"
Fi
;;
Stop
Echo-n "gracefully shutting down php-fpm"
if [!-R $php _fpm_pid]; Then
echo "Warning, no PID file found-php-fpm is not running?"
Exit 1
Fi
Kill-quit ' Cat $php _fpm_pid '
Wait_for_pid removed $php _fpm_pid
If [-N "$try"]; Then
echo "failed. Use Force-quit "
Exit 1
Else
echo "Done"
Fi
;;
Force-quit)
Echo-n "Terminating php-fpm"
if [!-R $php _fpm_pid]; Then
echo "Warning, no PID file found-php-fpm is not running?"
Exit 1
Fi
Kill-term ' Cat $php _fpm_pid '
Wait_for_pid removed $php _fpm_pid
If [-N "$try"]; Then
echo "Failed"
Exit 1
Else
echo "Done"
Fi
;;
Restart)
$ stop
$ start
;;
Reload
Echo-n "Reload Service PHP-FPM"
if [!-R $php _fpm_pid]; Then
echo "Warning, no PID file found-php-fpm is not running?"
Exit 1
Fi
KILL-USR2 ' Cat $php _fpm_pid '
echo "Done"
;;
*)
echo "Usage: $ {start|stop|force-quit|restart|reload}"
Exit 1
;;
Esac
Save, add x permissions.
For boot start: Chkconfig php-fpm on
Add: Set the number of FPM threads
After the PHP5.4 is installed, the default profile for FPM is located in/usr/local/php/etc/php-fpm.conf.default
>cp/usr/local/php/etc/php-fpm.conf.default/usr/local/php/etc/php-fpm.conf
>vim/usr/local/php/etc/php-fpm.conf
Enter "/www" to search the pool at www
PM = dynamic
; The number of child processes to being created when PM is set to ' static '
; Maximum number of child processes when the PM is set to ' dynamic ' or ' OnDemand '.
; This value sets the limit on the number of simultaneous requests that would be
; Served. Equivalent to the apachemaxclients directive with Mpm_prefork.
; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP
; Cgi. The below defaults are based on a server without much of the resources. Don ' t
; Forget to tweak pm.* to fit your needs.
; note:used when PM are set to ' static ', ' dynamic ' or ' OnDemand '
; Note:this value is mandatory.
Pm.max_children = 5
; The number of child processes created on startup.
; Note:used only if PM is set to ' dynamic '
; Default value:min_spare_servers + (max_spare_servers-min_spare_servers)/2
Pm.start_servers = 2
; The desired minimum number of idle server processes.
; Note:used only if PM is set to ' dynamic '
; Note:mandatory when PM are set to ' dynamic '
Pm.min_spare_servers = 1
; The desired maximum number of idle server processes.
; Note:used only if PM is set to ' dynamic '
; Note:mandatory when PM are set to ' dynamic '
Pm.max_spare_servers = 3
; The number of seconds after which a idle process would be killed.
; Note:used only if PM is set to ' OnDemand '
; Default value:10s
;p m.process_idle_timeout = 10s;
; The number of requests each child process should execute before respawning.
; This can is useful to work around memory leaks at 3rd party libraries. For
; Endless request processing Specify ' 0 '. Equivalent to Php_fcgi_max_requests.
; Default value:0
;p m.max_requests = 500
Explain:
PM = How dynamic controls the subprocess, the options are static and dynamic, the default is dynamic, and if you choose Static, the number of fixed Pm.max_children is specified by the.
If dynamic is selected, it is determined by the following parameters:
Pm.max_children, maximum number of child processes
Pm.start_servers, number of processes at startup
Pm.min_spare_servers, guarantees the minimum number of idle processes, and creates a new subprocess if the idle process is less than this value
Pm.max_spare_servers, guarantees the maximum number of idle processes, and cleans if the idle process is greater than this value
For dedicated servers, PM can be set to static.
Pm.max_requests sets the number of requests for services before each subprocess is regenerated. is useful for Third-party modules that may have memory leaks. If set to ' 0′, the request is always accepted. Set to 500 is OK (default 0).
Modify the value to read as follows:
Pm.max_children = 32
Pm.start_servers = 16
Pm.min_spare_servers = 8
Pm.max_spare_servers = 32
Pm.max_requests = 500
: Wq Save quit Vim
>/usr/local/php/sbin/php-fpm-t
Notice:configuration file/usr/local/php/etc/php-fpm.conf Test is successful
Test configuration file is normal, no problem, kill the current FPM process
>/USR/LOCAL/PHP/SBIN/PHP-FPM start