博主辛苦了,我要打赏银两给博主,犒劳犒劳站长。
【摘要】在阿里云购买了一个服务器(Linux ubuntu),有两个域名:www.mafuitan.net 和 blog.mafutian.net 这两个,此时先将这两个域名在阿里云服务器中添加域名的解析。然后在服务器的 apache 配置文件下面做一些修改。
需要修改的配置文件是:
vi /etc/apache2/sites-available/000-default
原本的内容如下:
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerName www.mafutian.net
ServerAlias www.mafutian.net
DocumentRoot /var/www/mafutian
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
修改为如下:
<VirtualHost *:80>
DocumentRoot "/var/www/www"
ServerName www.mafuitan.net
ServerAlias www.mafutian.net
<Directory "/var/www/www">
Options FollowSymLinks Indexes
AllowOverride All
Order deny,allow
Allow from all
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/var/www/blog"
ServerName blog.mafutian.net
ServerAlias blog.mafutian.net
<Directory "/var/www/blog">
Options FollowSymLinks Indexes
AllowOverride All
Order deny,allow
Allow from all
Require all granted
</Directory>
</VirtualHost>
重启 Apache 服务器:
service apache2 restart
另外可能需要修改目录 /var/www/blog 的权限,将这个目录下面的所有文件及子目录的权限设为 777:
chmod -R 777 /var/www/blog
然后访问:http://www.mafutian.net 访问的是服务器的 /var/www/www 这个目录
访问:http://blog.mafutian.net 访问的是服务器的 /var/www/blog 这是目录
(注意:不需要修改 hosts 文件)
版权归 马富天PHP博客 所有
本文标题:《ubuntu 下 apache 服务器虚拟主机的配置》
本文链接地址:http://www.mafutian.net/209.html
转载请务必注明出处,小生将不胜感激,谢谢! 喜欢本文或觉得本文对您有帮助,请分享给您的朋友 ^_^
顶0
踩0
评论审核未开启 |