【问题标题】:Apache Setting up multiple domains with http & httpsApache 使用 http 和 https 设置多个域
【发布时间】:2016-01-15 03:16:53
【问题描述】:

我一直在尝试向我的 apache ubuntu 服务器添加第二个域。我没有收到任何错误,但是当我转到“test.ca”时,它仍然重定向到“example.com”。我错过了什么??我希望一台服务器上的两个域都转到它们自己的文件夹。

How To Set Up Apache Virtual Hosts on Ubuntu 14.04 LTS

How To Set Up Apache Virtual Hosts on Ubuntu 12.04 LTS

How do I set up apache with multiple sites?

Hosting multiple websites with Apache2

Test.ca 错误日志为空。

Tounder.com 错误日志为空。

Apache 错误日志为空。

/var/下的权限:

drwxr-xr-x  3 root root   4096 Dec 15 20:49 www

/var/www/html/下的权限:

-rwxr-xr-x 1 root root 11510 Dec 15 20:49 index.html
drwxr-xr-x 4 sys  sys   4096 Jan 11 19:19 test.ca
drwxr-xr-x 4 sys  sys   4096 Dec 15 21:00 example.com

/etc/apache2/ports.conf:

Listen 80

<IfModule ssl_module>
        Listen 443
</IfModule>

<IfModule mod_gnutls.c>
        Listen 443
</IfModule>

/etc/hosts:

myip servername
myip test.ca
myip example.com

/etc/apache2/sites-available/000-default.conf 为空。

/etc/apache2/sites-available/000-test.ca.conf:

<VirtualHost *:80>
    ServerAdmin test@gmail.com
    ServerName test.ca
    ServerAlias www.test.ca
    DocumentRoot /var/www/html/test.ca/public_html/
    ErrorLog /var/www/html/test.ca/logs/error.log
    CustomLog /var/www/html/test.ca/logs/access.log combined
    <Directory /var/www/html/test.ca/>
            Require all granted
    </Directory>
</VirtualHost>

/etc/apache2/sites-available/000-example.com.conf:

<VirtualHost *:443>
    SSLEngine On
    SSLCertificateFile /etc/ssl/localcerts/example.com.crt
    SSLCertificateKeyFile /etc/ssl/localcerts/example.com.key
    SSLCACertificateFile /etc/ssl/localcerts/intermediate.crt

    ServerAdmin example@gmail.com
    ServerName example.com
    ServerAlias www.example.com
    DocumentRoot /var/www/html/example.com/public_html/
    ErrorLog /var/www/html/example.com/logs/error.log
    CustomLog /var/www/html/example.com/logs/access.log combined
    <Directory /var/www/html/example.com/>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride all
            Order allow,deny
            allow from all
    </Directory>
</VirtualHost>

【问题讨论】:

  • Stackoverflow 用于编程相关问题。来自 SO 帮助:“有关专业服务器或网络相关基础设施管理的问题对于 Stack Overflow 来说是无关紧要的,除非它们直接涉及编程或编程工具。您可以通过 Server Fault 获得帮助。

标签: php linux apache ubuntu


【解决方案1】:

您可能需要启用网站。

如果你去 /etc/apache2/sites-enabled/ 里面有什么吗?

试试

$   sudo a2ensite 000-test.ca.conf

【讨论】:

  • 你完成这一步后是否重启了apache?
  • 是的,我确实重启了 apache
【解决方案2】:

检查以下列表以确保您的虚拟主机配置正确:

1) 在sudo nano /etc/hosts 中有您的虚拟主机域名。这里111.111.111.111 test.ca

2) 创建 sudo nano /etc/apache2/sites-available/test.ca.conf 。不要在文件前面加上“000-”。 文件内容:

<VirtualHost *:80>
    ServerAdmin admin@test.ca
    ServerName test.ca
    ServerAlias www.test.ca
    DocumentRoot /var/www/test.ca/public_html
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

3) 运行命令启用test.ca sudo a2ensite test.com.conf

4) 最后重启apachesudo service apache2 restart

现在您可以在浏览器中加载 test.ca。

【讨论】:

    猜你喜欢
    • 2012-01-20
    • 2020-05-08
    • 2012-06-24
    • 1970-01-01
    • 2013-07-13
    • 2021-03-05
    • 2016-03-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多