LNMP 环境搭配

项目实施

1. 购置一台服务器

服务器类别:
  1. 塔式服务器

    塔式服务器是我们生活中见得比较多的,主要是因为塔式服务器的外形结构和普通PC比较类似。塔式服务器尺寸没有统一标准,由于塔式服务器的机箱比较大,服务器的配置也可以很高,冗余扩展更可以很齐备

  2. 机架式服务器

    机架式服务器的外形看来不像计算机,而像交换机,有1U(1U=1.75英寸)、2U、4U等规格。机架式服务器安装在标准的19英寸机柜里面。这种结构的多为功能型服务器。

  3. 刀片式服务器

    刀片服务器是指在标准高度的机架式机箱内可插装多个卡式的服务器单元,是一种实现HAHD(高可用高密度)的低成本服务器平台,为特殊应用行业和高密度计算环境专门设计。刀片服务器就像“刀片”一样,每一块“刀片”实际上就是一块系统主板。

结合项目及现状分析:
  1. 一般大部分中小型公司都是采购IBM或者DELL的PC服务器为主, HP的PC 服务器都偏少, 如果还需降低企业运营成本可以考虑国产浪潮、 曙光、 联想等 PC 服务器。 服务器的品牌选择好后主要是考虑到四大因素, CPU、内存、网卡、 磁盘。 其余配置都不是很重要。 另外在服务器选项的时候我们一般会选择比当前需求更高的配置,预防短期时间内需求的提升。
  2. 其次需要确认服务器运行程序, 结合项目分析需要运行http、mysql服
    务,web服务器是一个性能追求性服务器,对web服务器配置的要求主要取决于web的访问量;数据库服务是数据读取写入密集型应用,对服务器的内存资源和磁盘性能要比较高,CPU要求其次.服务器的 CPU 基本都是至强xeon系列的, 就看需要买哪个型号而已。可以先考虑单个八核,如果后期压力大再考虑添加一个 CPU 即可!
  3. 内存考虑一般和CPU是分不开的,由于数据库服务器需要内存资源,这里考虑上64G, 而且必须保证后期根据业务的需求能扩展到更高。
  4. 现在服务器网卡一般都是自适应 10M/100M/1000M 之间, 这点足以满足我们现在的需求,暂时不用考虑太多。
  5. 最后是磁盘,考虑到项目需要存储大量数据,且数据比较重要, 这里建议选择6块硬盘,2块为300G,组成RAID1,安装操作系统;另外4块硬盘大小为1T,热插拔型,组成RAID10,存放数据,在读写上会有所保证, 且数据安全性上比较可靠。

综上分析最后品牌建议大家选择一个主流的品牌, 比如 IBM X3650M3、 M4 系列或者 DELL R620、R730等系列。另外需要综合运营成本考虑,CPU选择 E5系列即可!配置为8C/64G/1T*4即可满足需求。

2. 安装操作系统

  • 使用VMware workstation新建虚拟机
  • 安装CentOS7.5系统,最小化安装,记得要选中“开发工具(development tools)
  • 安装bash-completion以便可以命令补全
    linux
    yum install bash-completion -y
  • 安装vim等基础包
    linux
    yum install vim wget net-tools curl -y
  • 创建普通管理用户admin,并设置复杂密码
    linux
    [root@localhost ~]# useradd admin
    [root@localhost ~]# echo '123.com' | passwd --stdin admin

3. 系统安全配置及初始化操作

3.1 安全配置
  • 更改SSH服务的默认端口
    linux
    [root@localhost ~]# vim /etc/ssh/sshd_config
    Port 1234
    [root@localhost ~]# systemctl restart sshd.service #如果不能重启,关闭selinux
    [root@localhost ~]# firewall-cmd --add-port=1234/tcp --permanent
    [root@localhost ~]# firewall-cmd --reload
  • 禁止root用户登录,只允许普通用户登陆,然后通过su命令切换到root用户。
    linux
    [root@localhost ~]# vim /etc/ssh/sshd_config
    PermitRootLogin no
    [root@localhost ~]# systemctl reload sshd.service
  • 限制SSH验证重试次数,最多3次。
    linx
    [root@localhost ~]# vim /etc/ssh/sshd_config
    MaxAuthTries 3
  • 使用证书替代密码认证,这里只允许使用key文件登陆,这种方式比起密码要
    安全的多,先拷贝证书公钥到admin用户的.ssh/authorized_keys文件中,以admin用户登录系统
    [admin@localhost ~]$ mkdir .ssh
    [admin@localhost .ssh]$ vim .ssh/authorized_keys #把公钥粘贴过来
    ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAtd4e0/HF4O4PNbmRzzmuJKTxoxsltjESBz/bYrWlsGBAC+A67id/kQLRnZ9PzsDXfp+
    oC0Y/+L/tbTFPeLTL9uZ+ecScmRbBhGuFSC8PwfckE+tG5whxdR6+pFzgGeVVGO5Zn28U+qPDTAtOyx3rYv4DwV6qNmHtCeejRxOsS1
    yHyp2eCmc+rk2Lb+Jn5jvzk0V4QJnoMJkIbpliqKcN5wCeorHVNMGvYbOciAVeetBMIXL5Eq5++/fwkvlhoDukxqVBRn3x5Q4u7JOoD
    eyFUhfQLYDsQ1hSUZU6KmeXFiwxNTyrhkimrCZogQIWauO/zWBElv2XRVm1/0+t3sybpQ== rsa 2048-051919
    [admin@localhost ~]$ chmod 700 .ssh/
    [admin@localhost .ssh]$ chmod 600 authorized_keys

    设置只能使用key验证,关闭密码验证

    [root@localhost ~]# vim /etc/ssh/sshd_config
    PasswordAuthentication no
  • 关闭 GSSAPI,减少远程拷贝的传输认证时间
    GSSAPIAuthentication no
  • IP 地址限制,只允许通过 192.168.2.1,192.168.2.2 访问本
    # vim /etc/hosts.allow
    sshd:192.168.2.1,192.168.2.2

    拒绝其他所有人访问本机

    # vim /etc/hosts.deny
    sshd:ALL

    上面使用白名单策略,你也可以采用黑名单策略。

  • history 文件,通过~/.bash_history 文件记录系统管理员的操作记录, 定制.bash_history格式
    [root@localhost ~]# vim .bash_profile
    HISTSIZE=1000
    HISTFILESIZE=2000
    HISTTIMEFORMAT="%Y-%m-%d-%H:%M:%S "
    export HISTTIMEFORMAT
    [root@localhost ~]# source .bash_profile
3.2 操作系统初始化
  • Linux 系统资源调配
    /etc/security/limits.conf
    * soft nofile 65535
    * hard nofile 65535
  • 设置系统同步时间, 追加到 cron 中
    [root@localhost ~]# yum install  ntpdate -y
    [root@localhost ~]# crontab -e
    */5 * * * * /sbin/ntpdate ntp.api.bz
  • 修改主机名字
    [root@localhost ~]# hostnamectl set-hostname www.lnmp.com
  • 配置网络。设置固定IP地址,网关及DNS服务器地址
    [root@localhost ~]# nmcli connection modify eno16777736 ipv4.addresses 192.168.66.136/24 ipv4.gateway 192.168.66.2 ipv4.dns 192.168.66.2  autoconnect yes
    
    nmcli connection  modify  eno16777736  ipv4.method manualdresses 192.168.66.136/24 ipv4.gateway 192.168.66.2 ipv4.onnect yes
    
    [root@localhost ~]# nmcli connection up ens32
  • 关闭 Selinux
    [root@localhost ~]# vim /etc/selinux/config
    SELINUX=disabled
  • yum源的配置,可以根据业务需求来安装 epel、 nginx、 remi 源, 且修改配置参数。
    [root@localhost yum.repos.d]# yum install epel-release -y
    [root@localhost yum.repos.d]# rpm -ivh http://rpms.remirepo.net/enterprise/remi-release-7.rpm
    [root@localhost yum.repos.d]# vim remi.repo
    [epel]
    enabled=1
  • DNS 解析域名设置
    vi /etc/resolve.conf
    nameserver 192.168.154.2
    nameserver 202.106.0.20

4. 安装配置Nginx网站服务器

4.1 安装nginx服务
  • 设置nginx YUM源
    [root@www ~]# yum install yum-utils -y
    [root@www ~]# cat  /etc/yum.repos.d/nginx.repo
    [nginx-stable]
    name=nginx stable repo
    baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
    gpgcheck=1
    enabled=1
    gpgkey=https://nginx.org/keys/nginx_signing.key
    
    [nginx-mainline]
    name=nginx mainline repo
    baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/
    gpgcheck=1
    enabled=0
    gpgkey=https://nginx.org/keys/nginx_signing.key
  • 安装nginx服务,会安装1.16.0版本
    linux
    [root@www ~]# yum install nginx -y
  • 设置nginx开机启动并开启nginx服务
    [root@www ~]# systemctl enable  nginx.service
    [root@www ~]# systemctl start  nginx.service 
    [root@www ~]# systemctl status  nginx.service 
    ● nginx.service - nginx - high performance web server
       Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled)
       Active: active (running) since Mon 2019-05-20 18:11:58 CST; 4s ago
         Docs: http://nginx.org/en/docs/
      Process: 1881 ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf (code=exited, status=0/SUCCESS)
     Main PID: 1882 (nginx)
       CGroup: /system.slice/nginx.service
               ├─1882 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
               └─1883 nginx: worker process
    
    May 20 18:11:58 www.lnmp.com systemd[1]: Starting nginx - high performance web server...
    May 20 18:11:58 www.lnmp.com systemd[1]: Started nginx - high performance web server.
  • 防火墙放行http服务
    linux
    [root@www ~]# firewall-cmd --add-service=http --permanent
    [root@www ~]# firewall-cmd --add-service=http
  • 测试是否可以访问nginx
    [root@www ~]# curl http://192.168.154.137
    或者找个客户端,使用浏览器访问服务器地址
4.2 调整nginx配置文件
[root@www ~]# vim /etc/nginx/nginx.conf
user  nginx nginx;
worker_processes  4;
worker_cpu_affinity 00000001 00000010 00000100 00001000;
worker_rlimit_nofile 65535;

error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;


events {
    use epoll;
    worker_connections  10240;
}
http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;
    server_names_hash_bucket_size 128;
    client_header_buffer_size 2k;
    large_client_header_buffers 4 4k;
    client_max_body_size 8m;

    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  /var/log/nginx/access.log  main;

    sendfile        on;
    tcp_nopush     on;
    tcp_nodelay on;
    keepalive_timeout  65;
    fastcgi_cache_path /etc/nginx/fastcgi_cache levels=1:2 keys_zone=TEST:10m inactive=5m;
    fastcgi_cache_key http://$host$request_uri;
    fastcgi_connect_timeout 300;
    fastcgi_send_timeout 300;
    fastcgi_read_timeout 300;
    fastcgi_buffer_size 4k;
    fastcgi_buffers 8 4k;
    fastcgi_busy_buffers_size 8k;
    fastcgi_temp_file_write_size 8k;
    fastcgi_cache TEST;
    fastcgi_cache_valid 200 302 1h;
    fastcgi_cache_valid 301 1d;
    fastcgi_cache_valid any 1m;
    fastcgi_cache_min_uses 1;
    fastcgi_cache_use_stale error timeout invalid_header http_500;
    open_file_cache max=204800 inactive=20s;
    open_file_cache_min_uses 1;
    open_file_cache_valid 30s;

    gzip  on;
    gzip_min_length 1k;
    gzip_buffers 4 16k;
    gzip_http_version 1.0;
    gzip_comp_level 2;
    gzip_types text/plain application/x-javascript text/css application/xml;
    gzip_vary on;

    include /etc/nginx/conf.d/*.conf;
}
[root@www nginx]# vim /etc/nginx/conf.d/default.conf
server {
    listen       80;
    server_name  www.lnmp.com;

    #charset koi8-r;
    #access_log  /var/log/nginx/host.access.log  main;

    location / {
        root   /opt/nginx/html;
        index  index.html index.htm;
    }
    location /status
    {
        stub_status on;
    }

    #error_page  404              /404.html;

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;

    location = /50x.html {
        root   /opt/nginx/html;
    }
    location ~ .*/.(gif|jpg|jpeg|png|bmp|swf|js|css)$
    {
        expires 30d;
    }

    # proxy the PHP scripts to Apache listening on 127.0.0.1:80
    #
    #location ~ \.php$ {
    #    proxy_pass   http://127.0.0.1;
    #}

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    #location ~ \.php$ {
    #    root           html;
    #    fastcgi_pass   127.0.0.1:9000;
    #    fastcgi_index  index.php;
    #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
    #    include        fastcgi_params;
    #}
      # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /\.ht {
    #    deny  all;
    #}
}
  • 由于更改了根目录,所以需要创建新的根目录
[root@www nginx]# mkdir /opt/nginx/html -p
[root@www nginx]# cp /usr/share/nginx/html/* /opt/nginx/html/
[root@www nginx]# ll /opt/nginx/html/
total 8
-rw-r--r-- 1 root root 494 May 22 20:33 50x.html
-rw-r--r-- 1 root root 612 May 22 20:33 index.html
  • 改变了服务配置文件,所以需要重新启动服务
[root@www ~]# systemctl restart nginx.service 
[root@www ~]# systemctl status nginx.service

5. 安装配置MySQL数据库服务器

MySQL是目前使用最受信赖和广泛使用的开源数据库平台。全球十大最受欢迎和高流量的网站中有10个依赖于MySQL。MySQL 8.0通过提供全面的改进建立在这一势头上,旨在使创新的DBA和开发人员能够在最新一代的开发框架和硬件上创建和部署下一代Web,嵌入式,移动和云/ SaaS / PaaS / DBaaS应用程序平台。MySQL 8.0亮点包括:
+ MySQL文档存储
+ 交易数据字典
+ SQL角色
+ 默认为utf8mb4
+ 公用表表达式
+ 窗口功能
+ 以及更多

5.1 安装mysql源
  • 下载MySQL YUM仓库:
    linux
    [root@www ~]# wget https://dev.mysql.com/get/mysql80-community-release-el7-2.noarch.rpm
  • 安装MySQL YUM仓库:
    linux
    [root@www ~]# rpm -Uvh mysql80-community-release-el7-2.noarch.rpm
5.2 安装mysql数据库
  • 默认安装最新GA版MySQL
  • 可以通过运行以下命令并检查其输出来验证是否已启用和禁用了正确的子存储库
    linux
    [root@www ~]# yum repolist enabled | grep mysql
    mysql-connectors-community/x86_64 MySQL Connectors Community 108
    mysql-tools-community/x86_64 MySQL Tools Community 90
    mysql80-community/x86_64 MySQL 8.0 Community Server 113
  • 安装MySQL
    [root@www ~]# yum remove mariadb-libs -y
    [root@www ~]# yum install mysql-community-server
    [root@www ~]# systemctl start mysqld.service 
    [root@www ~]# systemctl status mysqld.service 
    ● mysqld.service - MySQL Server
       Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
       Active: active (running) since Sat 2019-05-25 11:30:43 CST; 2s ago
         Docs: man:mysqld(8)
               http://dev.mysql.com/doc/refman/en/using-systemd.html
      Process: 2671 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
     Main PID: 2746 (mysqld)
       Status: "SERVER_OPERATING"
       CGroup: /system.slice/mysqld.service
               └─2746 /usr/sbin/mysqld
    
    May 25 11:30:13 www.lnmp.com systemd[1]: Starting MySQL Server...
    May 25 11:30:43 www.lnmp.com systemd[1]: Started MySQL Server.
5.3 MySQL数据库初始化(从MySQL 5.7开始):

在服务器初始启动时,如果服务器的数据目录为空,则会发生以下情况:
+ 服务器已初始化。
+ 在数据目录中生成SSL证书和密钥文件。
+ 该validate_password插件安装并启用。
+ 将’root’@’localhost’ 创建一个超级用户帐户。设置超级用户的密码并将其存储在错误日志文件中。要显示它,请使用以下命令:
“`linux
[root@www ~]# grep ‘temporary password’ /var/log/mysqld.log

2019-05-25T03:30:25.989353Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: gw2yrdVKWy,g
```
+ 通过使用生成的临时密码登录并为超级用户帐户设置自定义密码,尽快更改root密码:
```linux
[root@www ~]# mysql -u root -p gw2yrdVKWy,g
#进入数据库后更改密码

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';  

#注意:MySQL的 validate_password 插件默认安装。这将要求密码包含至少一个大写字母,一个小写字母,一个数字和一个特殊字符,并且密码总长度至少为8个字符。
```
5.4 配置开机启动mysql服务
[root@www ~]# systemctl enable mysqld.service 
[root@www ~]# systemctl restart mysqld.service 
[root@www ~]# systemctl status mysqld.service 
● mysqld.service - MySQL Server
       Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
       Active: active (running) since Sat 2019-05-25 11:42:41 CST; 3s ago
         Docs: man:mysqld(8)
               http://dev.mysql.com/doc/refman/en/using-systemd.html
      Process: 3018 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
     Main PID: 3042 (mysqld)
       Status: "SERVER_OPERATING"
       CGroup: /system.slice/mysqld.service
               └─3042 /usr/sbin/mysqld

    May 25 11:42:39 www.lnmp.com systemd[1]: Starting MySQL Server...
    May 25 11:42:41 www.lnmp.com systemd[1]: Started MySQL Server.

6. 安装配置PHP环境

6.1 安装php7的YUM源
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
6.2 安装PHP7.2
[root@www ~]# yum install php72w php72w-cli php72w-common php72w-gd php72w-ldap php72w-mbstring php72w-mcrypt php72w-mysql php72w-pdo
6.3 安装php-fpm并启动
[root@www ~]# yum install php72w-fpm php72w-opcache
[root@www ~]# systemctl enable php-fpm.service 
Created symlink from /etc/systemd/system/multi-user.target.wants/php-fpm.service to /usr/lib/systemd/system/php-fpm.service.
[root@www ~]# systemctl start php-fpm.service 
[root@www ~]# systemctl status php-fpm.service 
● php-fpm.service - The PHP FastCGI Process Manager
   Loaded: loaded (/usr/lib/systemd/system/php-fpm.service; enabled; vendor preset: disabled)
   Active: active (running) since Sat 2019-05-25 22:30:23 CST; 5s ago
 Main PID: 2368 (php-fpm)
   Status: "Ready to handle connections"
   CGroup: /system.slice/php-fpm.service
           ├─2368 php-fpm: master process (/etc/php-fpm.conf)
           ├─2369 php-fpm: pool www
           ├─2370 php-fpm: pool www
           ├─2371 php-fpm: pool www
           ├─2372 php-fpm: pool www
           └─2373 php-fpm: pool www

May 25 22:30:22 www.lnmp.com systemd[1]: Starting The PHP FastCGI Process Manager...
May 25 22:30:23 www.lnmp.com systemd[1]: Started The PHP FastCGI Process Manager.
6.4 调整php-fpm配置文件
[root@www ~]# vim /etc/php-fpm.d/www.conf 
[www]
user = nginx
group = nginx
6.5 调整nginx配置文件
[root@www ~]# vim /etc/nginx/conf.d/default.conf
    location / {
        root   /opt/nginx/html;
        index  index.php index.html index.htm;
    }
    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    location ~ \.php$ {
        root           /opt/nginx/html;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
   #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
        fastcgi_cache TEST;
        fastcgi_cache_valid 200 302 1h;
        fastcgi_cache_valid 301 1d;
        fastcgi_cache_valid any 1m;
    }
6.6 创建MySQL数据库管理员
  • 认证机制必须是mysql_native_password;默认mysql8使用 caching_sha2_password的身份验证机制
mysql> create user 'dbadmin'@'%' identified with mysql_native_password by 'Com.123456';
mysql> grant all on *.* to 'dbadmin'@'%';
mysql> grant GRANT OPTION  on *.* to 'dbadmin'@'%';
server {
    listen       80;
    server_name  www.lnmp.com;

    #charset koi8-r;
    #access_log  /var/log/nginx/host.access.log  main;

    location / {
        root   /jin/html;
        index  first.html index.php;
    }
    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    location ~ \.php$ {
        root           /jin/html;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
   #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        include        fastcgi_params;
        fastcgi_cache TEST;
        fastcgi_cache_valid 200 302 1h;
        fastcgi_cache_valid 301 1d;
        fastcgi_cache_valid any 1m;
    }
    location /status
    {
        stub_status on;
    }

    #error_page  404              /404.html;

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;

    location = /50x.html {
        root   /jin/html;
    }
    location ~ .*/.(gif|jpg|jpeg|png|bmp|swf|js|css)$
    {
        expires 30d;
    }

    # proxy the PHP scripts to Apache listening on 127.0.0.1:80
    #
    #location ~ \.php$ {
    #    proxy_pass   http://127.0.0.1;
    #}

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    #location ~ \.php$ {
    #    root           html;
    #    fastcgi_pass   127.0.0.1:9000;
    #    fastcgi_index  index.php;
    #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
    #    include        fastcgi_params;
    #}
      # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /\.ht {
    #    deny  all;
    #}
}

7. LNMP环境测试

7.1 测试LNMP环境
[root@www html]# cat test.php 
<?php
phpinfo();
?>
  • 在客户端访问:
    http://192.168.154.137/test.php
7.2 测试是否可以连接MySQL数据库文件
[root@www html]# cat mysql_test.php 
<?PHP
    $conn=mysqli_connect("localhost","dbadmin","your_dbpasswd");
    if($conn){
        echo"ok";
    }else{
        echo"error";    
    }
?>
  • 在客户端访问
[root@www html]# curl http://192.168.154.137/mysql_test.php
ok

8.部署开源论坛Discuz

8.1 下载Discuz论坛文件

Discuz现在在gitee.com进行维护,地址为:https://gitee.com/ComsenzDiscuz/DiscuzX
+ 下载文件
linux
[root@www test]# wget https://gitee.com/ComsenzDiscuz/DiscuzX/repository/archive/master.zip

+ 解压并上传upload目录到网站根目录
linux
[root@www test]# unzip master.zip
[root@www test]# cd DiscuzX/
[root@www DiscuzX]# ls
readme README.md upload utility
[root@www DiscuzX]# mv upload/ /opt/nginx/html/

8.2 建立Discuz论坛所用数据库
[root@www ~]# mysql -u dbadmin -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 8.0.16 MySQL Community Server - GPL

Copyright (c) 2000, 2019, 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> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.00 sec)

mysql> create database discuz;
Query OK, 1 row affected (0.03 sec)

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| discuz             |
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
5 rows in set (0.00 sec)

mysql> exit
Bye
8.3 安装Discuz论坛
  • 在客户端使用浏览器打开网站地址:http://39.96.9.200/upload/install/, 会显示以下安装界面:
  • 点击我同意
  • 解决所有文件权限,需要可写权限
    linux
    [root@www ~]# cd /opt/nginx/html/upload/
    [root@www upload]# chmod -R 777 ./config/ ./data/ ./uc_client/ ./uc_server/
  • 然后刷新界面
  • 选择全新安装,点击下一步
  • 添加安装数据库有关信息,必须要按照实际情况添加。
  • 会开始安装论坛,安装完毕后就可以访问论坛了,可以把upload文件夹重命名
    linux
    [root@www html]# mv upload/ discuz

    访问论坛
8.4 可以使用论坛管理员admin用户做论坛管理
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
该资源内项目源码是个人的课程设计、毕业设计,代码都测试ok,都是运行成功后才上传资源,答辩评审平均分达到96分,放心下载使用! ## 项目备注 1、该资源内项目代码都经过测试运行成功,功能ok的情况下才上传的,请放心下载使用! 2、本项目适合计算机相关专业(如计科、人工智能、通信工程、自动化、电子信息等)的在校学生、老师或者企业员工下载学习,也适合小白学习进阶,当然也可作为毕设项目、课程设计、作业、项目初期立项演示等。 3、如果基础还行,也可在此代码基础上进行修改,以实现其他功能,也可用于毕设、课设、作业等。 下载后请首先打开README.md文件(如有),仅供学习参考, 切勿用于商业用途。 该资源内项目源码是个人的课程设计,代码都测试ok,都是运行成功后才上传资源,答辩评审平均分达到96分,放心下载使用! ## 项目备注 1、该资源内项目代码都经过测试运行成功,功能ok的情况下才上传的,请放心下载使用! 2、本项目适合计算机相关专业(如计科、人工智能、通信工程、自动化、电子信息等)的在校学生、老师或者企业员工下载学习,也适合小白学习进阶,当然也可作为毕设项目、课程设计、作业、项目初期立项演示等。 3、如果基础还行,也可在此代码基础上进行修改,以实现其他功能,也可用于毕设、课设、作业等。 下载后请首先打开README.md文件(如有),仅供学习参考, 切勿用于商业用途。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值