centos7.4 Install the latest LNMP architecture settings grant access and build Discuz forum

Source: Internet
Author: User
Tags epoll fpm install php

[email protected] ~]# Yum install-y \ Install Nginx required libraries

Pcre-devel \//rewrite module need? Pcre Library
Zlib-devel//?gzip module need? zlib Library
[[email protected] ~]# useradd-m-s/sbin/nologin nginx Create program user Nginx
[[Email protected] ~]# tar XF nginx-1.13.9.tar.gz-c/opt/Unzip
[Email protected] ~]# cd/opt/nginx-1.13.9/
[Email protected] nginx-1.13.9]#/configure \
--prefix=/usr/local/nginx \//Specify the installation path
--user=nginx \//Specify running User
--group=nginx \//Specify run group
--with-http_stub_status_module//Add Log Statistics module

Note: The following error is reported by the./configure:
Configure:error:You need a C + + compiler for C + + support
You can use the following command to resolve: Yum install-y gcc gcc-c++
[[email protected] nginx-1.13.9]# make && make install

[[email protected] nginx-1.13.9]# ln-s/usr/local/nginx/sbin/nginx/usr/local/sbin/Soft Connection
[[email protected] nginx-1.13.9]# nginx-t//config file Syntax check

[[email protected] nginx-1.13.9]# nginx//Start service
[[email protected] nginx-1.13.9]# killall-1 nginx//safe restart
[[email protected] nginx-1.13.9]# killall-3 nginx//Stop service
After you start Nginx, enter 192.168.80.140 in the browser to verify that the installation was successful:

[[email protected] nginx-1.13.9]# Vi/etc/init.d/nginx//system service Management script
#!/bin/bash
#chkconfig: 35 99 20//Run level 35, 99th open, 20th off
#description: Nginx Service Control Script
prog= "/usr/local/nginx/sbin/nginx"//Master Path program
pidf= "/usr/local/nginx/logs/nginx.pid"//pid storage Path
Case "$" in
Start
$PROG
;;
Stop
Kill-s QUIT $ (cat $PIDF)//terminate Nginx process based on PID
;;
Restart
$ stop
$ start
;;
Reload
Kill-s HUP $ (cat $PIDF)//overload configuration based on process number
;;
*)
echo "Usage: $ {start|stop|restart|reload}"
Exit 1//Abnormal exit, exit when error is entered
Esac
Exit 0

[[email protected] nginx-1.13.9]# chmod +x/etc/init.d/nginx//Give service script Execute permission
[[email protected] nginx-1.13.9]# chkconfig--add nginx//Add as System service
[Email protected] ~]# vi/usr/local/nginx/conf/nginx.conf
User Nginx Nginx; Remove the previous comment symbol, run the user, add the group, the Space plus the group name
Error_log Logs/error.log Info; Error log messages
Events {
Use Epoll; New this line defaults to using Select/poll, specifying the EPOLL model within the events module
Worker_connections 1024; Indicates that each worker process allows 1024 connections.
Log_format main//define log format remove the previous # number
CharSet Utf-8; Change Language support
Location ~/status {//Configuration statistics Module
Stub_status on;
Access_log off;
}//Added on the Error_page in the server module




[[Email protected] ~]# service Nginx restart
[[email protected] ~]# Cat/usr/local/nginx/logs/access.log//view number of connections

Enter Http:192.168.80.140/status in the browser

The current number of active connections, the number of connections processed, the number of successful TCP handshake, and requests processed.
The following configuration of the Nginx authorization authentication function
[email protected] ~]# Yum install-y httpd-tools
[[email protected] ~]# htpasswd-c/usr/local/nginx/passwd.db Jack//Generate user authentication file
[[email protected] ~]# chmod 400/usr/local/nginx/passwd.db//For security, change permissions and attribution
[Email protected] ~]# chown nginx/usr/local/nginx/passwd.db
[Email protected] ~]# vi/usr/local/nginx/conf/nginx.conf
Location/{
root HTML;
Index index.html index.htm;
Allow 192.168.80.0/24; Allow 192.168.80.0 Network segment connection
Deny all; Reject All
Auth_basic "Secret"; Add Authentication Configuration
auth_basic_user_file/usr/local/nginx/passwd.db; Specifying user authentication Files
}

[Email protected] ~]# nginx-t
[[Email protected] ~]# service Nginx restart
Enter 192.168.80.140 in the browser to verify:

Enter the user name and password we created:

The following configures the virtual host features:
[Email protected] ~]# vi/usr/local/nginx/conf/nginx.conf
server {//domain-based virtual host
Listen 80;
server_name www.lq1.com;
CharSet Utf-8;
Access_log Logs/lq1.access.log Main;
Location/{
ROOT/VAR/WWW/LQ1;
Index index.html index.htm;
Error_page 502 503 504/50x.html;
Location =/50x.html {
root HTML;
}
}
}
server {
Listen 80;
server_name www.lq3.com;
CharSet Utf-8;
Access_log Logs/lq3.access.log Main;
Location/{
ROOT/VAR/WWW/LQ3;
Index index.html index.htm;
Error_page 502 503 504/50x.html;
Location =/50x.html {
root HTML;
}
}

[Email protected] ~]# mkdir-p/var/www/lq1
[Email protected] ~]# MKDIR/VAR/WWW/LQ3
[Email protected] www]# CD lq1/
[Email protected] lq1]# VI index.html

[Email protected] lq1]# vi/var/www/lq3/index.html

[[Email protected] www]# service Nginx restart
Real machine authentication because the server does not set up DNS so go to the hosts file to do domain name resolution
C Disk--windows--system32--drivers--etc--hosts//Open Hosts Path

Then enter http://www.lq1.com and http://www.lq3.com in the browser, in the case of network disconnection

Installing the MySQL step is consistent with the lamp build process, and here is no explanation.
The command is as follows:
Yum-y install \
ncurses \
Ncurses-devel \
Bison \
CMake

Useradd-s/sbin/nologin MySQL

Tar XF mysql-boost-5.7.20.tar.gz
CD mysql-5.7.20/
CMake \
-dcmake_install_prefix=/usr/local/mysql \
-dmysql_unix_addr=/usr/local/mysql/mysql.sock \
-DSYSCONFDIR=/ETC \
-dsystemd_pid_dir=/usr/local/mysql \
-ddefault_charset=utf8 \
-DDEFAULT_COLLATION=UTF8_GENERAL_CI \
-dwith_innobase_storage_engine=1 \
-dwith_archive_storage_engine=1 \
-dwith_blackhole_storage_engine=1 \
-dwith_perfschema_storage_engine=1 \
-dmysql_datadir=/usr/local/mysql/data \
-dwith_boost=boost \
-dwith_systemd=1

Make && make install

Chown-r mysql.mysql/usr/local/mysql/can also be mysql:mysql

Vi/etc/my.cnf

[Client]
Port = 3306
Default-character-set=utf8
Socket =/usr/local/mysql/mysql.sock

[MySQL]
Port = 3306
Default-character-set=utf8
Socket =/usr/local/mysql/mysql.sock

[Mysqld]
user = MySQL
Basedir =/usr/local/mysql
DataDir =/usr/local/mysql/data
Port = 3306
Character_set_server=utf8
Pid-file =/usr/local/mysql/mysqld.pid
Socket =/usr/local/mysql/mysql.sock
Server-id = 1

Sql_mode=no_engine_substitution,strict_trans_tables,no_auto_create_user,no_auto_value_on_zero,no_zero_in_date, No_zero_date,error_for_division_by_zero,pipes_as_concat,ansi_quotes

Chown mysql:mysql/etc/my.cnf//change attribution, easy for program user to read

Echo ' path=/usr/local/mysql/bin:/usr/local/mysql/lib: $PATH ' >>/etc/profile
echo ' Export PATH ' >>/etc/profile
Source/etc/profile

cd/usr/local/mysql/

BIN/MYSQLD \
--initialize-insecure \//Initialize Database
--user=mysql \//Specify program user
--basedir=/usr/local/mysql \//Setting the base directory
--datadir=/usr/local/mysql/data//Set working directory

CP usr/lib/systemd/system/mysqld.service/usr/lib/systemd/system/
Systemctl Daemon-reload
Systemctl Start mysqld
NETSTAT-ANPT | grep 3306

Systemctl Enable Mysqld

mysqladmin-u root-p Password "abc123"//Set password for root account

Mysql-u root-p//Enter the database and enter the password you set before entering

Install PHP below
[[email protected] mysql]# yum-y install \//Installation dependency Package
Libjpeg \
Libjpeg-devel \
Libpng libpng-devel \
FreeType freetype-devel \
LIBXML2 \
Libxml2-devel \
Zlib zlib-devel \
Curl curl-devel \
OpenSSL Openssl-devel

[Email protected] ~]# tar xjvf php-7.1.10.tar.bz2-c/opt/
[Email protected] ~]# cd/opt/php-7.1.10/
[Email protected] php-7.1.10]#/configure--prefix=/usr/local/php--with-mysql-sock=/usr/local/mysql/mysql.sock-- With-mysqli--with-zlib--with-curl--with-gd--with-jpeg-dir--with-png-dir--with-freetype-dir--with-openssl-- Enable-mbstring--enable-xml--enable-session--enable-ftp--enable-pdo--enable-tokenizer--enable-zip--enable-fpm

[[email protected] php-7.1.10]# make && make install
[email protected] php-7.1.10]# CP Php.ini-development/usr/local/php/lib/php.ini
[Email protected] php-7.1.10]# Vi/usr/local/php/lib/php.ini
Mysqli.default_socket =/usr/local/mysql/mysql.sock
Date.timezone = Asia/shanghai


[Email protected] php-7.1.10]#/usr/local/php/bin/php-m

Configuring and Optimizing the FPM module://nginx processing Dynamic Web pages, requires PHP-FPM module
[Email protected] php-7.1.10]# cd/usr/local/php/etc/
[email protected] etc]# CP Php-fpm.conf.default php-fpm.conf
[Email protected] etc]# cd/usr/local/php/etc/php-fpm.d/
[email protected] php-fpm.d]# CP Www.conf.default www.conf

[Email protected] etc]# VI php-fpm.conf

[Email protected] etc]#/usr/local/php/sbin/php-fpm-c/usr/local/php/etc/php.ini
[Email protected] etc]# NETSTAT-ANPT | grep 9000

[Email protected] etc]# ln-s/usr/local/php/bin//usr/local/bin/
[[Email protected] etc]# PS aux | Grep-c "PHP-FPM"

Update Startup scripts
[Email protected] etc]# Vi/etc/init.d/nginx
#!/bin/bash
#chkconfig: 35 99 20//Run level 35, 99th open, 20th off
#description: Nginx Service Control Script
Prog= "/usr/local/nginx/sbin/nginx"
pidf= "/usr/local/nginx/logs/nginx.pid"
Prog_fpm= "/USR/LOCAL/PHP/SBIN/PHP-FPM"
Pidf_fpm= "/usr/local/php/var/run/php-fpm.pid"
Case "$" in
Start
$PROG
$PROG _FPM
;;
Stop
Kill-s QUIT $ (cat $PIDF)
Kill-s QUIT $ (cat $PIDF _fpm)
;;
Restart
$ stop
$ start
;;
Reload
Kill-s HUP $ (cat $PIDF)
;;
)
echo "Usage: $ {start|stop|restart|reload}"
Exit 1
Esac
Exit 0

[Email protected] lq]# vi/usr/local/nginx/conf/nginx.conf
Location ~. php$ {
root HTML;
Fastcgi_pass 127.0.0.1:9000;
Fastcgi_index index.php;
Fastcgi_param Script_filename/usr/local/nginx/html$fastcgi_script_name; Note Directory name
Include Fastcgi_params;
}

[Email protected] lq]# nginx-t
[Email protected] etc]# cd/usr/local/nginx/html/
[[Email protected] html]# VI index.php//edit Web Test file
<?php
Phpinfo ();
?>

Enter http://192.168.80.140/index.php in the browser

[Email protected] lq]# mysql-u root-p
CREATE DATABASE BBS; Create a Database BBS
GRANT all on BBS. To ' bbsadm ' @ '% ' identified by ' admin123 ';//give Bbsadm maximum permissions
GRANT all on BBS.
To ' bbsadm ' @ ' localhost ' identified by ' admin123 ';
Flush privileges; Refresh Permissions

[Email protected] lq]# vi/var/www/lq/index.php
<?php
$link =mysqli_connect (' 192.168.80.140 ', ' bbsadm ', ' admin123 ');
if ($link) echo "else echo "fail!!";
?>

[[Email protected] lq]# service Nginx restart
Enter http://192.168.80.140/index.php in the browser

The following installation Discuz forum
[email protected] ~]# Yum install-y unzip
[Email protected] ~]# Unzip discuz_x3.4_sc_utf8_0101.zip-d/tmp/
[Email protected] bbs]# cd/tmp/dir_sc_utf8/
[Email protected] dir_sc_utf8]# cp-r upload//usr/local/nginx/html/bbs
Put it into the Web root directory of Nginx.
[Email protected] dir_sc_utf8]# Cd/usr/local/nginx/html/bbs
[Email protected] bbs]# chown-r Root:nginx./config/
[Email protected] bbs]# chown-r Root:nginx./data/
[Email protected] bbs]# chown-r Root:nginx./uc_client/
[Email protected] bbs]# chown-r Root:nginx./uc_server/
[Email protected] bbs]# chmod-r 777./config/
[Email protected] bbs]# chmod-r 777./data/
[Email protected] bbs]# chmod-r 777./uc_client/
[Email protected] bbs]# chmod-r 777./uc_server/
Enter 192.168.80.140/bbs/install/index.php in the browser




In the browser, enter 192.168.80.140/bbs/index.php

centos7.4 Install the latest LNMP architecture settings grant access and build Discuz forum

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.