LNMP Site Server Deployment

Source: Internet
Author: User
Tags php template nginx server

Lnmp is currently the most widely used Web server architecture,Linux is a class of UNIX computer operating system, is the most popular free operating system. The representative versions are: Debian, CentOS, Ubuntu, Fedora, Gentoo, etc.,Nginx is a high-performance HTTP and reverse proxy server, also a IMAP/POP3/SMTP proxy server,Mysql is a small relational database management system,PHP is a server-side execution of embedded HTML document scripting language. These four kinds of software are free open-source software, combined to become a free, efficient, scalable Web services system.

System environment:
    • RHEL 6.5 Operating system
    • Server IP Address:
    • Client IP Address: (same network segment as server and able to interconnect)
    • LNMP package Baidu Download Password: j892
Achieve the goal:
    1. Installing Nginx Server
    2. Installing the MySQL Database
    3. Install PHP
    4. Deploy Discuz Forum
Start deployment One. Installing Nginx server 1. Installing a Dependency Package
yum -y install pcre-devel zlib-devel gcc gcc-c++ make
2. New Nginx Admin user
useradd -M -s /sbin/nologin nginx
3. Unzip
tar xzvf nginx-1.6.0.tar.gz -C /opt
4. Configuration
cd /opt/nginx-1.6.0/

./configure \
--prefix=/usr/local/nginx \
--user=nginx \
--group=nginx \
--with-http_stub_status_module #开启stub_status状态统计模块

5. Compiling and installing
make && make install
6. Create Nginx links for easy system Management
ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin/

########### nginx Management Command ###########

Nginx-t #nginx配置文件检查
Nginx #启动
KILLALL-1 Nginx #重启nginx
Killall-3 Nginx #停止nginx


7. Generate Nginx Management scripts
vi /etc/init.d/nginx

#chkconfig:-99 20
#description: Nginx Service Control Script
Prog= "/usr/local/nginx/sbin/nginx"
pidf= "/usr/local/nginx/logs/nginx.pid"
Case "$" in
Kill-s QUIT $ (cat $PIDF)
$ stop
$ start
Kill-s HUP $ (cat $PIDF)
echo "Usage: $ {start|stop|restart|reload}"
Exit 1
Exit 0

8.nginx Give Execute permission
chmod +x /etc/init.d/nginx
9.nginx Join system service Management
chkconfig --add nginx
10. Start Nginx
service nginx start
11. Testing

Two. Install MySQL database 1. Installing Support Packages
yum -y install ncurses-devel gcc gcc-c++ cmake              
2. Unzip
tar xzvf mysql-5.5.24.tar.gz -C /opt
3. Go to the MySQL installation package directory
cd /opt/mysql-5.5.24
4. Configuration

CMake \
-dcmake_install_prefix=/usr/local/mysql \
-ddefault_charset=utf8 \
-dwith_extra_charsets=all \
-dmysql_unix_addr=/home/mysql/mysql.sock \
-dwith_myisam_storage_engine=1 \
-dwith_innobase_storage_engine=1 \
-dwith_archive_storage_engine=1 \
-dwith_blackhole_storage_engine=1 \
-denabled_local_infile=1 \
-dwith_ssl=system \
-dmysql_tcp_port=3306 \
-denable_downloads=1 \

5. Compiling and installing
make && make install
6. Copy the MySQL configuration file and launch script to the appropriate directory
cp support-files/my-medium.cnf /etc/my.cnfcp support-files/mysql.server /etc/init.d/mysqld
7. Mysqld Giving Execute permission
chmod +x /etc/init.d/mysqld
8. Add Mysqld to System Management
chkconfig mysqld onservice mysqld start
9. Add MySQL to the environment variable
echo "PATH=$PATH:/usr/local/mysql/bin/" >> /etc/profile. /etc/profile      #更新环境变量
10. Add a MySQL Admin user
useradd -s /sbin/nologin mysql
11. Modify the MySQL user and user group
chown -R mysql.mysql /usr/local/mysql
12. Import the MySQL default database

>/usr/local/mysql/scripts/mysql_install_db \
--user=mysql \
--ldata=/var/lib/mysql \
--basedir=/usr/local/mysql \

13. Establish Mysql.sock Link
ln -s /var/lib/mysql/mysql.sock  /home/mysql/mysql.sock
14. Edit the Mysqld startup script
vim /etc/init.d/mysqld


15. Restart the MYSQLD service
service mysqld restart
MySQL Test

Three. Install the PHP1. First install GD Library and GD Library Association program
yum -y install gd libxml2-devel libjpeg-devel libpng-devel zlib-devel fontconfig-devel openssl-devel bzip2-devel
2. Unzip
tar -jxvf php-5.4.5.tar.bz2 -C /opt
3. Go to the PHP directory
cd /opt/php-5.4.5/
4. Configuration

./configure \
--with-zlib \
--with-mysql=/usr/local/mysql \
--enable-mbstring \
--with-jpeg-dir \
--disable-ipv6 \

5. Compiling and installing
make && make install
6. Copy the PHP template configuration file
cp php.ini-development /usr/local/php5/php.ini
7. Create a link to the PHP execution file to the system directory for easy execution
ln -s /usr/local/php5/bin/* /usr/local/bin/ln -s /usr/local/php5/sbin/* /usr/local/sbin/
8. PHP Installation Accelerator

Tar xzvf zendguardloader-php-5.3-linux-glibc23-i386.tar.gz-c/opt
#复制ZendGuardLoader. So to PHP
CP zendguardloader.so/usr/local/php5/lib/php/

9. Configure the PHP recognition accelerator
vim /usr/local/php5/php.ini

[Zend Guard Loader]

10. Open the Nginx PHP support

#创建php-fpm.conf File
CP Php-fpm.conf.default php-fpm.conf
Useradd-m-s/sbin/nologin PHP

vi php-fpm.conf #修改

PID = Run/php-fpm.pid #25行
user = PHP #140行
Group = PHP #141行
Pm.max_children=50 #217行
Pm.start_servers = #222行
Pm.min_spare_servers = 5 #227行
Pm.max_spare_servers = #232行

11. View the 9000 port service
netstat -tnal | grep 9000
12. Let Nginx support PHP function
vi /usr/local/nginx/conf/nginx.conf

Location ~. php$ {
Fastcgi_index index.php;
Include fastcgi.conf;

Create a Site Directory
mkdir -p /var/www/php
13. New Site Home File
vim /var/www/php/index.php

<?php phpinfo ();?>

14. Restart Nginx
service nginx restart
Test: http: #

Four. Deployment of DISCUZ Forum 1. MySQL database management

Mysql-u Root


#把bbs数据库里面所有表的权限授予给bbsuser, and set the password
Mysql> GRANT all on bbs.* to ' bbsuser ' @ ' percent ' identified by ' admin123 ';

Mysql>flush privileges;

2. New MySQL Test Web page
vi /var/www/php/index.php

$link =mysql_connect (' ', ' bbsuser ', ' admin123 ');
if ($link) echo "success!!";
else echo "fail!!";
Mysql_close ();

Through client-side testing such as success

3. Decompression Discuz Forum
unzip Discuz_X2.5_SC_UTF8.zip -d /opt/discuz
4. Enter the DIS directory
cd /opt/discuz
5. Copy the upload file to the Web site Directory
cp -r upload/ /var/www/php/bbs
6. Change the owner to the folder

> chown-r php./config
Chown-r PHP./data
Chown-r PHP./uc_client
Chown-r PHP./uc_server/data

7. The client completes the installation through the http: Access Discuz Forum

LNMP Site Server Deployment

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.