CentOS 6.6 Builds LNMP environment

Source: Internet
Author: User
Tags nginx server

First, before the installation

1. Shutting down the Linux security mechanism

Vim/etc/selinux/config

Selinux=enforcing Change to Selinux=disabled

2. Close Iptables Firewall

Vim/etc/sysconfig/iptables #把里边的条例全部dd删除掉, Wq Save exit

Service Iptables Stop #关闭iptables
Chkconfig iptables off #开机不自启动iptables

3, configure the Yum source (local, network can) #如果能上网的话建议配置网络yum源

For details on how to configure Yum please read http://blog.csdn.net/allen_a/article/details/51198585

4. Restart the system

Reboot

Second, installation article

Yum List
Yum Clean All
Yum-y Install Pcre-devel Zlib-devel
Yum-y Install gcc* gcc-*
Yum Remove httpd
Rpm-qa httpd
1) Compile and install Nginx
A. Installing the Support software
Yum-y Install Pcre-devel Zlib-devel
B. Creating a running user, group
Useradd-m-s/sbin/nologin Nginx
C. Compiling and installing Nginx
Tar zxvf nginx-1.6.0
CD nginx-1.6.0
./configure--prefix=/usr/local/nginx--user=nginx--group=nginx--with-http_stub_status_module
Make && make install

/usr/local/nginx/sbin/nginx # start Nginx

Access to the Nginx server IP, will appear welcome to Nginx



Nginx on, Close command

Killall-s HUP Nginx
Killall-1 Nginx

Killall-s QUIT Nginx
Killall-3 Nginx


Viewing log information
cd/usr/local/nginx/logs/

NATSTAT-ANPT | grep nginx


Optimize Application Program Control
Vim/etc/init.d/nginx
#!/bin/bash
# Chkconfig:-99 20
# Description:nginx Server Control Script
Proc= "/usr/local/nginx/sbin/nginx"
Pid= "/usr/local/nginx/logs/nginx.pid"
Case "$" in
Start
$PROC
$PROG
;;
Stop
Kill-s QUIT $ (cat $PID)
;;
Restart
$ stop
$ start
;;
Reload
Kill-s HUP $ (cat $PID)
;;
Status
[-F $PID] &>/dev/null
If [$?-eq 0]
Then
NETSTAT-ANPT | grep nginx
Else
echo "Nginx is not running."
Fi
;;
*)
echo "Usage: $ {Start|stop|restart|reload|status}"
Esac
Exit 0


Check syntax
Nginx-t



Detects the installation environment and uninstalls the RPM application
Yum remove httpd mysql PHP


1. Install MySQL Database
1) Compile and install MySQL database
Yum-y Install Ncurses-devel


Tar zxvf cmake-2.8.6.tar.gz
CD cmake-2.8.6
./configure
Gmake
Gmake Install


Tar zxvf mysql-5.5.22.tar.gz
CD mysql-5.5.22
Cmake-dcmake_install_prefix=/usr/local/mysql-ddefault_charset=utf8-ddefault_collation=utf8_general_ci-dwith_ Extra_charsets=all-dsysconfigdir=/etc
Make && make install


2) Optimization adjustment
Rm-rf/etc/my.cnf
CP SUPPORT-FILES/MY-MEDIUM.CNF/ETC/MY.CNF
CP Support-files/mysql.server/etc/rc.d/init.d/mysqld
chmod +x/etc/rc.d/init.d/mysqld
Chkconfig--level mysqld on
echo "path= $PATH:/usr/local/mysql/bin" >>/etc/profile
. /etc/profile or Source/etc/profile


3) Initializing the database
Groupadd MySQL
Useradd-m-s/sbin/nologin mysql-g MySQL
Chown-r mysql:mysql/usr/local/mysql/


/usr/local/mysql/scripts/mysql_install_db--basedir=/usr/local/mysql/--datadir=/usr/local/mysql/data/--user= Mysql


4) Start the database
Service mysqld Start
mysqladmin-u root password ' pwd123 '
Mysql-u root-p


2. Install PHP parsing environment
1) Compile and install PHP
Yum-y Install GD libxml2 libxml2-devel libjpeg-devel libpng-devel
Tar zxvf php-5.3.28.tar.gz
CD php-5.3.28


./configure--prefix=/usr/local/php5/--with-gd--with-zlib--with-mysql=/usr/local/mysql--with-config-file-path=/ USR/LOCAL/PHP5--enable-mbstring--enable-fpm--with-jpeg-dir=/usr/lib
Make && make install


Test: Make Test


2) post-installation adjustment
CP Php.ini-development/usr/local/php5/php.ini
Ln-s/usr/local/php5/bin/*/usr/local/bin/
Ln-s/usr/local/php5/sbin/*/usr/local/sbin/


3) Install Zendguardloader
Tar zxvf zendguardloader-php-5.3-linux-glibc23-x86_64.tar.gz
CD zendguardloader-php-5.3-linux-glibc23-x86_64/php-5.3.x/
CP zendguardloader.so/usr/local/php5/lib/php/


Vim/usr/local/php5/php.ini
Zend_extension=/usr/local/php5/lib/php/zendguardloader.so
Zend_loader.enable=1


Service Nginx Restart


3) Configure Nginx support PHP environment
1) Start the PHP-FPM process
cd/usr/local/php5/etc/


CP Php-fpm.conf.default php-fpm.conf
Useradd-m-s/sbin/nologin PHP


Vim php-fpm.conf
PID = run/php-fpm.pid (remove semicolon)
user = PHP
Group = PHP
Pm.start 20
Pm.min 5
Pm.max 35
Pm.max_children 50


Start the PHP-FPM process
/usr/local/sbin/php-fpm


Netstat-apnt | grep php-fpm
Netstat-apnt | grep nginx
Netstat-apnt | grep mysqld


Service Nginx Restart or reload


2) configuration Nginx support PHP parsing
Location ~ \.php$ {
root HTML;
Fastcgi_pass 127.0.0.1:9000;
Fastcgi_index index.php;
#fastcgi_param Script_filename/scripts$fastcgi_script_name;
Include fastcgi.conf;
}
3) test access to PHP pages
Vim t.php
<?php
Phpinfo ();
?>


Vim test.php
<?php
$link =mysql_connect (' localhost ', ' root ', ' pwd123 '); Single quotation marks
if ($link)
echo "Congratulations, the database connection is successful! ";
Mysql_close ();
?>

CentOS 6.6 Builds LNMP environment

Related Article

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.