nginx installation and operation control
Compile and install nginx
Install support software
The configuration and operation of nginx need the support of pcre, zlib and other software packages
Install pcre and zlib
You need to mount the Centos image during installation. Clear the yum source
[root@centos ~]# yum -y install pcre-devel zlib-devel
Create and run users and groups
Create a user and group dedicated to managing nginx
[root@centos ~]# useradd -M -s /sbin/nologin nginx
After installation
Switch Linux image disc
Unzip the nginx file
[root@centos ~]# tar zxvf /mnt/nginx-1.6.0.tar.gz –C /usr/src // Unzip it to the / usr / SRC directory
After decompression, we compile
Configure nginx
cd /usr/src/nginx-1.6.0/ //Cut into the directory [root@centos nginx-1.6.0]#./configure --prefix=/usr/local/nginx --user=nginx --with-http_stub_status_module // Configuration module [root@centos nginx-1.6.0]# make && make install // Compile and install
Optimization command
[root@centos ~]# ln -s /usr/local/nginx/sbin/* /usr/local/sbin/
(after optimization, try the nginx shortcut)
nginx service control
start-up nginx [root@centos ~]# nginx [root@centos ~]# netstat -anptu | grep nginx
Restart nginx: Kill - s HUP nginx, kill - S 1 nginx
Close nginx: Kill - s quit nginx, kill - S 3 nginx
View nginx master profile
[root@centos ~]# cat /usr/local/nginx/conf/nginx.conf
Common configuration options for master profile
1) Global profile
Effective for the entire nginx
2)server
Virtual host profile
3) Performance optimization
worker_processes 1; // Number of processes, determined by CPU
events {
worker_connections 1024; // One process corresponds to 1024 link requests
}
use epoll; // Use the epoll model to the corresponding client request
user nobody; // Default management account nobody
Configure domain name based virtual host
Create page root
[root@centos ~]# mkdir -p /www/benetcom // Create benet directory [root@centos ~]# mkdir -p /www/accpcom // Create accp directory [root@centos ~]# echo "www.benet.com" > /www/benetcom/index.html [root@centos ~]# echo "www.accp.com" > /www/accpcom/index.html
Modify nginx master configuration file
[root@centos ~]# vim /usr/local/nginx/conf/nginx.conf Then we delete some unused comment lines 38 server { //First virtual host 39 listen 80; //Listening port 40 server_name www.benet.com; //domain name 41 charset utf-8; //Character encoding 42 access_log logs/www.benet.com.access.log; //Success log 43 location / { //Site root 44 root /www/benetcom/; //Site root location 45 index index.html; //Website home page 46 } 47 } 48 49 server { 50 listen 80; 51 server_name www.accp.com; 52 charset utf-8; 53 access_log logs/www.accp.com.access.log; 54 location / { 55 root /www/accpcom/; 56 index index.html; 57 } 58 }
Check the master profile for errors
nginx -t
We set up dns for testing
Installation services yum -y install bind bind-utils bind-chroot Set the startup and self startup systemctl enable named set up dns Master profile options { listen-on port 53 { any; }; directory "/var/named/"; }; zone "benet.com" IN { type master; file "benet.com.zone"; }; zone "accp.com" IN { type master; file "accp.com.zone"; }; Then configure two forward parsing files One benet One accp Forward parsing file for
Test the web page after configuration
Test web page
Build lnmp platform
Install MySQL first
Mount Linux image
After installation
Installing cmake dependencies
[root@centos ~]# yum -y install cmake
Create MySQL group
Please see the link below for the installation process
Install php
[root@centos ~]# yum -y install gd libxml2-devel.x86_64 libjpeg-turbo-devel.x86_64 libpng-devel.x86_64
Configure php
Switch Linux CD
[root@centos ~]# umount /mnt/ umount: /mnt/: unmounted [root@centos ~]# mount /dev/cdrom /mnt/ mount: /dev/sr0 Write protected, will mount as read-only
Installation and configuration of php
[root@centos ~]# yum -y install gd libxml2-devel libjpeg-devel libpng-devel [root@centos php-5.3.28]# ./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql/ --with-mysqli=/usr/local/mysql/bin/mysql_config --with-config-file-path=/use/local/php --enable-mbstring --enable-fpm --with-gd --with-zlib --with-jpeg-dir=/usr/lib/ [root@centos php-5.3.28]# make && make install
Generate php master configuration file
[root@centos php-5.3.28]# cp php.ini-production /usr/local/php/php.ini
Optimize php commands
[root@centos php-5.3.28]# ln -s /usr/local/php/bin/* /usr/local/bin/ [root@centos php-5.3.28]# php php php-config phpize [root@centos php-5.3.28]# cd [root@centos ~]# ln -s /usr/local/php/sbin/* /usr/local/sbin/
Configure zend acceleration
[root@centos ~]# tar zxvf /mnt/ZendGuardLoader-php-5.3-linux-glibc23-x86_64.tar.gz -C /usr/src/ ZendGuardLoader-php-5.3-linux-glibc23-x86_64/ ZendGuardLoader-php-5.3-linux-glibc23-x86_64/php-5.3.x/ ZendGuardLoader-php-5.3-linux-glibc23-x86_64/php-5.3.x/ZendGuardLoader.so ZendGuardLoader-php-5.3-linux-glibc23-x86_64/README.txt [root@centos ~]# cd /usr/src/ZendGuardLoader-php-5.3-linux-glibc23-x86_64/php-5.3.x/ [root@centos php-5.3.x]# ls ZendGuardLoader.so [root@centos php-5.3.x]# cp ZendGuardLoader.so /usr/local//php/lib/php/ [root@centos ~]# vim /usr/local/php/php.ini [PHP] zend_extension=/usr/local/php/lib/php/ZendGuardLoader.so zend_loader.enable=1
Configure php FPM to parse php dynamic language
[root@centos ~]# cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf [root@centos ~]# vim /usr/local/php/etc/php-fpm.conf user = nginx group = nginx
Start PHP FPM
[root@centos ~]# php-fpm [root@centos ~]# netstat -anptu | grep 9000 tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 125202/php-fpm: mas
Modify nginx main configuration file link php to work together
[root@centos ~]# vim /usr/local/nginx/conf/nginx.conf 38 server { 39 listen 80; 40 server_name www.benet.com; 41 charset utf-8; 42 access_log logs/www.benet.com.access.log; 43 location / { 44 root /www/benetcom/; 45 index index.html index.php; 46 } 47 location ~ \.php$ { 48 root /www/benetcom; 49 fastcgi_pass 127.0.0.1:9000; 50 fastcgi_index index.php; 51 include fastcgi.conf; 52 } 53 } 55 server { 56 listen 80; 57 server_name www.accp.com; 58 charset utf-8; 59 access_log logs/www.accp.com.access.log; 60 location / { 61 root /www/accpcom/; 62 index index.html index.php; 63 } 64 65 location ~ \.php$ { 66 root /www/accpcom; 67 fastcgi_pass 127.0.0.1:9000; 68 fastcgi_index index.php; 69 include fastcgi.conf; 70 } 71 }
Check master profile
[root@centos ~]# nginx -t
Set php test page
[root@centos ~]# vim /www/benetcom/index.php <?php phpinfo(); ?>
start nginx
[root@centos ~]# killall nginx [root@centos ~]# nginx
Test
#Deployment Forum
Unzip the forum configuration file
[root@centos ~]# unzip Discuz_X3.2_SC_UTF8.zip
Cut the project file to the root directory of the web site
[root@centos ~]# rm -rf /www/benetcom/* // Clear all under the website [root@centos ~]# mv upload/* /www/benetcom/ // Cut to website
Set directory owner and permissions
[root@centos ~]# chown -R nginx:nginx /www/benetcom/ [root@centos ~]# chmod -R 755 /www/benetcom/
Create the database file used by the forum project
[root@centos ~]# mysql -uroot -ppwd@123 mysql> create database bbs; mysql> grant all on bbs.* to 'bbs'@'localhost' identified by 'pwd@123';
Test