以前常用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. 解决Visual Studio “无法导入以下密钥文件”的错误

    错误1无法导入以下密钥文件: Common.pfx.该密钥文件可能受密码保护.若要更正此问题,请尝试再次导入证书,或手动将证书安装到具有以下密钥容器名称的强名称 CSP: VS_KEY_ 1110Co ...

  2. python入门-字典

    1 python是使用{}来表示字典 字典是一系列的键值对 alien_0={} 2 访问字典中的值 new_point = alien_0['point'] print("you just ...

  3. python入门-IF语句

    1 格式 cars = ['audi','bmw','subaru','toyata'] for car in cars: if car =='bmw': print(car.upper()) els ...

  4. LaTeX 公式字体大小设置

    字体大小: 七号 5.25pt   1.845mm \tiny六号 7.875pt  2.768mm \scriptsize小五号 9pt  3.163mm \footnotesize五号 10.5p ...

  5. php7---redis

    wget https://github.com/phpredis/phpredis/archive/php7.zip cd /usr/local/src/ phpredis-php7 /usr/loc ...

  6. kubernet使用笔记

    centos7.3下安装及部署:http://www.linuxidc.com/Linux/2017-02/140723.htm

  7. 内容方框 fieldset

    Title 登录 用户名 密码 <!DOCTYPE html><html lang="en"><head> <meta charset=& ...

  8. python中 cmp

    python3.*版本中取消了数值之间的比较:cmp(x, y).取而代之的是 (x > y) - (x < y) 因为python中 false 为 0, true 为 1.

  9. Qt 软件的发布

    我们程序的Release版本正式发布需要将各种依赖的库文件一起打包. 有时候我们并不清楚具体依赖哪些库,这时,可以用Qt的一个工具"windeployqt" 比如,找到程序.exe ...

  10. Xtrabackup安装及使用

    官方安装步骤:https://www.percona.com/doc/percona-xtrabackup/2.4/installation/yum_repo.html 安装percona repo源 ...