树莓派实现多个站点配置的方法

        因为一直没办法在raspbian上解决机械硬盘休眠问题,不得以使用OMV 系统。没想到OMV系统使用起来相当的理想。可以远程通过WEB界面管理树莓派。现在想在树莓派上搭建ARIA2的WEB-GUI端,以便能访问时,不用一直设置RPC地址。但80端口已经被OMV管理页面占用,所以得想办法使用其他端口来访问ARIA2-WEB-GUI页面。经过一翻摸索,解决步骤如下:
================================================================
以下文字及图片引用自http://blog.csdn.net/yongzhang52545/article/details/51282914
================================================================

首先找到nginx的配置文件nginx.conf
[plain] view plain copy

  1. [root@localhost nginx]# vi nginx.conf  


打开配置文件后找到类似下面一段:

[plain] view plain copy

  1. include /etc/nginx/conf.d/*.conf;  
没有的就加上,这是我的路径,你们的看实际情况改改,确保路径存在
加入这段的意思实际是把conf.d目录的以.conf结尾的配置文件都加载进来,修改后保存nginx.conf文件
然后进入conf.d目录
[plain] view plain copy

  1. [root@localhost nginx]# cd /etc/nginx/conf.d/  


然后把目录下面的文件都列出来:

[plain] view plain copy

  1. [root@localhost conf.d]# ll  

默认的话,目录下面有个default.conf文件

打开default.conf文件后如下:
[plain] view plain copy

  1. server {  
  2.     listen       80;  
  3.     server_name  localhost;  
  4.   
  5.     #charset koi8-r;  
  6.     access_log  /var/log/nginx/access.log  main;  
  7.   
  8.     root        /var/www/baidu;  
  9.     index       index.php index.html index.htm;  
  10.     location / {  
  11.         try_files $uri $uri/ =404;  
  12.     }  
  13.   
  14.     error_page  404              /404.html;  
  15.   
  16.     # redirect server error pages to the static page /50x.html  
  17.     #  
  18.     error_page   500 502 503 504  /50x.html;  
  19.     location = /50x.html {  
  20.         root   /var/www;  
  21.     }  
  22.   
  23.     # proxy the PHP scripts to Apache listening on 127.0.0.1:80  
  24.     #  
  25.     #location ~ \.php$ {  
  26.     #    proxy_pass   http://127.0.0.1;  
  27.     #}  
  28.   
  29.     # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000  
  30.     #  
  31.     location ~ \.php($|/) {  
  32.         try_files $uri =404;  
  33.         #rewrite ^/index.php/(.*)$  /$1 last;  
  34.         fastcgi_pass unix:/var/www/php-fpm.sock;  
  35.         fastcgi_index index.php;  
  36.         fastcgi_param PATH_INFO $fastcgi_path_info;  
  37.         fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;  
  38.         include fastcgi_params;  
  39.   
  40.         fastcgi_intercept_errors on;  
  41.         fastcgi_ignore_client_abort off;  
  42.         fastcgi_connect_timeout 60;  
  43.         fastcgi_send_timeout 180;  
  44.         fastcgi_read_timeout 180;  
  45.         fastcgi_buffer_size 128k;  
  46.         fastcgi_buffers 4 256k;  
  47.         fastcgi_busy_buffers_size 256k;  
  48.         fastcgi_temp_file_write_size 256k;  
  49.     }  
  50.     #location ~ \.php$ {  
  51.     #    root           html;  
  52.     #    fastcgi_pass   127.0.0.1:9000;  
  53.     #    fastcgi_index  index.php;  
  54.     #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;  
  55.     #    include        fastcgi_params;  
  56.     #}  
  57.   
  58.     # deny access to .htaccess files, if Apache's document root  
  59.     # concurs with nginx's one  
  60.     #  
  61.     #location ~ /\.ht {  
  62.     #    deny  all;  
  63.     #}  
  64. }  


如果把上面的配置作为本地配置一个百度网站的设置,那么其访问的端口为默认80端口,访问地址就是:http://localhost/

如果我们想用81端口配置为本地的另外一个网站的访问入口,应该怎么配置呢?
首先你需要在conf.d目录下创建一个以.conf结尾的文件,比如:google.com.conf文件,或者直接copy一个default.conf文件也可以,具体配置如下:

[plain] view plain copy

  1. server {  
  2.     listen       81;  
  3.     server_name  localhost;  
  4.   
  5.     #charset koi8-r;  
  6.     access_log  /var/log/nginx/access.log  main;  
  7.   
  8.     root        /var/www/google;  ##------》此处需要改为ARIA2-WEB-GUI程序的实际地址。
  9.     index       index.php index.html index.htm;  
  10.     location / {  
  11.         try_files $uri $uri/ =404;  
  12.     }  
  13.   
  14.     error_page  404              /404.html;  
  15.   
  16.     # redirect server error pages to the static page /50x.html  
  17.     #  
  18.     error_page   500 502 503 504  /50x.html;  
  19.     location = /50x.html {  
  20.         root   /var/www;  
  21.     }  
  22.   
  23.     # proxy the PHP scripts to Apache listening on 127.0.0.1:80  
  24.     #  
  25.     #location ~ \.php$ {  
  26.     #    proxy_pass   http://127.0.0.1;  
  27.     #}  
  28.   
  29.     # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000  
  30.     #  
  31.     location ~ \.php($|/) {  
  32.         try_files $uri =404;  
  33.         #rewrite ^/index.php/(.*)$  /$1 last;  
  34.         fastcgi_pass unix:/var/www/php-fpm.sock;  
  35.         fastcgi_index index.php;  
  36.         fastcgi_param PATH_INFO $fastcgi_path_info;  
  37.         fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;  
  38.         include fastcgi_params;  
  39.   
  40.         fastcgi_intercept_errors on;  
  41.         fastcgi_ignore_client_abort off;  
  42.         fastcgi_connect_timeout 60;  
  43.         fastcgi_send_timeout 180;  
  44.         fastcgi_read_timeout 180;  
  45.         fastcgi_buffer_size 128k;  
  46.         fastcgi_buffers 4 256k;  
  47.         fastcgi_busy_buffers_size 256k;  
  48.         fastcgi_temp_file_write_size 256k;  
  49.     }  
  50.     #location ~ \.php$ {  
  51.     #    root           html;  
  52.     #    fastcgi_pass   127.0.0.1:9000;  
  53.     #    fastcgi_index  index.php;  
  54.     #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;  
  55.     #    include        fastcgi_params;  
  56.     #}  
  57.   
  58.     # deny access to .htaccess files, if Apache's document root  
  59.     # concurs with nginx's one  
  60.     #  
  61.     #location ~ /\.ht {  
  62.     #    deny  all;  
  63.     #}  
  64. }  


保存后,重启nginx服务器

访问:http://localhost:81看看是否成功吧。
注意:配置里面的目录文件一定要存在,不然无法启动nginx。

评论

此博客中的热门博文

aria2 下载时出现errorcode=19 name resolution failed错误的解决办法

KODI(XMBC)安装中文字幕插件

CENTOS 7搭建Resilio-sync 官方指导步骤