1. mysql installation (with lamp inside the installation method)
2. PHP Installation
wget http://cn2.php.net/distributions/php-5.4.37.tar.bz2
Tar jxf php-5.4.37.tar.bz2
Useradd-s/sbin/nologin php-fpm runs #该php以php-fpm and needs to be created, unlike the previous lamp's PHP operation
CD php-5.4.37
./configure--prefix=/usr/local/php--with-config-file-path=/usr/local/php/etc--enable-fpm--with-fpm-user= PHP-FPM--with-fpm-group=php-fpm--with-mysql=/usr/local/mysql--with-mysql-sock=/tmp/mysql.sock--with-libxml-dir --WITH-GD--with-jpeg-dir--with-png-dir--with-freetype-dir--with-iconv-dir--with-zlib-dir--with-mcrypt- -enable-soap--enable-gd-native-ttf--enable-ftp--enable-mbstring--enable-exif--disable-ipv6--with-curl
Make && make install
CP Php.ini-production/usr/local/php/etc/php.ini
Copy startup script:
cp/usr/local/src/php-5.4.37/sapi/fpm/init.d.php-fpm/etc/init.d/php-fpm
Mv/usr/local/php/etc/php-fpm.conf.default/usr/local/php/etc/php-fpm.conf
chmod 755/etc/init.d/php-fpm
Chkconfig--add PHP-FPM
Service PHP-FPM Start
Chkconfig PHP-FPM on
3. Installing Nginx
cd/usr/local/src/
wget http://nginx.org/download/nginx-1.6.2.tar.gz
Tar zxvf nginx-1.6.2.tar.gz
CD nginx-1.6.2
./configure--prefix=/usr/local/nginx--with-pcre
Make
Make install
Start Nginx:
/usr/local/nginx/sbin/nginx
4. Writing Nginx Startup scripts
Vim/etc/init.d/nginx//Add 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/logs/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, execute
chmod A+x/etc/init.d/nginx
Chkconfig--add Nginx
Chkconfig Nginx on
5. Configuration parsing PHP
vim/usr/local/nginx/conf/nginx.conf//Put the following configuration in front of # Delete, and change Fastcgi_param script_filename that line
- Location ~ \.php$ {
- root HTML; #相对路径
- Fastcgi_pass 127.0.0.1:9000;
- Fastcgi_index index.php;
- Fastcgi_param Script_filename/usr/local/nginx/html$fastcgi_script_name; #/usr/local/nginx/html is the absolute path
- Include Fastcgi_params;
- }
Copy Code
Reload/usr/local/nginx/sbin/nginx-s Reload
vim/usr/local/nginx/html/1.php
Increase
<?php
Phpinfo ();
?>
Test: Curl localhost/1.php
LNMP First Part environment construction