我正在尝试使用 apache2 在我的产品服务器上部署我的 symfony 6.2 项目。
我的产品服务器已经有较旧的 symfony 项目,所以我使用 ondrej php 并安装了 php8.2 和 mods。
Server version: Apache/2.4.41 (Ubuntu)
部署git项目并运行composer:install.
这是我的 project.conf :
<virtualHost *:80>
ServerAdmin [email protected]
ServerName project.mysterty.com
DirectoryIndex index.php
DocumentRoot "/var/www/project/public"
<Directory "/var/www/project/public">
AllowOverride All
Order Allow,Deny
Allow from All
Require all granted
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{REQUEST_URI}::$0 ^(/.+)/(.*)::\2$
RewriteRule .* - [E=BASE:%1]
RewriteCond %{HTTP:Authorization} .+
RewriteRule ^ - [E=HTTP_AUTHORIZATION:%0]
RewriteCond %{ENV:REDIRECT_STATUS} =""
RewriteRule ^index\.php(?:/(.*)|$) %{ENV:BASE}/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ %{ENV:BASE}/index.php [L]
</IfModule>
<IfModule !mod_rewrite.c>
<IfModule mod_alias.c>
# When mod_rewrite is not available, we instruct a temporary redirect of
# the start page to the front controller explicitly so that the website
# and the generated links can still be used.
RedirectMatch 307 ^/$ /index.php/
# RedirectTemp cannot be used instead
</IfModule>
</IfModule>
</Directory>
<FilesMatch \.php$>
# For Apache version 2.4.10 and above, use SetHandler to run PHP as a fastCGI process server
SetHandler "proxy:unix:/run/php/php8.2-fpm.sock|fcgi://localhost"
</FilesMatch>
ErrorLog ${APACHE_LOG_DIR}/project_error.log
CustomLog ${APACHE_LOG_DIR}/project_access.log combined
</VirtualHost>
这是错误信息:
[Tue Apr 11 11:49:40.112857 2023] [proxy_fcgi:error] [pid 3184524] [client 194.38.23.179:63349] AH01071: Got error 'PHP message: PHP Warning: require(/var/www/project/vendor/composer/../symfony/polyfill-mbstring/bootstrap.php): Failed to open stream: Permission denied in /var/www/project/vendor/composer/autoload_real.php on line 78; PHP message: PHP Fatal error: Uncaught Error: Failed opening required '/var/www/project/vendor/composer/../symfony/polyfill-mbstring/bootstrap.php' (include_path='.:/usr/share/php') in /var/www/project/vendor/composer/autoload_real.php:78\nStack trace:\n#0 /var/www/project/vendor/composer/autoload_real.php(61): composerRequiree6ce3b729b7a527d4ebd0a97b86ba908()\n#1 /var/www/project/vendor/autoload.php(7): ComposerAutoloaderInite6ce3b729b7a527d4ebd0a97b86ba908::getLoader()\n#2 /var/www/project/vendor/autoload_runtime.php(5): require_once('...')\n#3 /var/www/project/public/index.php(5): require_once('...')\n#4 {main}\n thrown in /var/www/project/vendor/composer/autoload_real.php on line 78'
我假设该项目在我的本地服务器(ubuntu/apache2)上使用相同的配置工作。