标签:用户 场景 div top 配置 min www ase oms
1.0 Nginx介绍
http1.1版本–host(域名) 一个web服务器可以有多个站点,一个站点就是一个虚拟主机。定义虚拟主机的名字用域名来定义。
1.1 如何检测80端口通不通安装telnet
# yum install -y telnet
1.2 检测80端口
# telnet 192.168.109.133 80 Trying 192.168.109.133... telnet: connect to address 192.168.109.133: No route to host
1.3 说明80端口是不通的,centos7自带firewalld服务,开启状态。建议不要关闭防火墙。做实验想简单点可以关闭
# systemctl stop firewalld
1.4 或者添加80端口
# firewall-cmd --add-port=80/tcp --permanent
1.5 添加80端口还需要重载生效
# firewall-cmd --reload
1.6 现在自定义host到Windows上去设置,因为我们没有购买此域名,配置centos.com配置文件centos.com.conf
server { listen 80; server_name centos.com; index index.html index.htm index.php; root /data/wwwroot/default; }
1.7 配置aaa.com配置文件aaa.com.conf
server { listen 80 default_server; server_name aaa.com; index index.html index.htm index.php; root /data/wwwroot/aaa.com; }
默认虚拟主机:就是nginx的第一个虚拟主机,泛解析、禁掉默认虚拟主机,加一行deny all;
1.8 做个博客站点vim blog.linux.com.conf
server { listen 80 default_server; server_name blog.linux.com; deny all; index index.html index.htm index.php; root /data/wwwroot/blog.linux.com; }
1.9 需要创建/data/wwwroot/blog.linux.com 的目录
# mkdir /data/wwwroot/blog.linux.com
2.0 安装wrodpress,需要配置blog.linux.com配置文件解析php
server { listen 80; server_name blog.linux.com www.luquan.com; if ( $host = blog.linux.com ) { rewrite /(.*) http://www.luquan.com/$1 permanent; } index index.html index.htm index.php; root /data/wwwroot/blog.linux.com; location ~ \.php$ { include fastcgi_params; fastcgi_pass unix:/tmp/php-fcgi.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /data/wwwroot/blog.linux.com$fastcgi_script_name; } }
到官网下载
解压wordpress
移动位置
# mv wordpress/* /data/wwwroot/bolg.linux.com
设置Windows的hotts-blog.linux.com添加 访问blog.linux.com安装
2.1 设置数据库
create database blog;
2.2 创建用户
grant all on blog.* to ‘blog’@‘127.0.0.1’ identified by ‘123456’;
2.3 切换某个库
use blog;
2.4 查询库里有什么表
show tables;
2.5 问题处理:在安装wordoress过程中,需要设定网站程序目录权限,属主设定为php-fpm服务的那个用户:
# chown -R php-fpm /data/wwwroot/blog.linux.com
输入域名照着提示安装wordpress即可
# yum install -y git
3.1 克隆discuz到root目录下
# git clone https://gitee.com/ComsenzDiscuz/DiscuzX.git
3.2 拷贝upload到bbs.lingx.com
# cp -r DiscuzX/upload /data/wwwroot/bbs.linux.com
3.3 定义虚拟主机配置文件
# cp blog.linux.com.conf bbs.linux.com.conf
3.4 修改bbs.linux.com.conf里面的目录vim命令模式下
:1,$s/blog.linux.com/bbs.linux.com/g
3.5 重载配置文件
# /usr/local/nginx/sbin/nginx -t # /usr/local/nginx/sbin/nginx -s reload
3.6 开始安装,进入跟目录给权限
# cd /data/wwwroot/bbs.linux.com # chown -R php-fpm config data us_server/data uc_client/data
3.7 定义数据库相关操作进入数据库,创建库
# create database bbs
3.8 创建用户
# grant all on bbs.* to ‘bbs‘@127.0.0.1 identified by ‘123456‘;
安装discuz
两个域名从一个域名跳转到另外一个域名
配置blog.linux.com.conf,假如说你还有一个域名www.linux.com两个都不想舍弃
server { listen 80; server_name blog.linux.com www.linux.com; if ( $host = blog.linux.com ) { rewrite /(.*) http://www.linux.com/$1 permanent; } index index.html index.htm index.php; root /data/wwwroot/blog.linux.com; location ~ \.php$ { include fastcgi_params; fastcgi_pass unix:/tmp/php-fcgi.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /data/wwwroot/blog.linux.com$fastcgi_script_name; } }
添加这一行
if ( $host = blog.linux.com ) { rewrite /(.*) http://www.linux.com/$1 permanent; }
解释访问blog.linux.com/?p=1就会跳转到www.linux.com/?p=1
premanent是状态码
检测语法重载
# /usr/local/nginx/sbin/nginx -t # /usr/local/nginx/sbin/nginx -s reload
测试
# curl -x127.0.0.1:80 -I blog.linux.com/?p=1 HTTP/1.1 301 Moved Permanently Server: nginx/1.17.0 Date: Sat, 12 Oct 2019 12:21:05 GMT Content-Type: text/html Content-Length: 169 Connection: keep-alive Location: http://www.linux.com/?p=1 ##着重看着这行
测试不存在的页面
# curl -x127.0.0.1:80 -I blog.linux.com/abc/admin/1.txt HTTP/1.1 301 Moved Permanently Server: nginx/1.17.0 Date: Sat, 12 Oct 2019 12:23:07 GMT Content-Type: text/html Content-Length: 169 Connection: keep-alive Location: http://www.linux.com/abc/admin/1.txt
测试,修改配置文件
server { listen 80; server_name blog.linux.com www.linux.com; if ( $host = blog.linux.com ) { rewrite /(.*) http://www.linux.com/$1 permanent; } rewrite /1.txt /2.txt redirect; index index.html index.htm index.php; root /data/wwwroot/blog.linux.com; location ~ \.php$ { include fastcgi_params; fastcgi_pass unix:/tmp/php-fcgi.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /data/wwwroot/blog.linux.com$fastcgi_script_name; } }
重载配置文件
用www.linux.com测试因为blog.linux.com已经做了跳转
# curl -x127.0.0.1:80 -I www.linux.com/1.txt HTTP/1.1 302 Moved Temporarily Server: nginx/1.17.0 Date: Sat, 12 Oct 2019 12:24:36 GMT Content-Type: text/html Content-Length: 145 Location: http://www.linux.com/2.txt Connection: keep-alive
着重看状态码
标签:用户 场景 div top 配置 min www ase oms
原文地址:https://www.cnblogs.com/yantou/p/11663693.html