2015-05-11LNMP First Part environment construction

Source: Internet
Author: User
Tags mcrypt pear

Tag: blank Target Local

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
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

Yum install-y libxml2* libcurl* mcrypt* libmcrypt* gcc

Make && make install

Make Test
Wrote PEAR system config file at:/usr/local/php/etc/pear.conf

Want to add:/usr/local/php/lib/php to your php.ini include_path

/usr/local/mysql/php-5.4.37/build/shtool install-c Ext/phar/phar.phar/usr/local/php/bin

Ln-s-f/usr/local/php/bin/phar.phar/usr/local/php/bin/phar

Installing PDO headers:/usr/local/php/include/php/ext/pdo/
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

Yum install-y pcre* zlib*
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;
    6. Include Fastcgi_params;
    7. }

Copy Code

Reload/usr/local/nginx/sbin/nginx-s  Reload
vim /usr/local/nginx/html/1.php 
Add    
<?php
    phpinfo ();
?>
Test: Curl localhost/1.php 
[[email protected] nginx]# find / -name  error.log
/ Usr/local/nginx/logs/error.log
less /usr/local/php/var/log/php-fpm.log
2015/07/20 20:23:08 [ERROR] 17136#0: * * Connect () failed (111:connection refused) while connecting to upstream, client:116.211.87.246, server:local Host, Request: "Get/1.php http/1.1", Upstream: "fastcgi://127.0.0.1:9000", Host: "111.47.123.72"

http://www.ttlsa.com/nginx/connect-failed-111-connection-refused-while-connecting-to-upstream/
Extended Learning:
Why Nginx is more efficient than Apache httpd: Principle Article http://www.toxingwang.com/linux-unix/linux-basic/1712.html
Apache and Nginx working principle comparison http://www.server110.com/nginx/201402/6543.html
Comparison of mod_php and mod_fastcgi and php-fpm http://wenku.baidu.com/link?url= ... Qzfjkh_aelc4nc-ld03
Concept understanding: cgi,fastcgi,php-cgi and PHP-FPM http://www.nowamagic.net/librarys/veda/detail/1319/

2015-05-11LNMP 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.