/public_html/httptest.php' 未找到或无法统计 - LAMP

/public_html/httptest.php' not found or unable to stat - LAMP

我目前在 LAMP 服务器上设置了一个域,我想再添加一个。我尝试自己做,但是当我 运行 遇到问题时,我遵循 this.

我已经 example.com 设置并且工作正常,所有流量都会重定向到它的 https,我想继续这样做。尝试重新启动 apache2 后,我现在收到一条错误消息:

script '/var/www/html/test.ca/public_html/httptest.php' not found or unable to stat

我已经在我的 apache2.conf 文件中搜索了 httptest.php,但没有找到匹配项。

/etc/apache2/sites-available/000-default.conf

<VirtualHost *:80>
    ServerName example.com
    Redirect permanent / https://example.com/
</VirtualHost>
<VirtualHost *:80>
    ServerName test.ca
    Redirect permanent / http://test.ca
</VirtualHost>
<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>

<VirtualHost *:443>
    ServerAdmin example@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/example.com.conf

<VirtualHost *:80>
    ServerName example.com
    Redirect permanent / https://example.com/
</VirtualHost>
<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>

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

<VirtualHost *:80>
    ServerName test.ca
    Redirect permanent / http://test.ca
</VirtualHost>
<VirtualHost *:444>
    ServerAdmin example@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/hosts 文件说(它有我的 ip):

127.0.0.1 myservername

当我在 /var/www/html/ 中执行 ls -l 时,我得到:

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

然后改为:

-rw-r--r-- 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

我有 运行 下面的代码,它说它对两者都启用了:

sudo a2ensite example.com
sudo a2ensite test.ca

apache 重启时出现错误。

你激活虚拟主机了吗?如果不是...
使用内置的 apache 快捷方式激活主机:

sudo a2ensite example.com
sudo a2ensite test.ca

并重启 Apache 服务:

sudo service apache2 restart

还要检查项目文件夹的权限