Working with pretty urls on apache and fastcgi after hhvm installation
Asked Answered
S

1

14

I needed slim php to work with pretty urls using .htaccess, well no problem.

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]

Now I ran this using hhvm, fastcgi using this virtual host config.

<VirtualHost *:80>
  ServerName project.dev
  ServerALias www.project.dev
  DocumentRoot /var/www/project
  ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9000/var/www/project/$1
  <Directory "/var/www/project">
    AllowOverride All
    Order allow,deny
    Allow from all
  </Directory>
</VirtualHost>

Of course, it won't read the .htaccess file, I thought of adding the .htaccess config in virtual host config, but no, it won't work.

Like so:

<VirtualHost *:80>
  ServerName project.dev
  ServerALias www.project.dev
  DocumentRoot /var/www/project
  ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9000/var/www/project/$1
  <Directory "/var/www/project">
    AllowOverride All
    Order allow,deny
    Allow from all
  </Directory>
  RewriteEngine On
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule ^ index.php [QSA,L]
</VirtualHost>
Smaragdite answered 20/6, 2014 at 2:5 Comment(9)
have you looked at hhvm logs ( /var/log/hhvm ) to see the requests? and can you provide that as well?Marieann
I have, why do you think it is necessary? It's just how to redirect all requests in the index.php in a config. It work just fine if on normal php files, so access and error logs don't log anything that has something to do with it.Smaragdite
@JoeySalacHipolito It sounds like you are saying that you've had an issue and you think that HHVM is the underlying cause. If so you need do two things to get it some attention from the dev team: 1) install the debug build of HHVM. SEE github.com/facebook/hhvm/wiki/Prebuilt%20Packages%20for%20HHVM for OS dependant instructions. 2) open an issue describing your problem @ github.com/facebook/hhvm/issues?state=open They will instruct you on ways to resolve the problem if possible.Wembley
If you don't get an answer here, you might have more luck on serverfault. They are more into server configuration.Demon
Just to be sure, was this same htaccess file working without hhvm? And is ServerALias a typo? (ALias instead of Alias)Chestnut
It appears that hhvm is not fully compatible with all htaccess rules : github.com/facebook/hhvm/issues/751. Apparently there are hhvm config files for doing this.Chestnut
@Chestnut yes it is just a typo, the .htaccess file, work just fine, the problem here is just about the proper configuration of things..Smaragdite
You need to put the rules in the directory block, per Apache: "Note that it is completely equivalent to put a .htaccess file in a directory /www/htdocs/example containing a directive, and to put that same directive in a Directory section <Directory /www/htdocs/example> in your main server configuration" ApacheWort
I would recommend switching to nginx in this case. HHVM is very friendly with nginx and pretty urls work out of the box immediately. If you need more details do say, I can help you out.Warranty
P
1

This isn't really an HHVM issue, more trying to do rewriting at the same time as proxying.

Doing a quick google search yields another answer which might help.

Papert answered 21/8, 2014 at 1:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.