小米路由折腾指南终结版
小米路由器折腾指南终于要完结了,折腾到这,我基本上把我的路由器打造的我个人使用没有什么压力了,最后一篇是一个收尾的工作。主要讲两点。
- 自动化安装Nginx-Mysql-PHP
- Nginx 多域名配置
LNMP自动化脚本
脚本很简单,不多说,直接引用介绍。
Nginx多域名配置
这个主要是因为Ngixn会占用一个端口80,如果也想通过域名访问,之前路由器界面就要配置一下Nginx的设置了。
具体方法如下:
下面是具体的配置过程:
- 在 /opt/etc/nginx/ 下创建 vhosts 目录
mkdir /etc/nginx/vhosts
- 在 /opt/etc/nginx/vhosts/ 里创建一个名字为 的文件,把以下内容拷进去(注意里面的server_name配置换成你自己的名称)
server {
listen 80;
server_name
access_log example1.log main;
location / {
root
index index.php index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
}
- 打开 /opt/etc/nginix.conf 文件,在相应位置加入 include 把以上2个文件包含进来
user nginx;
worker_processes 1;
# main server error log
error_log /var/log/nginx/error.log ;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
# main server config
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"';
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
gzip on;
server {
listen 80;
server_name _;
access_log /var/log/nginx/access.log main;
server_name_in_redirect off;
location / {
root /usr/share/nginx/html;
index index.html;
}
}
# 包含所有的虚拟主机的配置文件
include /usr/local/etc/nginx/vhosts/*;
}
5、重启 Nginx
/opt/etc/init.d/nginx restart
这样设置完就可以即访问自己的网站也不会影响路由器界面了。
尾巴
小米路由的折腾写了很久了,时间跨度怕是有一年了,这一年折腾了很多个不眠之夜,虽然自己很累但是真的很开心。:)