1. Demonstration environment:
IP |
installed package |
Version |
192.168.1.144 |
nginx epel )_ |
1.10.2 |
php |
5.3.3 |
|
php-fpm ( FastCGI Process Manager) |
||
php-mysql ( the driver that php needs to use when connecting to mysql ) |
||
192.168.1.145 |
MySQL-server-5.6.39-1.el6.x86_64.rpm MySQL-client-5.6.39-1.el6.x86_64.rpm MySQL-devel-5.6.39-1.el6.x86_64.rpm MySQL-shared-5.6.39-1.el6.x86_64.rpm MySQL-shared-compat-5.6.39-1.el6.x86_64.rpm |
5.6.39 |
Remarks: The version of mysql installed by yum in CentOS 6.9 is 5.1.73 by default . Here , the rpm package of version 5.6.39 is used to install mysql
2. Build LNMP :
1. Preparation before installation:
(1) Proofreading server time
(2) Configure the epel source
2、安装nginx:# yum -y install nginx # service nginx start # ss -tunlp | grep :80
Configuration file:
Ø Main configuration file: /etc/nginx/nginx.conf
Ø Auxiliary configuration files: /etc/nginx/* , /etc/nginx/conf.d
3. Install php : # yum -y install php , configuration file: /etc/php.ini
4. Install and configure php-fpm :
# yum -y install php-fpm
# vim /etc/php-fpm.d/www.conf , modify the values of the following parameters:
listen = 192.168.1.144:9000 // The address port that php-fpm listens to
listen.allowed_clients = 192.168.1.144 // The FastCGI client address that is allowed to connect
user = nginx
group = nginx
# service php-fpm start
# ss -tunlp | grip: 9000
Configuration file:
Ø Main configuration file: /etc/php-fpm.conf
Ø Auxiliary configuration file: /etc/php-fpm.d/www.conf
5. Install and configure mysql :
# rpm -qa | grep -i mysql // Check whether the old version of mysql related components are installed
# yum -y remove mysql-libs*
// Switch to store MySQL-client-5.6.39-1.el6.x86_64.rpm , MySQL-server-5.6.39-1.el6.x86_64.rpm , MySQL-shared-compat-5.6.39-1.el6 .x86_64.rpm , MySQL-devel-5.6.39-1.el6.x86_64.rpm , MySQL-shared-5.6.39-1.el6.x86_64.rpm directory
# yum -y install *.rpm
# find / -name my*.cnf
# cp /usr/share/mysql/my-default.cnf /etc/my.cnf //mysql configuration file: /etc/my.cnf
# find / -name mysql.server
# cp /usr/share/mysql/mysql.server /etc/init.d/mysqld
# service mysqld start
# ss -tunlp | grip: 3306
# cat /root/.mysql_secret // View the random password of the root user of the mysql database
// Modify the mysql database root user password to 123456 , delete anonymous users, delete the test database, and reload the authorization table
# mysql_secure_installation
# mysql -uroot -p
mysql> grant all on *.* to 'root'@'192.168.%.%' identified by '123456'; // Authorize root user to log in remotely
mysql> flush privileges;
6. Install php-mysql : # yum -y install php-mysql
7. Configure nginx to support php :
# cd /etc/nginx/conf.d
# cp default.conf default.conf.bak
# vim default.conf
# service nginx reload
# service php-fpm restart
3. Test LNMP :
# cd /usr/share/nginx/html
# vim index.php
Enter http://192.168.1.144/index.php in the browser :
Stop mysql on 192.168.1.145 : # service mysqld stop
The communication between mysql and php is normal
Visit http://192.168.1.144
Fourth, install and configure Discuz :
Discuz is a community-based professional website building platform launched by Comsenz , a subsidiary of Tencent . The platform ( Open Platform ) is fully integrated to help the website achieve one-stop service. The download address is http://www.discuz.net/forum-10-1.html , here Discuz_X3.4_SC_UTF8.zip is used as an example.
# yum -y install unzip
# unzip -q Discuz_X3.4_SC_UTF8.zip
# cp -r upload/ /usr/share/nginx/html
# cd /usr/share/nginx/html/upload
# chmod -R 777 config/ data/ uc_client/ uc_server/
# vim config/config_global_default.php
# vim config/config_ucenter_default.php
# mysql -uroot -p
mysql> create database dcdb;
mysql> grant all on dcdb.* to 'dcuser'@'%' identified by "123456";
mysql> flush privileges;
# mysql -udcuser -p
mysql> show databases;
Modify the nginx configuration file and add index.php after the index parameter :
# vim /etc/nginx/conf.d/default.conf
location / {
index index.php index.html index.htm;
}
# service nginx reload
Enter http://192.168.1.144/upload/install/ in the browser
Click "I Agree":
Check the installation environment, after all pass, click "Next":
Select "New installation of Discuz! X (including UCenter Server )", and click "Next":
Fill in the database information and administrator information, and click "Next":
Click "Your forum has been installed, click here to visit":
You can log in with the admin account in the upper right corner :
Click "Management Center" in the upper right corner, and delete the installation page according to the prompts:
# rm -rf /usr/share/nginx/html/upload/install/index.php
# cd /usr/share/nginx/html
# mv upload/ discuz
Forum front desk login address http://192.168.1.144/discuz/
Forum background management address http://192.168.1.144/discuz/admin.php