Apache使用http& amp;设置多个域HTTPS

时间:2016-01-15 03:16:54

标签: php linux apache ubuntu

我一直在尝试将第二个域添加到我的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>

2 个答案:

答案 0 :(得分:0)

您可能需要启用网站。

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

尝试

$   sudo a2ensite 000-test.ca.conf

答案 1 :(得分:0)

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

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)最后重启apache sudo service apache2 restart

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