doubi9615 2014-01-02 14:13
浏览 47

Symfony 2.3生产模式网址无法解析

I have just gone through the Symblog tutorials on http://tutorial.symblog.co.uk/docs/customising-the-view-more-with-twig.html

In prod mode, if i access the url like so:

http://local.mysite.co.uk

I get the home page with links to all the blog posts.

However if i click one of the blog posts then I get a 404, in fact any of the links (to the about or contact) all return a 404, eg:

http://local.mysite.co.uk/12/a-day-with-symfony2

If I then access the prod mode via the app_dev.php all the links work again, ie:

http://local.mysite.co.uk/app.php/12/a-day-with-symfony2

I have run to ensure the mod rewrites should be working and restarted apache but no joy.

sudo a2enmod actions

Does anyone know why this might be happening?

Thanks, John

PS: This is the current vhost file for the dev site i am learning with (Ubuntu lts, apache 2.4, php 5.4ish)

<virtualhost *:80>

  # Admin email, Server Name (domain name) and any aliases
  ServerAdmin webmaster@domain.com
  ServerName  mysite.co.uk
  ServerAlias www.mysite.co.uk
  ServerAlias local.mysite.co.uk

  # Index file and Document Root (where the public files are located)
  DirectoryIndex app.php
  DocumentRoot /var/webroot/www/vhosts/mysite.co.uk/htdocs/Symfony/web/

  # Custom log file locations
  LogLevel warn
  ErrorLog  /var/webroot/www/vhosts/mysite.co.uk/log/error.log
  CustomLog /var/webroot/www/vhosts/mysite.co.uk/log/access.log combined

</virtualhost>

When I add an AllowOverride All to the vhost file and restart apache I get the follwoing error:

 * Starting web server apache2
 * 
 * The apache2 configtest failed.
Output of config test was:
AH00526: Syntax error on line 15 of /etc/apache2/sites-enabled/mysite.co.uk.conf:
AllowOverride not allowed here
Action 'configtest' failed.
The Apache error log may have more information.
  • 写回答

1条回答 默认 最新

  • douhuang3740 2014-01-02 14:54
    关注

    Altering the vhost worked (thanks to https://stackoverflow.com/users/308825/maerlyn).

    Placing a directory tag with the Allowoverride All fixed the issue. Seems that the rewrites are specific to each vhost.

    Here is my config for the symfony tutorial which is now functioning in prod mode:

    <directory /var/webroot/www/vhosts/mysite.co.uk/htdocs/Symfony/web/>
      Options Indexes FollowSymLinks MultiViews
      AllowOverride All
      Order allow,deny
      allow from all
    </directory>
    
    <virtualhost *:80>
    
      # Admin email, Server Name (domain name) and any aliases
      ServerAdmin webmaster@domain.com
      ServerName  mysite.co.uk
      ServerAlias www.mysite.co.uk
      ServerAlias local.mysite.co.uk
    
      # Index file and Document Root (where the public files are located)
      DirectoryIndex app.php
      DocumentRoot /var/webroot/www/vhosts/mysite.co.uk/htdocs/Symfony/web/
    
      # Custom log file locations
      LogLevel warn
      ErrorLog  /var/webroot/www/vhosts/mysite.co.uk/log/error.log
      CustomLog /var/webroot/www/vhosts/mysite.co.uk/log/access.log combined
    
    </virtualhost>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 2024-五一综合模拟赛
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭