一、nginx+mariadb+php搭建Dz论坛

1. YUM方式进行安装and配置nginx

1.1设置nginx YUM源

官方yum源:http://nginx.org/en/linux_packages.html#RHEL-CentOS

$ yum install -y vim wget
$ yum install yum-utils -y
$ vim /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
module_hotfixes=true[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
module_hotfixes=true

1.2 安装nginx服务,会安装1.18.0版本

$ yum install nginx -y

1.3 设置nginx开机启动

$ systemctl enable nginx.service
$ systemctl start nginx.service
$ systemctl status nginx.service
● nginx.service - nginx - high performance web serverLoaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled)Active: active (running) since Mon 2020-04-13 10:59:12 EDT; 14s agoDocs: http://nginx.org/en/docs/Process: 20145 ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf (code=exited, status=0/SUCCESS)Main PID: 20146 (nginx)CGroup: /system.slice/nginx.service├─20146 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx....└─20147 nginx: worker processApr 13 10:59:12 localhost.localdomain systemd[1]: Starting nginx - high perfo...
Apr 13 10:59:12 localhost.localdomain systemd[1]: Started nginx - high perfor...
Hint: Some lines were ellipsized, use -l to show in full.

1.4 防火墙放行htpp服务

$ firewall-cmd --add-service=http --permanent
$ firewall-cmd --reload
$ firewall-cmd --list-all$ setenforce 0
$ getenforce
Permissive

1.5 测试是否可以访问nginx

$ curl http://192.168.101.171

1.6 调整nginx配置文件

(文件夹有default.conf和nginx.conf)

$ vim /etc/nginx/nginx.conf
user  nginx;
worker_processes  auto;
worker_cpu_affinity auto;# 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;
}
$ vim /etc/nginx/conf.d/default.conf
server {listen       80;server_name  test.cn;#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|gpeg|png|bmp|swf|js|css)${expires 1d;}# 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;#}
}
  • 由于更改了根目录,所以需要创建新的根目录

    $ mkdir /opt/nginx/html -p
    $ cp /usr/share/nginx/html/* /opt/nginx/html/
    $ ll /opt/nginx/html/
    total 8
    -rw-r--r--. 1 root root 494 Apr 14 12:48 50x.html
    -rw-r--r--. 1 root root 612 Apr 14 12:48 index.html
    
  • 改变了服务配置文件,所以需要重新启动服务

    $ nginx -t #检测配置文件语法是否有错误
    $ systemctl restart nginx
    $ systemctl status nginx
    
  • 访问nginx

2. 安装配置必要软件

  1. 执行以下命令,安装必要软件(MariaDB、PHP、Git):
$ yum install php php-fpm php-mysql mariadb mariadb-server git -y
  1. 依次执行以下命令,启动服务。
$ systemctl start mariadb
$ systemctl start php-fpm
$ systemctl enable mariadb
$ systemctl enable php-fpm
  1. 执行以下命令,设定 root 帐户密码及基础配置,使 root 用户可以访问数据库。
# 注意:
# 针对首次登录 MariaDB 前执行以下命令进入用户密码及基础设置。
# 首次提示输入 root 密码后按 Enter 直接进入 root 密码设置步骤,设置 root 密码时界面默认不显示,并再次输入确认。通过界面上的提示完成基础配置。$ mysql_secure_installationNOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDBSERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.Enter current password for root (enter for none):
OK, successfully used password, moving on...Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.Set root password? [Y/n]
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..... Success!By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.Remove anonymous users? [Y/n] ... Success!Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.Disallow root login remotely? [Y/n] ... Success!By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.Remove test database and access to it? [Y/n] - Dropping test database...... Success!- Removing privileges on test database...... Success!Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.Reload privilege tables now? [Y/n] ... Success!Cleaning up...All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.Thanks for using MariaDB!
  1. 执行以下命令,登录 MariaDB,并输入 步骤3 设置的密码,按 “Enter”。
$ mysql -u root -p
# 若输入刚设定的密码可以登录到 MariaDB 中,则说明配置正确# 创建数据库
$ create database Discuz;> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| Discuz             |
| mysql              |
| performance_schema |
+--------------------+
4 rows in set (0.00 sec)$ \q    # 退出mariadb数据库

5.5 调整nginx配置文件

$ vi /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 300 302 1h;fastcgi_cache_valid 301 1d;fastcgi_cache_valid any 1m;}

修改nginx配置文件需重启nginx

$ nginx -t #检测配置文件语法是否有错误
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
$ systemctl restart nginx
$ systemctl status nginx
● nginx.service - nginx - high performance web serverLoaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled)Active: active (running) since Tue 2020-06-30 06:25:33 EDT; 11s agoDocs: http://nginx.org/en/docs/Process: 10252 ExecStop=/bin/kill -s TERM $MAINPID (code=exited, status=0/SUCCESS)Process: 10255 ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf (code=exited, status=0/SUCCESS)Main PID: 9711 (code=exited, status=0/SUCCESS)CGroup: /system.slice/nginx.service├─10256 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf├─10257 nginx: worker process├─10258 nginx: worker process├─10259 nginx: worker process├─10260 nginx: worker process├─10261 nginx: cache manager process└─10262 nginx: cache loader processJun 30 06:25:33 bogon systemd[1]: Starting nginx - high performance web server...
Jun 30 06:25:33 bogon systemd[1]: Can't open PID file /var/run/nginx.pid (yet?) after start: No suc...ctory
Jun 30 06:25:33 bogon systemd[1]: Started nginx - high performance web server.
Hint: Some lines were ellipsized, use -l to show in full.

3.LNMP环境测试

3.1 测试LNMP环境

$ cat test.php
<?php
phpinfo();
?>
  • 在客户端访问 http://192.168.101.171/test.php

4. 部署开源论坛Discuz

4.1 下载Discuz论坛文件

# 执行以下命令,下载安装包。
$ git clone https://gitee.com/ComsenzDiscuz/DiscuzX.git

42 安装准备工作

  1. 执行以下命令,进入下载好的安装目录。

    $ cd DiscuzX
    
  2. 执行以下命令,将 “upload” 文件夹下的所有文件复制到 /opt/nginx/html

    $ cp -r upload/* /opt/nginx/html/
    
  3. 执行以下命令,将写权限赋予给其他用户。

    $ chmod -R 777 /opt/nginx/html
    

4.3安装 Discuz!

  1. 访问http://192.168.101.171/install/
  2. 点击我同意→进入检查安装环境页面→确定当前状态→点击下一步
  3. 进入创建数据库界面→输入数据库名→数据库用户名→数据库密码→系统信箱→管理员账号→管理员密码→管理员Email→点击下一步(根据自己配置)
  4. 安装完成后单击您的论坛已完成安装,点此访问,即可访问论坛
  5. 进入DZ论坛就此搭建完毕
  $ chmod -R 777 /opt/nginx/html
  1. 进入DZ论坛就此搭建完毕

centos7.7 nginx+mariadb+php搭建Dz论坛最新版安装相关推荐

  1. Linux安装宝塔搭建dz论坛【傻瓜式安装,实测有效】

    一.安装宝塔 1.宝塔下载链接 https://www.bt.cn/new/download.html 2.宝塔下载脚本 用 SSH 连接工具,如 堡塔SSH终端 连接到您的 Linux 服务器后, ...

  2. 新装linux系统(centOs7)使用nginx驱动vue项目

    新装linux系统(centOs7)使用nginx驱动vue项目 配置linux环境 centos安装nginx 安装nginx前首先要确认系统中安装了gcc.pcre-devel.zlib-deve ...

  3. LAMP下搭建discuz论坛

    LAMP下搭建discuz论坛 一.安装discuz ---->//download discuz;[root@localhost ~]# mkdir /data/www [root@local ...

  4. CentOS7下搭建Discuz论坛

    搭建Discuz论坛的前提条件: LNMP环境 Discuz压缩包 一.检查各服务是否已经启动并且进程正常 检查Nginx服务的进程是否已启动和是否有监听80端口: [root@localhost ~ ...

  5. centos 编译nginx php mariadb,centos7安装nginx+mariadb+php-fpm

    由 dp7f1f9f 创建,最后一次修改 2017-05-22 用CentOS-7-x86_64-Minimal-1611.iso最小化安装一个centos7,安装选项:英文.时区为上海.启用网络(如 ...

  6. Nginx实战基础篇六 通过源码包编译安装部署LNMP搭建Discuz论坛

    Nginx实战基础篇六 通过源码包编译安装部署LNMP搭建Discuz论坛 版权声明: 本文遵循"署名非商业性使用相同方式共享 2.5 中国大陆"协议 您可以自由复制.发行.展览. ...

  7. 腾讯云服务器CVM(CentOS 7、Tencent Linux)手动搭建LNMP环境(linux+Nginx+Mariadb+PHP)

    手动搭建云服务器运行环境就是喜欢折腾,如果觉得麻烦的网友可以使用LNMP镜像直接启动CVM实例,以便快速建站. 腾讯云服务器CVM(CentOS 7.Tencent Linux)手动搭建LNMP环境( ...

  8. Linux整合LNMP(Centos7.4+Nginx+PHP+MariaDB)

    分享知识 传递快乐 由于之前写过Windows整合方式,有很多相同的地方,在此就不过多重复写了,参考下面几篇文章就够用了. Win7整合WNMP(Linux整合LNMP(Centos7.4+Nginx ...

  9. 腾讯云linux配置服务器配置,centos7+腾讯云服务器搭建wordpress

    title: centos7+腾讯云服务器搭建wordpress date: 2020-03-04 categories: web tags: [wordpress] 分两部分:1.搭建LEMP环境 ...

最新文章

  1. keras Classifier 分类
  2. VMRC控制台的连接已断开..正在尝试重新连接
  3. Vue实现访问百度音乐API实现播放音乐功能
  4. 图的存储结构matlab,matlab存储 一幅图像的的函数为( )
  5. Java char所占用的字节_关于unicode:为什么Java char原语占用2个字节的内存?
  6. linux防火墙规则命令意思,linux防火墙iptables配置规则分享
  7. 查看linux上卸载mysql数据库_linux卸载mysql数据库
  8. vue项目中的跑马灯的使用
  9. 代码动态逍遥叹之狂学php
  10. 免费画图软件推荐 - draw.io
  11. 小米球外网映射本地tomcat
  12. qq音乐api接口梳理
  13. IGBT 直通短路过程问题分析
  14. Firefox中强制复制粘贴的插件
  15. 如何用PPT制作一份可视化数据图表?
  16. 区间缩放,标准化,归一化
  17. Python自学笔记————字符串
  18. CorelDRAW VBA - 获取页面边框范围内的所有图形
  19. Socket详解-socket建立
  20. 64 win7 PLSQL Developer 连接

热门文章

  1. 职业最低谷时的样子——北漂18年(55)
  2. JavaScript--BOM
  3. LTE中20MHz带宽采样率为30.72MHz
  4. Excel 将一列数据分成多列
  5. 【ZJOI2015】醉醺醺的幻想乡 题解
  6. 7-3 统计正数和负数的个数然后计算这些数的平均值 (15 分)
  7. 简单的项目规模统计方法
  8. 证件照怎么弄?教你一招制作证件照的简单方法
  9. 【转载】VTD_RDB_TrafficLights 数据解析提取
  10. SAP安全库存(时间)详解