zoukankan      html  css  js  c++  java
  • 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; } }
  • 相关阅读:
    0099 数据类型转换 之 转为布尔:Boolean()
    0098 数据类型转换 之 转为数字: parseInt 、 parseFloat 、Number()、隐式转换
    0097 数据类型转换 之 转为字符串:toString()、String() 、加号拼接、隐式转换
    0096 获取变量数据类型typeof、字面量
    0095 布尔型Boolean,Undefined和 Null
    0094 字符串型 String
    0093 数字型 Number:整数、小数 、数字型进制、数字型范围、数字型三个特殊值、isNaN
    0092 数据类型、简单数据类型概述
    0091 交换两个变量的值( 实现思路:使用一个 临时变量 用来做中间存储 )
    SCSS 常用属性合集
  • 原文地址:https://www.cnblogs.com/lpblogs/p/7491969.html
Copyright © 2011-2022 走看看