LNMP环境搭建BBS论坛及伪静态
我们在mysql备份 LNMP环境中的数据库迁移为独立的服务器的基础上搭建BBS论坛:
[root@bqh-117 ~]# mysql -uroot -p123456
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.5.32 MySQL Community Server (GPL) Copyright (c) 2000, 2013, 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 |
| test |
| wordpress |
+--------------------+
5 rows in set (0.00 sec) mysql> create database bbs; #创建库
Query OK, 1 row affected (0.00 sec) mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| bbs |
| mysql |
| performance_schema |
| test |
| wordpress |
+--------------------+
6 rows in set (0.00 sec) mysql> grant all on bbs.* to bbs@'192.168.0.%' identified by '123456'; #授权
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges; #刷新授权生效
Query OK, 0 rows affected (0.00 sec) mysql> select user,host from mysql.user;
+-----------+-------------+
| user | host |
+-----------+-------------+
| root | 127.0.0.1 |
| bbs | 192.168.0.% |
| wordpress | 192.168.0.% |
| root | ::1 |
| | bqh-117 |
| root | bqh-117 |
| | localhost |
| root | localhost |
+-----------+-------------+
8 rows in set (0.00 sec) mysql>
此时我们可以通过118机器用已授权的用户远程登录一下数据库:
[root@bqh-118 ~]# mysql -ubbs -p123456 -h 192.168.0.117 #-h 指定远程IP地址
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.5.32 MySQL Community Server (GPL) Copyright (c) 2000, 2013, 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 |
| bbs |
| test |
+--------------------+
3 rows in set (0.00 sec)
nginx环境配置:
[root@bqh-118 conf]# vim nginx.conf
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name www.jywbbs.com;
root html/bbs;
location / {
index index.php index.html index.htm;
}
location ~ .*\.(php|php5)?$ {
root html/bbs;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi.conf;
}
error_page 500 502 503 504 /50x.html;
}
}
[root@bqh-118 conf]# /application/nginx/sbin/nginx -t
nginx: the configuration file /application/nginx-1.6.3/conf/nginx.conf syntax is ok
nginx: configuration file /application/nginx-1.6.3/conf/nginx.conf test is successful
[root@bqh-118 conf]# /application/nginx/sbin/nginx -s reload
下面我们下载bbs程序:
[root@bqh-118 bbs]# wget -q http://download.comsenz.com/DiscuzX/3.2/Discuz_X3.2_SC_UTF8.zip
[root@bqh-118 bbs]# ll
总用量 12196
-rw-r--r-- 1 root root 12486773 9月 13 2017 Discuz_X3.2_SC_UTF8.zip
[root@bqh-118 bbs]# unzip -o Discuz_X3.2_SC_UTF8.zip #-o 覆盖当前同名文件或目录,工作中慎用。
[root@bqh-118 bbs]# ll
总用量 12208
-rw-r--r-- 1 root root 12486773 9月 13 2017 Discuz_X3.2_SC_UTF8.zip
drwxr-xr-x 2 root root 4096 5月 31 2016 readme
drwxr-xr-x 12 root root 4096 5月 31 2016 upload
drwxr-xr-x 4 root root 4096 5月 31 2016 utility
授权:
[root@bqh-118 html]# chown -R nginx.nginx config/ data/ uc_*
然后我们做hosts地址解析:

同样在windows系统,配置一下host在“C:\Windows\System32\drivers\etc”下的hosts中配置一下域名解析

此时我们打开浏览器输入:www.jywbbs.com或192.168.0.118





此时我们可以管控一下权限:下面是删除后,从新授权。
[root@bqh-117 ~]# mysql -uroot -p123456
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 5.5.32 MySQL Community Server (GPL) Copyright (c) 2000, 2013, 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> drop user bbs@'192.168.0.%';
Query OK, 0 rows affected (0.00 sec) mysql> grant insert,delete,update,select,drop on bbs.* to bbs@'192.168.0.%' identified by '123456';
Query OK, 0 rows affected (0.00 sec) mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

登录论坛后台,发布一篇稿子,上传一个图片,获取图片路径:


[root@bqh- bbs]# find ./ -type f -name "*.jpg" -mmin - #查看最近5分钟内上传带.jpg的图片路径

用户上传的数据:
将来挂载到NFS上的:
图片路径:data/attachment/forum
头像目录:uc_server/data/avatar
把安装文件删除掉,防止其他用户通过web从新安装bbs。
[root@bqh- bbs]# rm -rf install/
配置BBS论坛实现列表、内容页等伪静态:

查看当前的 Rewrite 规则:
Nginx Web Server
rewrite ^([^\.]*)/topic-(.+)\.html$ $/portal.php?mod=topic&topic=$ last;
rewrite ^([^\.]*)/article-([-]+)-([-]+)\.html$ $/portal.php?mod=view&aid=$&page=$ last;
rewrite ^([^\.]*)/forum-(\w+)-([-]+)\.html$ $/forum.php?mod=forumdisplay&fid=$&page=$ last;
rewrite ^([^\.]*)/thread-([-]+)-([-]+)-([-]+)\.html$ $/forum.php?mod=viewthread&tid=$&extra=page%3D$&page=$ last;
rewrite ^([^\.]*)/group-([-]+)-([-]+)\.html$ $/forum.php?mod=group&fid=$&page=$ last;
rewrite ^([^\.]*)/space-(username|uid)-(.+)\.html$ $/home.php?mod=space&$=$ last;
rewrite ^([^\.]*)/blog-([-]+)-([-]+)\.html$ $/home.php?mod=space&uid=$&do=blog&id=$ last;
rewrite ^([^\.]*)/(fid|tid)-([-]+)\.html$ $/index.php?action=$&value=$ last;
rewrite ^([^\.]*)/([a-z]+[a-z0-9_]*)-([a-z0-9_\-]+)\.html$ $/plugin.php?id=$:$ last;
if (!-e $request_filename) {
return ;
}
Apache Web Server(独立主机用户)
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^(.*)/topic-(.+)\.html$ $/portal.php?mod=topic&topic=$&%
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^(.*)/article-([-]+)-([-]+)\.html$ $/portal.php?mod=view&aid=$&page=$&%
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^(.*)/forum-(\w+)-([-]+)\.html$ $/forum.php?mod=forumdisplay&fid=$&page=$&%
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^(.*)/thread-([-]+)-([-]+)-([-]+)\.html$ $/forum.php?mod=viewthread&tid=$&extra=page\%3D$&page=$&%
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^(.*)/group-([-]+)-([-]+)\.html$ $/forum.php?mod=group&fid=$&page=$&%
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^(.*)/space-(username|uid)-(.+)\.html$ $/home.php?mod=space&$=$&%
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^(.*)/blog-([-]+)-([-]+)\.html$ $/home.php?mod=space&uid=$&do=blog&id=$&%
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^(.*)/(fid|tid)-([-]+)\.html$ $/index.php?action=$&value=$&%
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^(.*)/([a-z]+[a-z0-9_]*)-([a-z0-9_\-]+)\.html$ $/plugin.php?id=$:$&%
</IfModule>
Apache Web Server(虚拟主机用户)
# 将 RewriteEngine 模式打开
RewriteEngine On # 修改以下语句中的 /discuz 为您的论坛目录地址,如果程序放在根目录中,请将 /discuz 修改为 /
RewriteBase /discuz # Rewrite 系统规则请勿修改
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^topic-(.+)\.html$ portal.php?mod=topic&topic=$&%
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^article-([-]+)-([-]+)\.html$ portal.php?mod=view&aid=$&page=$&%
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^forum-(\w+)-([-]+)\.html$ forum.php?mod=forumdisplay&fid=$&page=$&%
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^thread-([-]+)-([-]+)-([-]+)\.html$ forum.php?mod=viewthread&tid=$&extra=page\%3D$&page=$&%
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^group-([-]+)-([-]+)\.html$ forum.php?mod=group&fid=$&page=$&%
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^space-(username|uid)-(.+)\.html$ home.php?mod=space&$=$&%
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^blog-([-]+)-([-]+)\.html$ home.php?mod=space&uid=$&do=blog&id=$&%
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^archiver/(fid|tid)-([-]+)\.html$ archiver/index.php?action=$&value=$&%
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^([a-z]+[a-z0-9_]*)-([a-z0-9_\-]+)\.html$ plugin.php?id=$:$&% IIS Web Server(独立主机用户)
[ISAPI_Rewrite] # = hour
CacheClockRate RepeatLimit # Protect httpd.ini and httpd.parse.errors files
# from accessing through HTTP
RewriteRule ^(.*)/topic-(.+)\.html(\?(.*))*$ $/portal\.php\?mod=topic&topic=$&$
RewriteRule ^(.*)/article-([-]+)-([-]+)\.html(\?(.*))*$ $/portal\.php\?mod=view&aid=$&page=$&$
RewriteRule ^(.*)/forum-(\w+)-([-]+)\.html(\?(.*))*$ $/forum\.php\?mod=forumdisplay&fid=$&page=$&$
RewriteRule ^(.*)/thread-([-]+)-([-]+)-([-]+)\.html(\?(.*))*$ $/forum\.php\?mod=viewthread&tid=$&extra=page\%3D$&page=$&$
RewriteRule ^(.*)/group-([-]+)-([-]+)\.html(\?(.*))*$ $/forum\.php\?mod=group&fid=$&page=$&$
RewriteRule ^(.*)/space-(username|uid)-(.+)\.html(\?(.*))*$ $/home\.php\?mod=space&$=$&$
RewriteRule ^(.*)/blog-([-]+)-([-]+)\.html(\?(.*))*$ $/home\.php\?mod=space&uid=$&do=blog&id=$&$
RewriteRule ^(.*)/(fid|tid)-([-]+)\.html(\?(.*))*$ $/index\.php\?action=$&value=$&$
RewriteRule ^(.*)/([a-z]+[a-z0-9_]*)-([a-z0-9_\-]+)\.html(\?(.*))*$ $/plugin\.php\?id=$:$&$ IIS7 Web Server(独立主机用户)
<rewrite>
<rules>
<rule name="portal_topic">
<match url="^(.*/)*topic-(.+).html\?*(.*)$" />
<action type="Rewrite" url="{R:1}/portal.php\?mod=topic&topic={R:2}&{R:3}" />
</rule>
<rule name="portal_article">
<match url="^(.*/)*article-([0-9]+)-([0-9]+).html\?*(.*)$" />
<action type="Rewrite" url="{R:1}/portal.php\?mod=view&aid={R:2}&page={R:3}&{R:4}" />
</rule>
<rule name="forum_forumdisplay">
<match url="^(.*/)*forum-(\w+)-([0-9]+).html\?*(.*)$" />
<action type="Rewrite" url="{R:1}/forum.php\?mod=forumdisplay&fid={R:2}&page={R:3}&{R:4}" />
</rule>
<rule name="forum_viewthread">
<match url="^(.*/)*thread-([0-9]+)-([0-9]+)-([0-9]+).html\?*(.*)$" />
<action type="Rewrite" url="{R:1}/forum.php\?mod=viewthread&tid={R:2}&extra=page%3D{R:4}&page={R:3}&{R:5}" />
</rule>
<rule name="group_group">
<match url="^(.*/)*group-([0-9]+)-([0-9]+).html\?*(.*)$" />
<action type="Rewrite" url="{R:1}/forum.php\?mod=group&fid={R:2}&page={R:3}&{R:4}" />
</rule>
<rule name="home_space">
<match url="^(.*/)*space-(username|uid)-(.+).html\?*(.*)$" />
<action type="Rewrite" url="{R:1}/home.php\?mod=space&{R:2}={R:3}&{R:4}" />
</rule>
<rule name="home_blog">
<match url="^(.*/)*blog-([0-9]+)-([0-9]+).html\?*(.*)$" />
<action type="Rewrite" url="{R:1}/home.php\?mod=space&uid={R:2}&do=blog&id={R:3}&{R:4}" />
</rule>
<rule name="forum_archiver">
<match url="^(.*/)*(fid|tid)-([0-9]+).html\?*(.*)$" />
<action type="Rewrite" url="{R:1}/index.php\?action={R:2}&value={R:3}&{R:4}" />
</rule>
<rule name="plugin">
<match url="^(.*/)*([a-z]+[a-z0-9_]*)-([a-z0-9_\-]+).html\?*(.*)$" />
<action type="Rewrite" url="{R:1}/plugin.php\?id={R:2}:{R:3}&{R:4}" />
</rule>
</rules>
</rewrite>
Zeus Web Server
match URL into $ with ^(.*)/topic-(.+)\.html\?*(.*)$
if matched then
set URL = $/portal.php?mod=topic&topic=$&$
endif
match URL into $ with ^(.*)/article-([-]+)-([-]+)\.html\?*(.*)$
if matched then
set URL = $/portal.php?mod=view&aid=$&page=$&$
endif
match URL into $ with ^(.*)/forum-(\w+)-([-]+)\.html\?*(.*)$
if matched then
set URL = $/forum.php?mod=forumdisplay&fid=$&page=$&$
endif
match URL into $ with ^(.*)/thread-([-]+)-([-]+)-([-]+)\.html\?*(.*)$
if matched then
set URL = $/forum.php?mod=viewthread&tid=$&extra=page\%3D$&page=$&$
endif
match URL into $ with ^(.*)/group-([-]+)-([-]+)\.html\?*(.*)$
if matched then
set URL = $/forum.php?mod=group&fid=$&page=$&$
endif
match URL into $ with ^(.*)/space-(username|uid)-(.+)\.html\?*(.*)$
if matched then
set URL = $/home.php?mod=space&$=$&$
endif
match URL into $ with ^(.*)/blog-([-]+)-([-]+)\.html\?*(.*)$
if matched then
set URL = $/home.php?mod=space&uid=$&do=blog&id=$&$
endif
match URL into $ with ^(.*)/(fid|tid)-([-]+)\.html\?*(.*)$
if matched then
set URL = $/index.php?action=$&value=$&$
endif
match URL into $ with ^(.*)/([a-z]+[a-z0-9_]*)-([a-z0-9_\-]+)\.html\?*(.*)$
if matched then
set URL = $/plugin.php?id=$:$&$
endif
并把Nginx Web Server rewrite插入到nginx.conf
[root@bqh- ~]# vim /application/nginx/conf/nginx.conf
worker_processes ;
events {
worker_connections ;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout ; server {
listen ;
server_name www.jywbbs.com;
root html/bbs;
location / {
index index.php index.html index.htm;
rewrite ^([^\.]*)/topic-(.+)\.html$ $1/portal.php?mod=topic&topic=$2 last;
rewrite ^([^\.]*)/article-([0-9]+)-([0-9]+)\.html$ $1/portal.php?mod=view&aid=$2&page=$3 last;
rewrite ^([^\.]*)/forum-(\w+)-([0-9]+)\.html$ $1/forum.php?mod=forumdisplay&fid=$2&page=$3 last;
rewrite ^([^\.]*)/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ $1/forum.php?mod=viewthread&tid=$2&extra=page%3D$4&pa
ge=$3 last;rewrite ^([^\.]*)/group-([0-9]+)-([0-9]+)\.html$ $1/forum.php?mod=group&fid=$2&page=$3 last;
rewrite ^([^\.]*)/space-(username|uid)-(.+)\.html$ $1/home.php?mod=space&$2=$3 last;
rewrite ^([^\.]*)/blog-([0-9]+)-([0-9]+)\.html$ $1/home.php?mod=space&uid=$2&do=blog&id=$3 last;
rewrite ^([^\.]*)/(fid|tid)-([0-9]+)\.html$ $1/index.php?action=$2&value=$3 last;
rewrite ^([^\.]*)/([a-z]+[a-z0-9_]*)-([a-z0-9_\-]+)\.html$ $1/plugin.php?id=$2:$3 last;
if (!-e $request_filename) {
return 404;
}
}
location ~ .*\.(php|php5)?$ {
root html/bbs;
fastcgi_pass 127.0.0.1:;
fastcgi_index index.php;
include fastcgi.conf;
}
error_page /50x.html;
}
}
[root@bqh- conf]# vim nginx.conf
[root@bqh- conf]# /application/nginx/sbin/nginx -t
nginx: the configuration file /application/nginx-1.6./conf/nginx.conf syntax is ok
nginx: configuration file /application/nginx-1.6./conf/nginx.conf test is successful
[root@bqh- conf]# /application/nginx/sbin/nginx -s reload
此时我们打开内容页网址已成伪静态url:

ok,bbs论坛搭建、url伪静态配置成功!
LNMP环境搭建BBS论坛及伪静态的更多相关文章
- LNMP环境搭建(discuz论坛)
		
一.操作系统级环境及软件版本 操作系统:CentOS release 6.5 (Final)minimal 内核版本:2.6.32-431.el6.x86_64 MySQL版本:MySQL-5.6.2 ...
 - LNMP环境搭建之php安装,wordpress博客搭建
		
LNMP环境搭建之php安装,wordpress博客搭建 一.介绍: 1.什么是CGI CGI全称是"通用网关接口"(Common Gateway Interface),HTTP服 ...
 - LNMP环境搭建:Nginx安装、测试与域名配置
		
Nginx作为一款优秀的Web Server软件同时也是一款优秀的负载均衡或前端反向代理.缓存服务软件 2.编译安装Nginx (1)安装Nginx依赖函数库pcre pcre为“perl兼容正则表达 ...
 - zabbix学习(一)——LNMP环境搭建及zabbix安装
		
第一部分:LNMP环境搭建 一.环境说明: OS: centos7.6_x64nginx:nginx-1.16.0php: php-7.1.11mysql:mysql-5.6.44 zabbi ...
 - Linux下-LNMP环境搭建博客网站(全过程)
		
通常我们所说的LNMP是指一个网站基本的组织框架,即Linux系统支持,Nginx静态服务,Mysql数据库支持以及PHP动态编程语言支持.目前Mysql数据库被Oracle数据库分析公司收购,其创始 ...
 - LNMP环境搭建
		
LNMP环境搭建 Linux + Nginx + MySQL + PHP PHP是一种脚本语言,当前中国乃至世界上使用PHP语言开发的网站非常普遍 Nginx是一个web服务软件,和apache是一类 ...
 - 阿里云(ECS)Centos服务器LNMP环境搭建
		
阿里云( ECS ) Centos7 服务器 LNMP 环境搭建 前言 第一次接触阿里云是大四的时候,当时在校外公司做兼职,关于智能家居项目的,话说当时俺就只有一个月左右的 php 后台开发经验(还是 ...
 - LNMP环境搭建——MySQL篇
		
The world's most popular open source database 1.Install MySQL root@kallen:~# apt-get install mysql-s ...
 - Ubuntu16.04 lnmp 环境搭建
		
Ubuntu16.04 lnmp 环境搭建 nginx 安装 sudo apt-add-repository ppa:nginx/stablesudo apt-add-repository ppa:o ...
 
随机推荐
- Django 引用{% url "name"%} 避免链接硬编码
			
前提条件:为每个url指定name且name值要唯一.比如: 项目中的url.py文件: urlpatterns = patterns('', url(r'^$',TemplateView.as_vi ...
 - (一)IDEA修改HTML不生效(未热部署)
			
一.问题 IDEA 版本:2018.1.2 项目类型:SpringBoot 描述 : 修改JSP文件内容时,不会热部署,需要每次都重启项目才生效. 二.解决方案 加入Springboot开发者工具,即 ...
 - SpringBoot学习笔记:读取配置文件
			
SpringBoot学习笔记:读取配置文件 配置文件 在以往的项目中,我们主要通过XML文件进行框架配置,业务的相关配置会放在属性文件中,然后通过一个属性读取的工具类来读取配置信息.在SpringBo ...
 - eclipse的maven中需要把jar的包文件登入到自己的仓库里面的操作
			
问题的描述 从别人那拿到了Java maven的工程,导入自己的eclipse中之后编译的时候出现包文件找不到,之后把工程进行maven的update project之后,pom.xml文件出现错误, ...
 - PHP与Cookie
			
不管什么语言写的cookie,本质上没区别. cookie 常用于识别用户.cookie 是服务器留在用户计算机中的小文件.每当相同的计算机通过浏览器请求页面时,它同时会发送 cookie.通过 PH ...
 - Linux将.deb以绿色免安装的方式“安装”
			
1.如果是xxx.deb文件,一般网上都是教你dkpg -i xxx.deb,但是这种方式类似windows里的安装,可能会在很多地方生成一些“垃圾”数据[比如不需要在dpkg安装应用信息文件里写入此 ...
 - 015 Android md5密码加密及其工具类
			
1.md5加密介绍 MD5算法是广泛使用的杂凑函数,也就是哈希函数,英文全拼是:Message Digest Algorithm,对应的中文名字是消息摘要算法. MD5加密:将字符串转换成 32位的字 ...
 - 原生js 实现better-scroll效果,饿了么菜单内容联动,即粘即用
			
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content ...
 - Ctex ERROR Reading
			
提供一个"Ctex ERROR Reading"的处理办法 方法/步骤: 1. 再我们打开一些网上下载的文档的时候可能出现错误提示 2. 这种问题一般是文件编码的问题,我们需要选择 ...
 - 剑指offer11:输入一个整数,输出该数二进制表示中1的个数。其中负数用补码表示。(进制转换,补码反码)
			
1. 题目描述 输入一个整数,输出该数二进制表示中1的个数.其中负数用补码表示. 2. 思路和方法 使用移位(<<)和 “| & !”操作来实现.1的二进制是:前面都是0,最后一位 ...