服务器的多域名配置

1. 常用的WEB服务器有Apache和nginx,小编偏向使用nginx。日常开发机器使用的是windows,本地测试安装的wamp,会用的Apache;生成环境是使用linux,一键安装lnmp,所以使用了nginx。

2. Nginx是一个高性能、轻量级的HTTP和反向代理服务器,也是一个IMAP/POP3/SMTP服务器。

Apache是一款老牌的Web服务器软件。它可以运行在几乎所有广泛使用的计算机平台上,由于其跨平台和安全性被广泛使用,是最流行的Web服务器端软件之一。

3. 首先要把域名指定到服务器的IP上

4. Nginx的域名配置

Nginx的配置文件是/usr/local/nginx/conf/nginx.conf,文件中

include vhost/*.conf;

可以把域名配置文件协助vhost文件下下载,为了区分开来,每个域名创建一个.conf文件,如mydomain.conf配置文件如下

server

{

listen 80 ;

server_name www.mydomain.com;

index index.html;

root /data/mydomain/wwwroot/default;

#error_page 404 /404.html;

include enable-php.conf;

location /nginx_status

{

stub_status on;

access_log off;

}

location ~ .*.(gif|jpg|jpeg|png|bmp|swf)$

{

expires 30d;

}

location ~ .*.(js|css)?$

{

expires 12h;

}

location ~ /.

{

deny all;

}

access_log /data/wwwlogs/access.log ;

}

配置好监听端口80,server_name,index,root,include enable-php.conf这是兼容php

多个域名配置多个conf文件即可下载。然后测试一下配置文件是否写正确

nginx –t

没问题了就可以重启

/etc/init.d/nginx restart

5. Apache 配置

Apache配置文件在D:wamp64binapacheapache2.4.18confextrahttpd-vhosts.conf

配置文件里面有多个VirtualHost,每个VirtualHost对应一个域名,多个域名配置多个即可

<VirtualHost *:80>

ServerName mydomain.com

DocumentRoot D:/wamp64/www/mydomain/public

<Directory “D:/wamp64/www/mydomain/public/”>

Options +Indexes +FollowSymLinks +MultiViews

AllowOverride All

Require local

</Directory>

</VirtualHost>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值