ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 【Nginx】Nginx虚拟vhost配置文件

【Nginx】Nginx虚拟vhost配置文件

原创 Linux操作系统 作者:小亮520cl 时间:2016-08-11 09:42:52 0 删除 编辑
Nginx可以采用vhost虚拟配置文件配置多个conf,多个域名多个配置文件方便管理
主配置文件

  1. [root@iZ251xiy3yfZ conf]# more nginx.conf

  2. #user nobody;
  3. worker_processes 1;

  4. #error_log logs/error.log;
  5. #error_log logs/error.log notice;
  6. #error_log logs/error.log info;

  7. #pid logs/nginx.pid;


  8. events {
  9.     worker_connections 1024;
  10. }


  11. http {
  12. server
  13. {
  14.     listen 80;
  15.     server_name _;
  16.     root /tmp/fuckyou;
  17.     location /phpfpm-status
  18.     {
  19.         fastcgi_pass 127.0.0.1:9000;
  20.         fastcgi_param SCRIPT_FILENAME $fastcgi_script_name;
  21.         allow 127.0.0.1;
  22.         deny all;
  23.     }


  24.     location /nginx_status
  25.     {
  26.         stub_status on;
  27.         access_log off;
  28.         allow 127.0.0.1;
  29.         deny all;
  30.     }
  31. }
  32. server
  33.    {
  34.      listen 8080;
  35.      server_name _;
  36.      return 403;
  37.    }

  38. include vhost/*.conf;
  39. }



  1. 某个域名配置文件

  1. [root@iZ251xiy3yfZ conf]# more vhost/testapi.luobohr.com.conf
  2.     server {
  3.         listen 80;
  4.         server_name testapi.luobohr.com ;
  5.         root /home/wwwroot/api.luobohr.com;    ##域名与目录

  6.         location / {
  7.                 index index.php index.html;
  8.                 if ( !-e $request_filename){
  9.                         rewrite ^/(.*)$ /index.php?s=$1 last;
  10.                         break;
  11.                 }
  12.         }


  13.         location ~ .*\.(php|php5)?$ {
  14.             root /home/wwwroot/api.luobohr.com;          目录

  15.                 try_files $uri =404;
  16.                 fastcgi_pass 127.0.0.1:9000;               ----php-fpm端口
  17.                 fastcgi_index index.php;
  18.                         fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  19.                 include fastcgi_params;
  20.         }
  21.         location ~ /.git
  22.         {
  23.             return 403;
  24.         }
  25.          location ~* ^/Admin{
  26.             return 403;
  27.         }

  28.          location ~* ^/bank{
  29.             return 403;
  30.         } 
  31.     }

与http的alias差不多的
  1. cat /etc/httpd/conf.d/zabbix.conf
  2. #
  3. # Zabbix monitoring system php web frontend
  4. #

  5. Alias /zabbix /usr/share/zabbix

  6. <Directory "/usr/share/zabbix">
  7.     Options FollowSymLinks
  8.     AllowOverride None
  9.     Require all granted

  10.     <IfModule mod_php5.c>
  11.         php_value max_execution_time 300
  12.         php_value memory_limit 128M
  13.         php_value post_max_size 16M
  14.         php_value upload_max_filesize 2M
  15.         php_value max_input_time 300
  16.         php_value always_populate_raw_post_data -1
  17.         # php_value date.timezone Europe/Riga
  18.     </IfModule>
  19. </Directory>

  20. <Directory "/usr/share/zabbix/conf">
  21.     Require all denied
  22. </Directory>

  23. <Directory "/usr/share/zabbix/app">
  24.     Require all denied
  25. </Directory>

  26. <Directory "/usr/share/zabbix/include">
  27.     Require all denied
  28. </Directory>

  29. <Directory "/usr/share/zabbix/local">
  30.     Require all denied
  31. </Directory>
访问http://****/zabbix/   指向这个目录


来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/29096438/viewspace-2123306/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
毕业以后专业任职数据库工程师职位,itpub一直作为自己的笔记记录的地方,blog写的不详细,草书笔记,仅供参考!

注册时间:2013-09-12

  • 博文量
    529
  • 访问量
    1126950