【发布时间】:2020-03-13 15:34:09
【问题描述】:
我无法在 Apache 中配置虚拟主机,尽管我按照instructions 做所有事情。是什么原因? 我正在尝试在 Apache 中配置虚拟主机,但它失败了。我执行指令没有问题,但这对我不起作用。
Ubuntu 18.04。根目录是/var/www/html
有一个 index.html 并且可以从网络访问。 现在,如果您只是在浏览器中输入该站点的地址,那么它仍然会显示 /var/www/html/index.php,而不是 index.html > 从虚拟主机。也就是说,事实证明虚拟主机根本不起作用。
我做了以下事情:
sudo mkdir -p /var/www/xxxxxx.xx/html
sudo chown -R $USER:$USER /var/www/xxxxxx.xx/html
sudo chmod -R 755 /var/www/xxxxxx.xx
nano /var/www/xxxxxx.xx/html/index.html
在此处添加页面代码。
sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/xxxxxx.xx.conf
sudo nano /etc/apache2/sites-available/xxxxxx.xx.conf
我插入到 xxxxxx.xx.conf:
<VirtualHost *:80>
ServerAdmin host1@gmail.com
ServerName xxxxxx.xx
ServerAlias www.xxxxxx.xx
DocumentRoot /var/www/xxxxxx.xx/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
DirectoryIndex index.php
</VirtualHost>
sudo a2ensite xxxxxx.xx.conf
sudo a2dissite 000-default.conf
sudo systemctl restart apache2
目录权限:
user1@host1:/var/www$ ls -l
total 12
drwxr-xr-x 3 root root 4096 Nov 14 11:05 xxxxxx.xx
drwxr-xr-x 13 www-data www-data 4096 Nov 13 16:14 html
drwxr-xr-x 4 user1 user1 4096 Nov 12 11:03 html-bk
user1@host1:/var/www/xxxxxx.xx$ ls -l
total 4
drwxr-xr-x 2 user1 user1 4096 Nov 14 11:08 html
user1@host1:/var/www/xxxxxx.xx/html$ ls -l
total 4
-rw-rw-r-- 1 user1 user1 177 Nov 14 11:08 index.html
怎么了?我是第一次设置Apache,但是按照说明,执行过程中没有错误。
【问题讨论】:
标签: apache ubuntu-18.04