Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Centos 7 Building LNMP Architecture and deploying Discuz Forum

2025-03-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

I. LNMP architecture and application deployment

As we all know, LAMP platform is the most widely used web server architecture, in which "A" corresponds to the Apache HTTP Server of web service software. with the increasing use of Nginx in the working environment, LNMP (or LEMP) architecture is also favored by more and more Linux operation and maintenance engineers.

Just like building LAMP platform, building LNMP platform also requires Linux server, MySQL database, and PHP parsing environment. The distinction lies in the collaborative configuration of Nginx and PHP.

Preparatory work

One Centos 7 operating system

One Windows client

For images and software packages required by the case, please visit: https://pan.baidu.com/s/10wFG1YQaY2FTJKgMp1x0kw

Extraction code: rl3i

Second, construct the platform of LNMP website

Pre-deployment preparation

① mounts the Linux CD and copies the nginx dependency program to the / usr/src/ directory

[root@centos02 ~] # mount / dev/cdrom / mnt/mount: / dev/sr0 write protection, [root@centos02 ~] # cp / mnt/nginx-1.6.0.tar.gz / usr/src/ will be mounted read-only

② switches the LAMP disc and copies all the data under the mnt directory to the / usr/src/ directory

[root@centos02 ~] # umount / mnt/

[root@centos02 ~] # mount / dev/cdrom / mnt/mount: / dev/sr0 write protection, [root@centos02 ~] # cp / mnt/* / usr/src/ will be mounted read-only

③ switches to the operating system CD

[root@centos02 ~] # umount / mnt/

[root@centos02 ~] # mount / dev/cdrom / mnt/mount: / dev/sr0 write protection, which will be mounted read-only. 1. Deploy Nginx static website

For specific configuration and overview of Nginx, please visit the blog: Centos 7 deploy Nginx website service

[root@centos02 ~] # rm-rf / etc/yum.repos.d/CentOS-* [root@centos02 ~] # yum-y install pcre-devel zlib-devel [root@centos02 ~] # useradd-M-s / sbin/nologin nginx [root@centos02 ~] # tar zxvf / usr/src/nginx-1.6.0.tar.gz-C / usr/src/ [root@centos02 ~] # cd / usr/src/nginx-1.6.0/ [root@centos02 nginx-1.6.0] #. / configure-prefix=/usr/local/nginx-user=nginx-group=nginx-with-http_stub_status_module [root@centos02 nginx-1.6 .0] # make & & make install [root@centos02 ~] # ln-s / usr/local/nginx/sbin/* / usr/local/sbin/ [root@centos02 ~] # cp / usr/local/nginx/conf/nginx.conf / usr/local/nginx/conf/nginx.conf.bak [root@centos02 ~] # vim / usr/local/nginx/conf/nginx.conf 3 user nginx 4 worker_processes 1; 6 error_log logs/error.log;12 pid logs/nginx.pid;16 use epoll;17 worker_connections 1024 * 29 # access_log logs/access.log main;31 sendfile on;35 keepalive_timeout 65 * * 39 server {40 listen 80 * * 41 server_name localhost;44 charset utf-8;48 location / {49 root html 50 index index.html index.htm 51} 84} [root@centos02 ~] # nginx [root@centos02 ~] # netstat-anptu | grep nginx tcp 00 0.0.0.0 netstat 80 0.0.0.0 anptu * LISTEN 4663/nginx: master [root@centos02 ~] # vim / etc/init.d/nginx #! / bin/bash#chkconfig: 35 90 30#description:nginx serverPROG= "/ usr/local/nginx / sbin/nginx "PIDF=" / usr/local/nginx/logs/nginx.pid "case" $1 "instart) $PROG ; stop) kill-s QUIT $(cat $PIDF);; restart) $0 stop$0 start;;reload) kill 0s HUP $(cat $PIDF) *) echo "Usage:$0 (start | stop | restart | reload)" exit 1esacexit 0 [root@centos02 ~] # chmod + x / etc/init.d/nginx [root@centos02 ~] # chkconfig-- add nginx [root@centos02 ~] # chkconfig-- level 35 nginx on [root@centos02 ~] # / etc/init.d/nginx stop [root@centos02 ~] # / etc/init.d/nginx start [root@centos02 ~] # / etc/init.d/nginx restart

At this point, you can configure the client to configure the same network card as the server, the IP address and gateway of the same network segment, and visit the Nginx website

2. Deploy the domain name-based virtual host [root@centos02 ~] # yum-y install bind bind-chroot bind-utils [root@centos02 ~] # echo "> / etc/named.conf [root@centos02 ~] # vim / etc/named.conf options {listen-on port 53 {192.168.100.20;}; directory" / var/named ";} zone" benet.com "IN {type master File "benet.com.zone";} zone "accp.com" IN {type master; file "accp.com.zone" } [root@centos02 ~] # named-checkconf-z / etc/named.conf [root@centos02 ~] # vim / var/named/benet.com.zone $TTL 86400 @ SOA benet.com. Root.benet.com (2019112801 1H 15M 1W 1D) @ NS centos02.benet.com.centos02 A 192.168.100.20www A 192.168.100.20 [root@centos02 ~] # chmod + x / var/named/benet.com.zone [root@centos02 ~] # chown named:named / var / named/benet.com.zone [root@centos02 ~] # named-checkzone benet.com/ var/named/benet.com.zone zone benet.com/IN: loaded serial 2019112801OK [root@centos02 ~] # cp / var/named/benet.com.zone / var/named/accp.com.zone [root@centos02] # vim / var/named/accp.com.zone $TTL 86400 @ SOA accp.com. Root.accp.com (2019112801 1H 15M 1W 1D) @ NS centos02.accp.com.centos02 A 192.168.100.20www A 192.168.100.20 [root@centos02 ~] # named-checkzone accp.com / var/named/accp.com.zone [root@centos02 ~] # vim / etc/sysconfig/network-scripts/ Ifcfg-ens32DNS1=192.168.100.20 [root@centos02 ~] # systemctl restart network [root@centos02 ~] # systemctl start named [root@centos02 ~] # systemctl enable named [root@centos02 ~] # nslookup www.benet.com Server: 192.168.100.20Address: 192.168.100.20#53Name: www.benet.comAddress: 192.168.100.20 [root@centos02 ~] # nslookup www.accp.com Server: 192.168 .100.20Address: 192.168.100.20#53Name: www.accp.comAddress: 192.168.100.20 [root@centos02 ~] # mkdir-p / var/www/benetcom [root@centos02 ~] # mkdir-p / var/www/accpcom [root@centos02 ~] # echo "www.benet.com" > / var/www/benetcom/index.html [root@centos02 ~ ] # echo "www.accp.com" > / var/www/accpcom/index.html [root@centos02 ~] # vim / usr/local/nginx/conf/nginx.conf server {listen www.benet.com:80 Server_name www.benet.com; charset utf-8; access_log logs/www.benet.com.access.log; error_log logs/www.benet.com.error.log; location / {root / var/www/benetcom/ Index index.html;}} server {listen www.accp.com:80; server_name www.accp.com; charset utf-8; access_log logs/www.accp.com.access.log Error_log logs/www.accp.com.error.log; location / {root / var/www/accpcom/; index index.html }} [root@centos02 ~] # nginx-t nginx: the configuration file / usr/local/nginx/conf/nginx.conf syntax is oknginx: configuration file / usr/local/nginx/conf/nginx.conf test is successful [root@centos02 ~] # systemctl restart named [root@centos02 ~] # / etc/init.d/nginx restart

Add the DNS address to the client and access the domain name.

3. Deploy MySQL database

Specific configuration and overview of MySQL database, please visit the blog: Centos install MySQL database

[root@centos02 ~] # groupadd mysql [root@centos02 ~] # useradd-M-s / sbin/nologin-g mysql mysql [root@centos02 ~] # yum-y install ncurses-devel [root@centos02] # tar zxvf / usr/src/cmake-2.8.6.tar.gz-C / usr/src/ [root@centos02 ~] # cd / usr/src/cmake-2.8.6/ [root@centos02 cmake-2.8.6] #. / configure & & gmake & & gmake install [root@centos02] # tar zxvf / usr/src/mysql-5.5.22.tar.gz-C / usr/src/ [root@centos02 mysql-5.5.22] # cmake-DCMAKE_INSTALL_PREFIX=/usr/local/mysql-DDEFAULT_CHARSET=utf8-DDEFAULT_COLLATION=utf8_general_ci-DWITH_EXTRA_CHARSETS=all-DSYSCONFDIR=/etc [root@centos02 mysql-5. 5.22] # make & & make install [root@centos02 mysql-5.5.22] # cp support-files/my-medium.cnf / etc/my.cnf cp: is "/ etc/my.cnf" overwritten? Y [root@centos02 mysql-5.5.22] # cp support-files/mysql.server / etc/init.d/mysqld [root@centos02 ~] # chmod + x / etc/init.d/mysqld [root@centos02 ~] # chkconfig-- add mysqld [root@centos02 ~] # chkconfig-level 35 mysqld on [root@centos02 ~] # vim / etc/profile PATH=$PATH:/usr/local/mysql/bin/ [root@centos02] # source / etc/profile [root@centos02 ~] # / usr/local/mysql/scripts/mysql_install_db-user=mysql-basedir=/usr/local/mysql-datadir=/usr/local/mysql/data [root@centos02 ~] # systemctl start mysqld [root@centos02 ~] # systemctl enable mysqld [root@centos02 ~] # mysqladmin-uroot password New password: Confirm new password: [root@centos02 ~] # mysql-uroot-ppwd@123 mysql > show databases +-+ | Database | +-+ | information_schema | | mysql | | performance_schema | | test | +-+ 4 rows in set (0.00 sec) 4. Deploy PHP parsing environment 1) configure php dependency program [root@centos02] # yum-y install gd libxml2-devel libjpeg-devel libpng-devel [root@centos02 ~] # tar zxvf / usr/src/php-5.3.28.tar.gz-C / usr/src/ [root@centos02 ~] # cd / usr/src/php-5.3.28/ [root@centos02 php-5.3.28] # / configure-- prefix=/usr/local/php-- with-config-file-path=/usr/local/php-- with-mysql=/usr/local/mysql/-- with-mysqli=/usr/local/mysql/bin/mysql_config-- with-gd-- with-zlib-- with-jpeg-dir=/usr/lib-- enable-mbstring-- enable-fpm [root@centos02 php-5.3.28] # make & & make install [root@centos02 php-5.3 .28] # ls-ld / usr/local/php/ drwxr-xr-x 10 root root 101 November 28 20:04 / usr/local/php/2) generate PHP configuration file optimizer execution location [root@centos02 php-5.3.28] # cp php.ini-production / usr/local/php/php.ini [root@centos02 ~] # ln-s / usr/local/php/sbin/* / usr/local/sbin/ [root@centos02 ~] # ln-s / usr/local/php/bin/* / usr/local/bin/ [root@centos02 ~] # tar zxvf / usr/src/zendguardloader-php-5.3-linux-glibc23-i386.tar.gz-C / usr/src/ [root@centos02 ~] # mv / usr/src/ZendGuardLoader-php-5.3-linux-glibc23-i386/php-5.3.x/ZendGuardLoader.so / usr / local/php/lib/php/ [root@centos02 ~] # vim / usr/local/php/php.ini zend_extension=/usr/local/php/lib/php/ZendGuardLoader.sozend_loader.enable=13) configure php-fpm to support loading dynamic website [root@centos02 ~] # cp / usr/local/php/etc/php-fpm.conf.default / usr/local/php/etc/php-fpm.conf [root@centos02 ~] # vim / usr/local / php/etc/php-fpm.conf 26 pid = run/php-fpm.pid141 user = nginx142 group = nginx [root@centos02 ~] # / usr/local/sbin/php-fpm [root@centos02 ~] # netstat-anptu | grep 9000 tcp 00 127.0.0.1 run/php-fpm.pid141 user 9000 0.0.0.0 grep * LISTEN 127332/php-fpm: mas4) configuration nginx main configuration file supports php Configure php to www.benet.com virtual host [root@centos02 ~] # vim / usr/local/nginx/conf/nginx.conf location ~\ .php$ {root / var/www/benetcom Fastcgi_pass 127.0.0.1 9000; fastcgi_index index.php; include fastcgi.conf } [root@centos02 ~] # nginx-t nginx: the configuration file / usr/local/nginx/conf/nginx.conf syntax is oknginx: configuration file / usr/local/nginx/conf/nginx.conf test is successful [root@centos02 ~] # vim / var/www/benetcom/index.php [root@centos02 ~] # / etc/init.d/nginx restart

At this point, the client can access the PHP test page

Build open source forum based on LNMP architecture 1, modify Nginx main configuration file, configure php to www.accp.com virtual host to support php-fpm [root@centos02 ~] # vim / usr/local/nginx/conf/nginx.conf 104 server {105 listen www.accp.com:80;106 server_name www.accp.com;107 charset utf-8 108 access_log logs/www.accp.com.access.log;109 error_log logs/www.accp.com.error.log;110 location / {111 root / var/www/accpcom/;112 index index.html index.php 113} 114 location ~\. Php$ {115 root / var/www/accpcom;116 fastcgi_pass 127.0.0.1 119} 2. Upload the source code package of the forum to the server

3 、 Configure the forum [root@centos02 ~] # unzip Discuz_X3.2_SC_UTF8.zip [root@centos02 ~] # ls anaconda-ks.cfg Discuz_X3.2_SC_UTF8.zip readme utilityDiscuz_X3.2_SC_UTF8 initial-setup-ks.cfg upload [root@centos02 ~] # mv. / upload/* / var/www/accpcom/ [root@centos02 ~] # chmod-R + x / var/www/accpcom/ [root@centos02 ~] # chown-R nginx:nginx / var/www/accpcom/ [root@centos02 ~] # mysql-uroot-ppwd@123mysql > create database bbs Mysql > grant all on bbs.* to bbs@localhost identified by 'pwd@123'; [root@centos02 ~] # / etc/init.d/nginx restart 4, client visits forum website

1) enter www.accp.com/install in the client browser to access, and click I agree to start the installation

2) check the installation environment

3) Select a new installation, and click next

4) set the user and password of the database

5) wait for the installation to complete

6) delete the default home page of the accp.com website

[root@centos02 ~] # rm-rf / var/www/accpcom/index.html

7) client access

8) Log in to the backend management website

At this point, the forum has been deployed.

-this is the end of this article. Thank you for reading-

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report