LNMP First Part environment construction

Source: Internet
Author: User

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

  1. Location ~ \.php$ {
  2. root HTML; #相对路径
  3. Fastcgi_pass 127.0.0.1:9000;
  4. Fastcgi_index index.php;
  5. Fastcgi_param Script_filename/usr/local/nginx/html$fastcgi_script_name; #/usr/local/nginx/html is the absolute path
  6. Include Fastcgi_params;
  7. }

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

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.