LNMP平台服务简介、部署及应用

本文涉及的产品
云数据库 RDS MySQL Serverless,0.5-2RCU 50GB
简介: LNMP平台服务简介、部署及应用

一、LNMP简介


(1)LNMP的组成



(2)LNMP和LAMP的区别


  • 使用的网站服务不同,LNMP使用Nginx,LAMP使用Apache
  • 在LAMP中PHP是当作Apache的一个模块来使用的,而在LNMP中PHP是当作一个独立进程来使用的(即PHP_FPM)


(3)单服务器中Nginx与PHP的工作原理


  • FastCGI将Http Server和动态脚本语言分离开来
  • Ngnix专门处理静态请求,转发动态请求
  • PHP/PHP_FPM专门解析Nginx转发过来的动态请求


(4)LNMP平台的构建步骤


(1) 安装Ngnix网站服务

(2) 安装Mysql数据库

(3) 安装PHP解析环境


  • 启用FPM(FastCGI Process Manager,FastCGI进程管理器)模块


(4) 配置Ngnix支持PHP环境


——第一步和第二步没有严格要求——


二、部署LNMP平台


本次实验使用CentOS7的操作系统


(1)安装Nginx网站服务


******(1)安装必要组件
[root@centos7-007 ~]# mount /dev/cdrom /media/cdrom/
mount: /dev/sr0 写保护,将以只读方式挂载
[root@centos7-007 ~]# yum -y install pcre-devel zlib-devel
。。。。。。
完毕!
******(2)创建nginx的用户
[root@centos7-007 ~]# useradd -M -s /sbin/nologin nginx
******(3)上传源码包,配置、编译、并安装
[root@centos7-007 ~]# ll
总用量 964
-rw-------. 1 root root   1220 9月   3 18:16 anaconda-ks.cfg
-rw-r--r--  1 root root 980831 1月  27 23:03 nginx-1.12.0.tar.gz
[root@centos7-007 ~]# tar xf nginx-1.12.0.tar.gz -C /usr/src/
[root@centos7-007 ~]# cd /usr/src/nginx-1.12.0/
[root@centos7-007 nginx-1.12.0]#  ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_stub_status_module
—————————————————————————————————————华丽分割线———————————————————————————————————————
--with-http_stub_status_module   支持状态统计,便于查看服务器的连接信息
—————————————————————————————————————————————————————————————————————————————————————
[root@centos7-007 nginx-1.12.0]# make && make install
******(4)验证安装
[root@centos7-007 nginx-1.12.0]# ls /usr/local/nginx/
conf  html  logs  sbin
******(5)创建软连接,优化执行路径
[root@centos7-007 nginx-1.12.0]# ln -s /usr/local/nginx/sbin/nginx  /usr/local/sbin/
[root@centos7-007 nginx-1.12.0]# ls -l /usr/local/sbin/ |grep nginx
lrwxrwxrwx 1 root root 27 1月  27 23:06 nginx -> /usr/local/nginx/sbin/nginx
******(6)编辑配置文件,可以先备份一份
[root@centos7-007 nginx-1.12.0]# mv /usr/local/nginx/conf/nginx.conf /usr/local/nginx/conf/nginx.conf.bak
[root@centos7-007 nginx-1.12.0]# vim /usr/local/nginx/conf/nginx.conf (重新写一份配置文件)
写入
worker_processes  1;
events {
    use epoll;
    worker_connections  4096;
}
http {
    include       mime.types;
    default_type  application/octet-stream;
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';
    access_log  logs/access.log  main;
    sendfile        on;
    keepalive_timeout  65;
    server {
        listen       80;
        server_name  www.benet.com;
        charset utf-8;
        location / {
            root   html;
            index  index.html index.php;
        }
      location /status {
          stub_status on;
          access_log off;
      }    
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
}
保存退出
******(7)检查配置文件语法是否正确
[root@centos7-007 nginx-1.12.0]# nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok (ok说明语法正确)
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
******(8)安装killall命令
[root@centos7-007 nginx-1.12.0]# yum -y install psmisc
。。。。。。
完毕!
******(9)编写nginx的启动脚本,添加nginx为系统服务
[root@centos7-007 nginx-1.12.0]# vim /etc/init.d/nginx
写入
#!/bin/bash
# chkconfig: - 99 20
# description: Nginx Server Control Script
NP="/usr/local/nginx/sbin/nginx"
NPF="/usr/local/nginx/logs/nginx.pid"
case "$1" in 
  start)
    $NP;
    if [ $? -eq 0 ] 
    then
      echo "nginx is starting!! "
    fi
  ;;
  stop)
    kill -s QUIT $(cat $NPF)
    if [ $? -eq 0 ]
    then
    echo "nginx is stopping!! "
    fi
  ;;
  restart)
    $0 stop
    $0 start
  ;;
  reload)
    kill -s HUP $(cat $NPF)
    if [ $? -eq 0 ]
    then
      echo "nginx config file is reload! "
    fi
  ;;
  *)
    echo "Usage: $0 {start|stop|restart|reload}"
    exit 1
esac
exit 0
保存退出
[root@centos7-007 nginx-1.12.0]# chmod +x /etc/init.d/nginx  (添加可执行权限)
[root@centos7-007 nginx-1.12.0]# chkconfig --add nginx       (添加nginx为系统服务)
******(10)测试nginx是否能正常使用
[root@centos7-007 nginx-1.12.0]# /etc/init.d/nginx start  (开启)
nginx is starting!! 
[root@centos7-007 nginx-1.12.0]# curl 127.0.0.1  (访问本地循环地址,发现可以正常访问)
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
    body {
        width: 35em;
        margin: 0 auto;
        font-family: Tahoma, Verdana, Arial, sans-serif;
    }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>
<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>
<p><em>Thank you for using nginx.</em></p>
</body>
</html>
******(11)关闭nginx
[root@centos7-007 nginx-1.12.0]# /etc/init.d/nginx stop  (关闭)
nginx is stopping!! 
[root@centos7-007 nginx-1.12.0]# netstat -anpt | grep nginx  (查看端口确认已经关闭)
[root@centos7-007 nginx-1.12.0]# cd
[root@centos7-007 ~]# 
至此Ngnix网站服务搭建完成

(2)安装Mysql数据库

******(1)安装必要组件
[root@centos7-007 ~]# yum -y install ncurses-devel
******(2)上传cmake源码包,安装基础环境
[root@centos7-007 ~]# ll
总用量 6420
-rw-------. 1 root root    1220 9月   3 18:16 anaconda-ks.cfg
-rw-r--r--  1 root root 5583905 1月  27 23:19 cmake-2.8.6.tar.gz
-rw-r--r--  1 root root  980831 1月  27 23:03 nginx-1.12.0.tar.gz
[root@centos7-007 ~]# tar xf cmake-2.8.6.tar.gz -C /usr/src/
[root@centos7-007 ~]# cd /usr/src/cmake-2.8.6/
[root@centos7-007 cmake-2.8.6]#  ./configure &&gmake &&gmake install 
等待安装完成
[root@centos7-007 cmake-2.8.6]# cd
******(3)上传mysql源码包,进行配置、编译、安装
[root@centos7-007 ~]# ll
总用量 37860
-rw-------. 1 root root     1220 9月   3 18:16 anaconda-ks.cfg
-rw-r--r--  1 root root  5583905 1月  27 23:19 cmake-2.8.6.tar.gz
-rw-r--r--  1 root root 32192348 1月  27 23:22 mysql-5.6.36.tar.gz
-rw-r--r--  1 root root   980831 1月  27 23:03 nginx-1.12.0.tar.gz
[root@centos7-007 ~]# tar xf mysql-5.6.36.tar.gz -C /usr/src/
[root@centos7-007 ~]# cd /usr/src/mysql-5.6.36/
[root@centos7-007 mysql-5.6.36]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS=all -DSYSCONFDIR=/etc && make && make install
等待安装完成
[root@centos7-007 mysql-5.6.36]# cd
******(4)到了这一步得先解决一下cp -f 强制复制依旧提示的问题,原因是因为cp命令的别名默认为cp -i所导致的
[root@centos7-007 mysql-5.6.36]# which cp
alias cp='cp -i'
  /usr/bin/cp
[root@centos7-007 mysql-5.6.36]# unalias cp
[root@centos7-007 mysql-5.6.36]# which cp
/usr/bin/cp
******(5)添加mysql为系统服务,创建用户、组,优化执行路径等
[root@centos7-007 mysql-5.6.36]# cp -f support-files/my-default.cnf
 /etc/my.cnf
[root@centos7-007 mysql-5.6.36]# cp support-files/mysql.server /etc/rc.d/init.d/mysqld
[root@centos7-007 mysql-5.6.36]# chmod +x /etc/rc.d/init.d/mysqld 
[root@centos7-007 mysql-5.6.36]# chkconfig --add mysqld
[root@centos7-007 mysql-5.6.36]# echo "PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile
[root@centos7-007 mysql-5.6.36]# source /etc/profile
[root@centos7-007 mysql-5.6.36]# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/usr/local/mysql/bin
[root@centos7-007 mysql-5.6.36]# groupadd mysql
[root@centos7-007 mysql-5.6.36]# useradd -M -s /sbin/nologin mysql -g mysql
[root@centos7-007 mysql-5.6.36]# chown -R mysql:mysql /usr/local/mysql/
[root@centos7-007 mysql-5.6.36]# cd /usr/local/mysql/scripts/
[root@centos7-007 scripts]# /usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql
[root@centos7-007 scripts]# cd
******(6)开启mysql,并且测试是否可以正常使用
[root@centos7-007 ~]# /etc/rc.d/init.d/mysqld start
Starting MySQL.Logging to '/usr/local/mysql/data/centos7-007.err'.
 SUCCESS! 
[root@centos7-007 etc]# mysqladmin -u root -p password 123 (配置密码为123)
[root@centos7-007 ~]# mysql -u root 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.36 Source distribution
Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> exit
Bye
******(7)关闭mysql
[root@centos7-007 ~]# /etc/rc.d/init.d/mysqld stop
Shutting down MySQL.. SUCCESS! 
[root@centos7-007 ~]# netstat -anpt | grep 3306 (检查mysql端口查看是否已经关闭)

(3)安装PHP解析环境

******(1)安装必要组件
[root@centos7-007 ~]# yum -y install libxml2-devel gd zlib-devel libjpeg-devel libpng-devel
。。。。。。
完毕!
******(2)上传PHP源码包,进行配置、编译、安装
[root@centos7-007 ~]# ll
总用量 55232
-rw-------. 1 root root     1220 9月   3 18:16 anaconda-ks.cfg
-rw-r--r--  1 root root  5583905 1月  27 23:19 cmake-2.8.6.tar.gz
-rw-r--r--  1 root root 32192348 1月  27 23:22 mysql-5.6.36.tar.gz
-rw-r--r--  1 root root   980831 1月  27 23:03 nginx-1.12.0.tar.gz
-rw-r--r--  1 root root 17785731 1月  27 23:48 php-5.5.38.tar.gz
[root@centos7-007 ~]# tar xf php-5.5.38.tar.gz -C /usr/src/
[root@centos7-007 ~]# cd /usr/src/php-5.5.38/
[root@centos7-007 php-5.5.38]#  ./configure --prefix=/usr/local/php5 --with-gd --with-zlib --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-config-file-path=/usr/local/php5 --enable-mbstring --enable-fpm --with-jpeg-dir=/usr/lib && make && make install
******(3)确认安装结果
[root@centos7-007 php-5.5.38]# ls /usr/local/php5/
bin  etc  include  lib  php  sbin  var
******(4)复制ini文件,优化执行路径
[root@centos7-007 php-5.5.38]# cp php.ini-development /usr/local/php5/php.ini
[root@centos7-007 php-5.5.38]# ln -s /usr/local/php5/bin/* /usr/local/bin/
[root@centos7-007 php-5.5.38]# ln -s /usr/local/php5/sbin/* /usr/local/sbin/
[root@centos7-007 php-5.5.38]# cd
******(5)安装ZendGuardLoader,上传源码包
[root@centos7-007 ~]# ll
总用量 55888
-rw-------. 1 root root     1220 9月   3 18:16 anaconda-ks.cfg
-rw-r--r--  1 root root  5583905 1月  27 23:19 cmake-2.8.6.tar.gz
-rw-r--r--  1 root root 32192348 1月  27 23:22 mysql-5.6.36.tar.gz
-rw-r--r--  1 root root   980831 1月  27 23:03 nginx-1.12.0.tar.gz
-rw-r--r--  1 root root 17785731 1月  27 23:48 php-5.5.38.tar.gz
-rw-r--r--  1 root root   668812 1月  28 01:59 zend-loader-php5.5-linux-x86_64_update1.tar.gz
[root@centos7-007 zend-loader-php5.5-linux-x86_64]# ls  (有三个文件)
opcache.so  README.txt  ZendGuardLoader.so
[root@centos7-007 zend-loader-php5.5-linux-x86_64]# cp ZendGuardLoader.so /usr/local/php5/lib/php/
[root@centos7-007 zend-loader-php5.5-linux-x86_64]# cd
******(6)编写刚刚复制的ini文件
[root@centos7-007 ~]# cat <<aaa>> /usr/local/php5/php.ini  (在末尾添加两行)
> zend_extension=/usr/local/php5/lib/php/ZendGuardLoader.so
> zend_loader.enable=1
> aaa
******(7)配置Nginx支持PHP
[root@centos7-007 ~]# cd /usr/local/php5/etc/
[root@centos7-007 etc]# useradd -M -s /sbin/nologin php  (创建php用户)
[root@centos7-007 etc]# vim php-fpm.conf   (创建新文件)
写入
[global]
pid = run/php-fpm.pid
[www]
listen = 127.0.0.1:9000
user = php
group = php
pm = dynamic
pm.max_children = 50
pm.start_servers = 20
pm.min_spare_servers = 5
pm.max_spare_servers = 35 
保存退出
******(8)测试php-fpm是否能够正常启动
[root@centos7-007 etc]# /usr/local/php5/sbin/php-fpm 
[root@centos7-007 etc]# netstat -anpt | grep php
tcp        0      0 127.0.0.1:9000          0.0.0.0:*               LISTEN      15245/php-fpm: mast 
[root@centos7-007 etc]# killall -9 php-fpm  (强制关闭php-fpm)
[root@centos7-007 etc]# netstat -anpt | grep php
******(9)编写LNMP的启动脚本,并且添加为系统服务
[root@centos7-007 etc]# vim /etc/init.d/lnmp
写入
#!/bin/bash
# chkconfig: 35 95 30
# description: This script is for LNMP Management!
NGF=/usr/local/nginx/sbin/nginx
NGP=/usr/local/nginx/logs/nginx.pid
FPMF=/usr/local/php5/sbin/php-fpm
FPMP=/usr/local/php5/var/run/php-fpm.pid
case $1 in 
   start)
      $NGF &&echo "nginx is starting! "
      $FPMF && echo "php-fpm is starting! "
   ;;
   stop)
      kill -QUIT $(cat $NGP) &&echo "nginx is stoped! "
      kill -QUIT $(cat $FPMP) &&echo "php-fpm is stoped! "
   ;;
   restart)
      $0 stop
      $0 start
   ;;
   reload)
      kill -HUP $(cat $NGP) 
      kill -HUP $(cat $FPMP)
   ;;
   status)
      netstat -utpln |grep nginx &>/dev/null 
      if [  $? -eq 0 ]
      then
         echo "nginx is running! "
      else
         echo "nginx is not running! "
      fi
      netstat -upltn |grep php-fpm &>/dev/null 
      if [ $? -eq 0 ]
      then
         echo "php-fpm is runing! "
      else
         echo "php-fpm is not running! "
      fi
   ;;
   *)
      echo "Usage $0 {start|stop|status|restart}"
      exit 1
   ;;
esac
exit 0
保存退出
[root@centos7-007 etc]# chmod  +x /etc/init.d/lnmp   (给可执行权限)
[root@centos7-007 etc]# chkconfig --add lnmp   (添加为系统服务)

(4)配置Nginx支持php


******(1)确保php-fpm、Nginx服务已经关闭
[root@centos7-007 etc]# netstat -anpt | grep nginx
[root@centos7-007 etc]# netstat -anpt | grep php-fpm
******(2)利用刚刚写的lnmp脚本同时启动php-fpm、nginx
[root@centos7-007 etc]# systemctl start lnmp
******(3)查看状态,发现nginx已经启动master和worker进程,php-fpm已经启动master进程和20个工作进程
[root@centos7-007 etc]# systemctl status lnmp
● lnmp.service - SYSV: This script is for LNMP Management!
   Loaded: loaded (/etc/rc.d/init.d/lnmp; bad; vendor preset: disabled)
   Active: active (running) since 四 2021-01-28 02:10:34 CST; 53s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 15304 ExecStart=/etc/rc.d/init.d/lnmp start (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/lnmp.service
           ├─15306 nginx: master process /usr/local/nginx/sbin/n...
           ├─15308 nginx: worker process
           ├─15309 php-fpm: master process (/usr/local/php5/etc/...
           ├─15310 php-fpm: pool www
           ├─15311 php-fpm: pool www
           ├─15312 php-fpm: pool www
           ├─15313 php-fpm: pool www
           ├─15314 php-fpm: pool www
           ├─15315 php-fpm: pool www
           ├─15316 php-fpm: pool www
           ├─15317 php-fpm: pool www
           ├─15318 php-fpm: pool www
           ├─15319 php-fpm: pool www
           ├─15320 php-fpm: pool www
           ├─15321 php-fpm: pool www
           ├─15322 php-fpm: pool www
           ├─15323 php-fpm: pool www
           ├─15324 php-fpm: pool www
           ├─15325 php-fpm: pool www
           ├─15326 php-fpm: pool www
           ├─15327 php-fpm: pool www
           ├─15328 php-fpm: pool www
           └─15329 php-fpm: pool www
1月 28 02:10:34 centos7-007 systemd[1]: Starting SYSV: This scr...
1月 28 02:10:34 centos7-007 lnmp[15304]: nginx is starting!
1月 28 02:10:34 centos7-007 lnmp[15304]: php-fpm is starting!
1月 28 02:10:34 centos7-007 systemd[1]: Started SYSV: This scri...
Hint: Some lines were ellipsized, use -l to show in full.
******(4)编辑nginx服务的主配置文件,配置php解析
———————————————————————————————————华丽分割线————————————————————————————————————
有两种方式:
第一种:本地服务器php解析(本次实验使用本地解析)
在配置文件中修改为:(直接server以下全部修改)
   server {
    listen 80;
    server_name 域名;
    charset utf-8;
    access_log logs/日志名称.access.log;
    location / {
     root /usr/local/nginx/html/网页目录;
     index index.html index.php;
       }
    location ~ \.php$ {
            root /usr/local/nginx/html/网页目录;
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_index index.php;
            include fastcgi.conf;
        }
     }
第二种:转发给其他服务器去处理(如果是转发的话,那么目标主机是需要搭建php的)
修改配置文件为
location ~ \.php$ {
      proxy_pass http://目标主机ip:80;
        }
————————————————————————————————————————————————————————————————————————————————
[root@centos7-007 etc]# vim /usr/local/nginx/conf/nginx.conf
。。。。。。
 14     keepalive_timeout  65;
 15  server {
 16     listen 80;
 17     server_name www.benet.com;
 18     charset utf-8;
 19     access_log logs/benet.access.log;
 20     location / {
 21      root /usr/local/nginx/html/benet;
 22      index index.html index.php;
 23        } 
 24         
 25     location ~ \.php$ {
 26             root /usr/local/nginx/html/benet;
 27             fastcgi_pass 127.0.0.1:9000;
 28             fastcgi_index index.php;
 29             include fastcgi.conf;
 30         }
 31 
 32 
 33      }
 34 }
 35 
。。。。。。
保存退出
******(5)测试配置文件语句是否正确
[root@centos7-007 etc]# nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok (显示ok说明语句正确)
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
******(6)创建测试php网页
[root@centos7-007 etc]# mkdir /usr/local/nginx/html/benet  (创建目录,这个和配置文件中的网页目录名称要一致)
[root@centos7-007 etc]# vim /usr/local/nginx/html/benet/test.php (创建php页面)
写入
<?php
$link=mysqli_connect('localhost','root','123');  (这里的mysql密码要和MySQL的一致)
if($link) echo "<h1>恭喜你可以成功连接MySQL数据库啦</h1>";
mysqli_close($link);
?>
保存退出
******(7)利用LNMP的启动脚本,重新启动nginx和php-fpm
[root@centos7-007 etc]# /etc/init.d/lnmp restart
nginx is stoped! 
php-fpm is stoped! 
nginx is starting! 
php-fpm is starting! 


测试页面,发现可以正常访问,至此LNMP平台搭建完成(因为php页面写的变量是连接数据库,所以这里标语写这个)


20210127184308592.png


三、LNMP应用——discuz社区论坛

******安装相应组件zip,并且上传discuz的压缩包(因为这个压缩包是.zip结尾的,所以要使用相应的解压软件去解压)
[root@centos7-007 etc]# yum -y install unzip
[root@centos7-007 etc]# cd
[root@centos7-007 ~]# ll
总用量 66556
-rw-------. 1 root root     1220 9月   3 18:16 anaconda-ks.cfg
-rw-r--r--  1 root root  5583905 1月  27 23:19 cmake-2.8.6.tar.gz
-rw-r--r--  1 root root 10922155 1月  28 02:46 Discuz_X3.3_SC_UTF8.zip
-rw-r--r--  1 root root 32192348 1月  27 23:22 mysql-5.6.36.tar.gz
-rw-r--r--  1 root root   980831 1月  27 23:03 nginx-1.12.0.tar.gz
-rw-r--r--  1 root root 17785731 1月  27 23:48 php-5.5.38.tar.gz
drwxrwxrwx  2 root root       68 11月 29 2016 zend-loader-php5.5-linux-x86_64
-rw-r--r--  1 root root   668812 1月  28 01:59 zend-loader-php5.5-linux-x86_64_update1.tar.gz
******(2)解压压缩包
[root@centos7-007 ~]# unzip Discuz_X3.3_SC_UTF8.zip 
[root@centos7-007 ~]# ll
总用量 66560
-rw-------.  1 root root     1220 9月   3 18:16 anaconda-ks.cfg
-rw-r--r--   1 root root  5583905 1月  27 23:19 cmake-2.8.6.tar.gz
-rw-r--r--   1 root root 10922155 1月  28 02:46 Discuz_X3.3_SC_UTF8.zip
-rw-r--r--   1 root root 32192348 1月  27 23:22 mysql-5.6.36.tar.gz
-rw-r--r--   1 root root   980831 1月  27 23:03 nginx-1.12.0.tar.gz
-rw-r--r--   1 root root 17785731 1月  27 23:48 php-5.5.38.tar.gz
drwxr-xr-x   2 root root      102 7月  27 2017 readme
drwxr-xr-x  12 root root     4096 7月  27 2017 upload
drwxr-xr-x   4 root root       72 7月  27 2017 utility
drwxrwxrwx   2 root root       68 11月 29 2016 zend-loader-php5.5-linux-x86_64
-rw-r--r--   1 root root   668812 1月  28 01:59 zend-loader-php5.5-linux-x86_64_update1.tar.gz
******(3)移动upload到nginx的网页目录
[root@centos7-007 ~]# mv upload/ /usr/local/nginx/html/benet/bbs
[root@centos7-007 ~]# chown -R php:php /usr/local/nginx/html/benet/bbs/ (刚刚已过去的目录属主和数组改为php)
******(4)登录mysql创建几个测试用的数据库和用户
[root@centos7-007 ~]# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 5.6.36 Source distribution
Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> create database bbs;
Query OK, 1 row affected (0.01 sec)
mysql> grant all on bbs.* to ly@localhost identified by '123123'; 
Query OK, 0 rows affected (0.00 sec)
mysql> quit
Bye


测试是否可以正常访问,使用测试机访问:http://ip地址/bbs/install/index.php(如果有域名那就访问域名)


20210127185302628.png


安装discuz社区论坛


开始安装,点击下一步,点击全新安装,到第三步时,要修改一下数据库密码,在mysql数据中创建的用户名、密码,在这里要填的一直,管理员admin的密码自行填写,信箱什么的都可以自行填写


例如:

数据库服务器:localhost

数据库名:bbs (我在mysql数据库里创建数据库的名称就是bbs)

数据库用户名:ly (MySQL中创建的用户名时ly)

数据库密码:123123 (密码为123123)

系统信箱:ly@163.com


安装完成访问首页 http://ip地址/bbs/forum.php


管理后台:http://ip地址/bbs/admin.php

相关实践学习
基于CentOS快速搭建LAMP环境
本教程介绍如何搭建LAMP环境,其中LAMP分别代表Linux、Apache、MySQL和PHP。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助 &nbsp; &nbsp; 相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
目录
相关文章
|
7月前
|
关系型数据库 应用服务中间件 nginx
Docker搭建LNMP运行Wordpress平台 上
Docker搭建LNMP运行Wordpress平台
127 0
|
7月前
|
关系型数据库 MySQL 应用服务中间件
手动部署LNMP环境(Alibaba Cloud Linux 2)
本场景带您体验如何在Alibaba Cloud Linux 2.1903 LTS 64位操作系统的云服务器上搭建LNMP环境。
202 0
|
7月前
|
关系型数据库 MySQL PHP
Docker搭建LNMP运行Wordpress平台 下
Docker搭建LNMP运行Wordpress平台
76 0
|
3月前
|
API PHP 数据库
Docker六脉神剑(四) 使用Docker-Compose进行服务编排搭建lnmp环境
Docker六脉神剑(四) 使用Docker-Compose进行服务编排搭建lnmp环境
33 0
|
4月前
|
关系型数据库 MySQL 应用服务中间件
小白带你部署LNMP分布式部署
小白带你部署LNMP分布式部署
69 0
|
7月前
|
弹性计算 关系型数据库 MySQL
基于ROS快速部署LNMP环境(CentOS 7)
本教程提供在阿里云云服务器ECS上基于CentOS 7.9操作系统搭建LNMP环境的指引。LNMP是应用广泛的网站服务系统,由四种免费的开源软件Linux、Nginx、MySQL和PHP组成。搭建好LNMP环境后,您可以在该ECS实例上搭建网站、访问网站
406 0
|
7月前
|
关系型数据库 MySQL 应用服务中间件
手动部署LNMP环境(Ubuntu 20)
本教程介绍如何在Ubuntu 20.04操作系统的ECS实例上搭建一套Nginx、MySQL和PHP应用的开发环境。
300 0
|
7月前
|
Linux 应用服务中间件 网络安全
手动部署LNMP环境(CentOS 8)
本场景带您体验如何在CentOS 8操作系统的云服务器上搭建LNMP环境。
106 0
|
8月前
|
关系型数据库 MySQL 应用服务中间件
lnmp部署
lnmp部署
|
4月前
|
关系型数据库 应用服务中间件 nginx
基于Docker的LNMP环境微服务搭建
基于Docker的LNMP环境微服务搭建
基于Docker的LNMP环境微服务搭建