我在CentOS工作.
我按照教程:
当我使用Apache时,我也遵循了这个页面:
我制作了默认控制器和默认模板.使用此控制器(/),我得到以下错误(在调试工具栏中):
An error occurred while loading the web debug toolbar. Open the web profiler.
Run Code Online (Sandbox Code Playgroud)
当我点击链接:"打开web profiler"时,我可以看到Apache响应:
Not Found
The requested URL /_profiler/177403 was not found on this server.
Run Code Online (Sandbox Code Playgroud)
在chrome检查器中,我可以看到:GET http://172.31.18.7/_wdt/177403 404(未找到)
这是我的composer.json的有趣部分:
"require": {
"php": "^7.1.3",
"ext-iconv": "*",
"doctrine/doctrine-fixtures-bundle": "^3.0",
"sensio/framework-extra-bundle": "^5.1",
"sonata-project/admin-bundle": "^3.35",
"sonata-project/doctrine-orm-admin-bundle": "^3.6",
"symfony/apache-pack": "^1.0",
"symfony/console": "^4.0",
"symfony/flex": "^1.0",
"symfony/framework-bundle": "^4.0",
"symfony/lts": "^4@dev",
"symfony/maker-bundle": "^1.4",
"symfony/orm-pack": "^1.0",
"symfony/requirements-checker": "^1.1",
"symfony/security-bundle": "^4.0",
"symfony/twig-bundle": "^4.0",
"symfony/validator": "^4.0",
"symfony/yaml": "^4.0"
},
"require-dev": {
"sensiolabs/security-checker": "^4.1",
"symfony/dotenv": "^4.0",
"symfony/web-profiler-bundle": "^4.0"
},
Run Code Online (Sandbox Code Playgroud)
我的httpd.conf:
<VirtualHost *:80>
DocumentRoot /var/www/html/elora/public
ServerName eloradev
ServerAlias www.elora.dev
DirectoryIndex index.php
<Directory "elora/public">
AllowOverride all
Order Allow,Deny
Deny from all
Allow from 127.0.0.1
Allow from ::1
Allow from localhost
</Directory>
<Directory elora>
Options FollowSymlinks
</Directory>
ErrorLog /var/apache/logs/error.log
CustomLog /var/apache/logs/access.log combined
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)
而我的.htaccess:
DirectoryIndex index.php
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
RewriteRule ^(.*) - [E=BASE:%1]
RewriteCond %{HTTP:Authorization} .
RewriteRule ^ - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^index\.php(?:/(.*)|$) %{ENV:BASE}/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]
RewriteRule ^ %{ENV:BASE}/index.php [L]
</IfModule>
<IfModule !mod_rewrite.c>
<IfModule mod_alias.c>
RedirectMatch 307 ^/$ /index.php/
</IfModule>
</IfModule>
Run Code Online (Sandbox Code Playgroud)
并且,为了完成,我的/ lucky/number(https://symfony.com/doc/current/page_creation.html)会引发apache消息:
Not Found
The requested URL /lucky/number was not found on this server.
Run Code Online (Sandbox Code Playgroud)
看起来路由组件不起作用.
路由器规则(debug:router):
-------------------------- -------- -------- ------ -------------------
Name Method Scheme Host Path
-------------------------- -------- -------- ------ -----------------------
app_homepage ANY ANY ANY /
app_lucky ANY ANY ANY /lucky
app_lucky_number ANY ANY ANY /lucky/number
_twig_error_test ANY ANY ANY /_error/{code}.{_format}
_wdt ANY ANY ANY /_wdt/{token}
_profiler_home ANY ANY ANY /_profiler/
_profiler_search ANY ANY ANY /_profiler/search
_profiler_search_bar ANY ANY ANY /_profiler/search_bar
_profiler_phpinfo ANY ANY ANY /_profiler/phpinfo
_profiler_search_results ANY ANY ANY /_profiler/{token}/search/results
_profiler_open_file ANY ANY ANY /_profiler/open
_profiler ANY ANY ANY /_profiler/{token}
_profiler_router ANY ANY ANY /_profiler/{token}/router
_profiler_exception ANY ANY ANY /_profiler/{token}/exception
_profiler_exception_css ANY ANY ANY /_profiler/{token}/exception.css
-------------------------- -------- -------- ------ -----------------------
Run Code Online (Sandbox Code Playgroud)
我手动创建了目录/ _wdt,以防万一,但它没有改变任何东西.
我用debug调试了错误:event-dispatcher,没什么特别的.
我注意到探查器的缓存位于该目录中:var/cache/dev/profiler/03/74 /并命名为177403
还有一件事,我用'root'用户运行了作曲家.我用chown来改变我的项目的所有者.
这是我文件的一部分.env:
###> symfony/framework-bundle ###
APP_ENV=dev
Run Code Online (Sandbox Code Playgroud)
小智 48
我认为这需要htaccess或mod_rewrite
composer require symfony/apache-pack
Run Code Online (Sandbox Code Playgroud)
小智 13
composer require symfony/apache-pack
Do you want to execute this recipe?
[y] Yes
[n] No
[a] Yes for all packages, only for the current installation session
[p] Yes permanently, never ask again for this project
(defaults to n): y
Run Code Online (Sandbox Code Playgroud)
主机文件:
127.0.0.1 symfony01.com
127.0.0.1 www.symfony01.com
Run Code Online (Sandbox Code Playgroud)
httpd-vhosts.conf :
<VirtualHost *:80>
ServerName symfony01.com
ServerAlias www.symfony01.com
DocumentRoot "c:/wamp64/www/symfony01/public"
<Directory "c:/wamp64/www/symfony01/public/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)
Bis*_*was 10
如果您使用的是 symfony v5. *
去your_project_root > public创建一个名为的新文件.htaccess
只需粘贴代码:
DirectoryIndex index.php
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
RewriteRule ^(.*) - [E=BASE:%1]
RewriteCond %{HTTP:Authorization} .
RewriteRule ^ - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^index\.php(?:/(.*)|$) %{ENV:BASE}/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]
RewriteRule ^ %{ENV:BASE}/index.php [L]
</IfModule>
<IfModule !mod_rewrite.c>
<IfModule mod_alias.c>
RedirectMatch 307 ^/$ /index.php/
</IfModule>
</IfModule>
Run Code Online (Sandbox Code Playgroud)
如果您需要更多信息,可以访问这里
由于回复是在评论中,我重复一遍:
您是否尝试过URL http://www.elora.dev/index.php/_wdt/?我有一个类似的问题,因为URL重写是错误的.- AL
而已 !
非常感谢AL
小智 6
只需添加:
FallbackResource /index.php
在您的目录设置中
<Directory "/Library/WebServer/Documents/Your_public_symfony_directory">
....
FallbackResource /index.php
....
</Directory>Run Code Online (Sandbox Code Playgroud)
有关更多文档,请单击此处
Il 听起来像是缓存写入问题。由于调试数据写入缓存文件夹,探查器/调试工具栏崩溃。您的应用程序可能在prod环境中运行良好。
要查看这是否是您的问题,请尝试运行chmod -R 777 var/cache,然后重试。
“更好的修复”取决于您的操作系统。请随意添加更多信息以准确回答,否则您可以在此处查看 Symfony 相关文档(故意过时的链接,他们从 SF4 文档中删除了它)。
| 归档时间: |
|
| 查看次数: |
22146 次 |
| 最近记录: |