• Linux lnmp 配置虚拟域名 vhost


    1、首先假设我们的项目在 /home/wwwroot/default/bathroom  (bathroom 就是我们的框架项目)

    具体过程如下:

    1、cd /usr/local/nginx/conf/vhost 目录下

    2、vim example1.com.conf 创建一个文件并把以下内容拷贝进去 ↓: 

    server {
    
      listen 80;
      server_name example1.com www. example1.com;    #域名名称  以及二级虚拟域名
      #access_log /www/access_ example1.log main;   #访问记录日志存储位置
    
      location / {
        root /www/example1.com;            # 例如:root /home/wwwroot/default/Bathroom  (因为make安装的lnmp环境,默认项目根路径在/home/wwwroot/default/下访问)
        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 /www/example1.com/$fastcgi_script_name;  #这里需要改成/home/wwwroot/default/Bathroom/ (项目根目录)
        include fastcgi_params;
      }
    
      location ~ /.ht {
        deny all;
      }
    }

    注意:可能你会想虚拟域名不是配置在nginx文件中吗。为什么会配置vhost下面

    你可以  vim /user/local/nginx/conf/nginx.conf   配置文件

    找到:,这里默认引入 vhost 下所有的文件,所以更方便管理

    -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    我的案例:

    server {
    
        listen 80;
        server_name www.bathroomstation.com;
        #access_log /www/access_ example1.log main;
    location
    / { root /home/wwwroot/default/Bathroom; 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$ { $的意思是默认以.php文件结尾 location ~ .php(.*) {
    fastcgi_pass
    127.0.0.1:9000; fastcgi_index index.php; # 配置pathinfo模式,访问不在出现404 fastcgi_param PATH_INFO $1; fastcgi_param SCRIPT_FILENAME /home/wwwroot/default/Bathroom/$fastcgi_script_name; include fastcgi_params; } location ~ /.ht { deny all; } }
  • 相关阅读:
    Android Studio 快捷键
    维基百科地址(应该是吧)
    Freeswitch常見問題解決辦法
    配置SIP网关拨打外部电话
    Freeswitch连接SIP软电话
    CentOS6.5安装freeswitch以及啟動
    hdu 4292: Food(Dinic + 链式前向星)
    hdu 2709:Sumsets(递推)
    hdu 2577:How to Type(动态规划)
    hdu 2955:Robberies(01背包)
  • 原文地址:https://www.cnblogs.com/lpblogs/p/7491969.html
Copyright © 2020-2023  润新知