服务器的多域名配置php
1. 经常使用的WEB服务器有Apache和nginx,小编偏向使用nginx。平常开发机器使用的是windows,本地测试安装的wamp,会用的Apache;生成环境是使用linux,一键安装lnmp,因此使用了nginx。css
2. Nginx是一个高性能、轻量级的HTTP和反向代理服务器,也是一个IMAP/POP3/SMTP服务器。html
Apache是一款老牌的Web服务器软件。它能够运行在几乎全部普遍使用的计算机平台上,因为其跨平台和安全性被普遍使用,是最流行的Web服务器端软件之一。linux
3. 首先要把域名指定到服务器的IP上nginx
4. Nginx的域名配置apache
Nginx的配置文件是/usr/local/nginx/conf/nginx.conf,文件中windows
include vhost/*.conf;安全
能够把域名配置文件协助vhost文件下,为了区分开来,每一个域名建立一个.conf文件,如mydomain.conf配置文件以下服务器
serverdom
{
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>
6. 总之,服务器的多域名配置就这么简单,若有遗漏,请多指正。
wxgzh:ludong86