在 OVH 上部署 Symfony 4 项目
Deploy Symfony 4 project on OVH
我正在尝试在 OVH 上部署使用 Symfony 4 创建的网站。
我有两个 .htaccess 文件(1 个在我的代码所在的 www 文件夹的根目录中,另一个在我的 public 文件夹中):
RewriteEngine on
RewriteBase /
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://example.com/ [R,L]
RewriteCond %{REQUEST_URI} !^/public/
RewriteRule ^(.*)$ /public/ [L] `
在我的 public 文件夹中:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
但是当我尝试访问我的网站时出现 404 错误。
有人知道问题出在哪里吗?
OVH 是您的托管服务,它不会向我们提供有关您的服务器配置和安装的任何信息。你使用 Nginx 还是 Apache? PHP FPM 或 PHP CGI ?
因为您使用的是 .htaccess
文件,所以我假设您已经安装了 Apache。
Symfony 有一个方法可以在 Apache 上为 运行 安装正确的重写规则。
您可以通过执行以下命令 运行 它:
composer require symfony/apache-pack
根据您的 PHP 安装(CGI 或 FPM),运行ning Symfony 在 Apache 上有不同的配置。对于 PHP-CGI:
<VirtualHost *:80>
ServerName domain.tld
ServerAlias www.domain.tld
DocumentRoot /var/www/project/public
<Directory /var/www/project/public>
AllowOverride All
Order Allow,Deny
Allow from All
</Directory>
# uncomment the following lines if you install assets as symlinks
# or run into problems when compiling LESS/Sass/CoffeeScript assets
# <Directory /var/www/project>
# Options FollowSymlinks
# </Directory>
ErrorLog /var/log/apache2/project_error.log
CustomLog /var/log/apache2/project_access.log combined
</VirtualHost>
所有这些信息都可以在官方文档中找到:Symfony Web Server Configuration
我正在尝试在 OVH 上部署使用 Symfony 4 创建的网站。 我有两个 .htaccess 文件(1 个在我的代码所在的 www 文件夹的根目录中,另一个在我的 public 文件夹中):
RewriteEngine on
RewriteBase /
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://example.com/ [R,L]
RewriteCond %{REQUEST_URI} !^/public/
RewriteRule ^(.*)$ /public/ [L] `
在我的 public 文件夹中:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
但是当我尝试访问我的网站时出现 404 错误。
有人知道问题出在哪里吗?
OVH 是您的托管服务,它不会向我们提供有关您的服务器配置和安装的任何信息。你使用 Nginx 还是 Apache? PHP FPM 或 PHP CGI ?
因为您使用的是 .htaccess
文件,所以我假设您已经安装了 Apache。
Symfony 有一个方法可以在 Apache 上为 运行 安装正确的重写规则。
您可以通过执行以下命令 运行 它:
composer require symfony/apache-pack
根据您的 PHP 安装(CGI 或 FPM),运行ning Symfony 在 Apache 上有不同的配置。对于 PHP-CGI:
<VirtualHost *:80>
ServerName domain.tld
ServerAlias www.domain.tld
DocumentRoot /var/www/project/public
<Directory /var/www/project/public>
AllowOverride All
Order Allow,Deny
Allow from All
</Directory>
# uncomment the following lines if you install assets as symlinks
# or run into problems when compiling LESS/Sass/CoffeeScript assets
# <Directory /var/www/project>
# Options FollowSymlinks
# </Directory>
ErrorLog /var/log/apache2/project_error.log
CustomLog /var/log/apache2/project_access.log combined
</VirtualHost>
所有这些信息都可以在官方文档中找到:Symfony Web Server Configuration