如何配置 Bitnami Lightsail LAMP 服务器来托管第二个网站?
How do I configure a Bitnami Lightsail LAMP server to host a second web site?
我有一个托管单个网站的 AWS Lightsail Bitnami LAMP 实例。我想在同一台服务器上为第二个域创建站点,但尚未成功。
我复制并修改了一个httpd-vhosts.conf文件,放在了/opt/bitnami/apache2/conf中。我在指向新的 httpd-vhosts.conf 文件的 /opt/bitnami/apache2/conf/bitnami/bitnami.conf 末尾添加了一个 include 语句。尝试访问新站点或旧站点时,浏览器响应为 "Forbidden You don't have permission to access / on this server".
/opt/bitnami/apache2/conf/httpd-vhosts.conf中有两个代码块。这是其中之一。第二块与 "site1" 相同,更改为 "site2"。
<VirtualHost *:80>
ServerAdmin me@site1.com
DocumentRoot "/opt/bitnami/apache2/site1.com/htdocs"
<Directory />
Options -Indexes
AllowOverride All
</Directory>
<Directory /opt/bitnami/apache2/site1.com/htdocs>
Options -Indexes
AllowOverride All
Order allow,deny
allow from all
</Directory>
ServerName site1.com
ServerAlias www.site1.com
ErrorLog "logs/site1.com-error_log"
CustomLog "logs/site1.com-access_log" common
</VirtualHost>
似乎正在读取新的 httpd-vhosts.conf 文件,因为创建了新的错误和访问日志。错误日志指出 "client denied by server configuration:"。错误日志中与此错误关联的目录是 ...site1.com/htdocs,如 httpd-vhosts.conf 文件中所定义。
这里是 Bitnami 工程师。
让我们尝试这些更改来修复您 运行 遇到的错误:
- 删除以下块
<Directory />
Options -Indexes
AllowOverride All
</Directory>
您只需要为您的应用文件所在的文件夹设置配置。
- 您需要替换这些行,因为它们在新的 Apache 版本中不受支持
Order allow,deny
allow from all
已弃用。使用 Apache 2.4
时需要使用 Require all granted
https://httpd.apache.org/docs/2.4/mod/mod_authz_core.html#require
- 正确设置应用文件夹的权限
sudo chown -R bitnami:daemon /opt/bitnami/apache2/site1.com/htdocs
sudo chmod -R g+w /opt/bitnami/apache2/site1.com/htdocs
我有一个托管单个网站的 AWS Lightsail Bitnami LAMP 实例。我想在同一台服务器上为第二个域创建站点,但尚未成功。
我复制并修改了一个httpd-vhosts.conf文件,放在了/opt/bitnami/apache2/conf中。我在指向新的 httpd-vhosts.conf 文件的 /opt/bitnami/apache2/conf/bitnami/bitnami.conf 末尾添加了一个 include 语句。尝试访问新站点或旧站点时,浏览器响应为 "Forbidden You don't have permission to access / on this server".
/opt/bitnami/apache2/conf/httpd-vhosts.conf中有两个代码块。这是其中之一。第二块与 "site1" 相同,更改为 "site2"。
<VirtualHost *:80>
ServerAdmin me@site1.com
DocumentRoot "/opt/bitnami/apache2/site1.com/htdocs"
<Directory />
Options -Indexes
AllowOverride All
</Directory>
<Directory /opt/bitnami/apache2/site1.com/htdocs>
Options -Indexes
AllowOverride All
Order allow,deny
allow from all
</Directory>
ServerName site1.com
ServerAlias www.site1.com
ErrorLog "logs/site1.com-error_log"
CustomLog "logs/site1.com-access_log" common
</VirtualHost>
似乎正在读取新的 httpd-vhosts.conf 文件,因为创建了新的错误和访问日志。错误日志指出 "client denied by server configuration:"。错误日志中与此错误关联的目录是 ...site1.com/htdocs,如 httpd-vhosts.conf 文件中所定义。
这里是 Bitnami 工程师。
让我们尝试这些更改来修复您 运行 遇到的错误:
- 删除以下块
<Directory />
Options -Indexes
AllowOverride All
</Directory>
您只需要为您的应用文件所在的文件夹设置配置。
- 您需要替换这些行,因为它们在新的 Apache 版本中不受支持
Order allow,deny
allow from all
已弃用。使用 Apache 2.4
时需要使用Require all granted
https://httpd.apache.org/docs/2.4/mod/mod_authz_core.html#require
- 正确设置应用文件夹的权限
sudo chown -R bitnami:daemon /opt/bitnami/apache2/site1.com/htdocs
sudo chmod -R g+w /opt/bitnami/apache2/site1.com/htdocs