以前常用Windows 很熟悉,lnmp 配置虚拟目录也很简单。

安装完lnmp环境之后,在nginx的配置文件夹下,我采用的方法是复制default.conf 然后重命名为vhost_a.conf 文件/vhost_b.conf

当然里面的root 网站目录要设置一下:

vhost_a.conf:

server {
listen ;
server_name b.caesar.com; #charset koi8-r;
#access_log /var/log/nginx/log/host.access.log main; location / {
root /usr/share/nginx/html/b/;
index index.html index.htm index.php;
} #error_page /.html; # redirect server error pages to the static page /50x.html
#
error_page /50x.html;
location = /50x.html {
root /usr/share/nginx/html/b;
} # proxy the PHP scripts to Apache listening on 127.0.0.1:
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:
#
location ~ \.php$ {
root /usr/share/nginx/html/b;
fastcgi_pass 127.0.0.1:;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
} # deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}

vhost_b.conf:

server {
listen ;
server_name b.caesar.com; #charset koi8-r;
#access_log /var/log/nginx/log/host.access.log main; location / {
root /usr/share/nginx/html/b/;
index index.html index.htm index.php;
} #error_page /.html; # redirect server error pages to the static page /50x.html
#
error_page /50x.html;
location = /50x.html {
root /usr/share/nginx/html/b/;
} # proxy the PHP scripts to Apache listening on 127.0.0.1:
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:
#
location ~ \.php$ {
root /usr/share/nginx/html/b/;
fastcgi_pass 127.0.0.1:;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
} # deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}

然后nginx.conf 默认加载conf.d 文件夹下的所有后缀名为.conf的文件。所以不用修改nginx.conf

include /etc/nginx/conf.d/*.conf;

然后修改服务器的hosts 文件,将域名添加进去。

vi /etc/hosts

然后在html 目录下创建你的 a,b 目录

然后~nginx重新加载配置文件,或者restart

/etc/init.d/nginx restart

根据你服务器自己的配置进行重启,

然后如果域名是虚拟的病没有解析,注意要自己的电脑加上hosts



                                                                                                              

lnmp vhost 虚拟目录配置的更多相关文章

  1. Tomcat热部署和虚拟目录配置

    1.Tomcat如何配置热部署 默认就是 <Host appBase="webapps" autoDeploy="true" name="loc ...

  2. TOMCAT服务器不写端口号、不写项目名访问项目、虚拟目录配置

    一.不写端口. 这个问题都被问烂了,因为TOMCAT默认的访问端口为8080,而TCP/IP协议默认80端口访问,大家之所以看到别的网站都不写端口号是因为人家用的的80端口访问的,而80端口因为的TC ...

  3. tomcat虚拟目录配置

    Tomcat6.0虚拟目录配置[转] 设虚拟目录 "site",通过 http://localhost:8080/site 访问物理路径 D:"site 文件夹里面的内容 ...

  4. 在apache虚拟目录配置

    在apache虚拟目录配置中 <VirtualHost *:80>xxx xxx xxx</VirtualHost> 不能写成 <VirtualHost *>xxx ...

  5. Tomcat常见问题[内存溢出,虚拟目录配置等](一)

    一.Tomcat内存溢出的解决方法 内存溢出一般有如下三种常见的原因: OutOfMemoryError: Java heap space OutOfMemoryError: PermGen spac ...

  6. apache虚拟目录配置实例

    apache虚拟目录配置实例 一.首先,开启虚拟主机配置 在文件httpd.conf中找到: include conf/extra/httpd-vhosts.conf #开启 二.对httpd-vho ...

  7. ubuntu下lnmp添加虚拟目录没有权限

    lnmp.org下载的lnmp集成环境,通过lnmp vhost tsp创建了虚拟主机目录,将此目录导入到phpstorm中时提示错误,应该时权限的问题,想通过chmod -R 777 tsp来改变t ...

  8. Tomcat虚拟目录配置方法及原理

    tomcat 安装好之后,只需要把你的程序包放到$Tomcat_Home$/webapps下就可以直接使用了.这样会使webapps越来越大就需要设置虚拟目录: 1.单个应用设置: 在<Host ...

  9. tomcat虚拟主机虚拟目录配置

    今天着实要记上一笔,需要配置tomcat虚拟目录的问题 一 首先看两个名词 appBase -- 顾名思义 就是你app所在的目录,目录下面的子目录将自动被部署为应用:war被解压并部署 docBas ...

随机推荐

  1. hibernate vs ibatis

    主要通过 灵活性,性能,开发速度 三个角度来看 1.ibatis非常简单易学,hibernate相对较复杂,门槛较高.  2.二者都是比较优秀的开源产品  3.当系统属于二次开发,无法对数据库结构做到 ...

  2. border做三角符号

    用border做三角符号以及其他图形 ;; border-width:20px 10px; border-style:solid; border-color:#ff3300 #ff3300 #ffff ...

  3. windows自带杀毒防火墙

    windows自带杀毒防火墙 Windows Defender FireWall

  4. jsp 回车代替tab 自动切换text焦点

    方法一keyCode (IE11以后失效) <html> <head> <meta http-equiv="Content-Type" content ...

  5. WDA-FPM-4-用OVP做查询跳转到明细

    转载:https://www.cnblogs.com/sapSB/p/10100697.html   FPM四:用OVP做查询跳转到明细 前面做了查询的UIBB配置,在这边可以直接复用,查询的feed ...

  6. WP8.1 页面跳转,overwrite后退键

    In 8.1 we use the below code to navigate between pages: this.Frame.Navigate(typeof(PivotPage)); In 8 ...

  7. AutoConfig工具使用

    下载安装Auto工具包: http://code.taobao.org/mvn/repository/com/alibaba/citrus/tool/antx-autoconfig/1.0.9/ant ...

  8. Why ExerciseAlone May Not Be the Key to Weight Loss

    加强运动也许并不能减肥Why ExerciseAlone May Not Be the Key to Weight LossIf you give a mouse a running wheel, i ...

  9. 利用 setInterval 确定用户的动作是否停止

    最近遇到一个问题,对于某一个持续的动作,希望能够知晓用户何时停止这个动作, 比如说 我们通过注册onresize事件,去监听浏览器窗口变化的事件,在这个事件里面,我们可能要执行大量的计算去确定窗口变化 ...

  10. mark_2017_2_27

    工作总结web_acl 535 git clone “ssh://git@outergit.yonyou.com:49622/esn_web/web_acl.git" 600 git bra ...