• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

HHVM issue

Marian Miron

New Pleskian
Hello guys.
I`ve recently moved to a VPS and Plesk seems to be the best option available. However, with plesk installed and no HHVM support the config is pretty confusing. Just updated to 12.5 and using the "FPM App server by apache". Everything seems to be working fine if I check a .php file: Nginx+HHVM kicks in as desired. The problem is when I check a normal link ( without the file extension ). The file is served by Apache.
I am using laravel for my website so all the files have no extension whatsoever (except static ones).
Any idea how this can be fixed?
Thanks!
 
Hi Marian Miron,

can you confirm, that your nginx configuration file ( /var/www/vhosts/system/subdomain.domain.com/conf/last_nginx.conf ) has been modified ( or additional nginx directives over the Plesk Control are added? ) to fit the needed laravel - rewrite rules ?

Standard Plesk with nginx + PHP-FPM configuration has for example:
Code:
...
    location ~ /$ {
        index index.html index.cgi index.pl index.php index.xhtml index.htm index.shtml;
        try_files $uri $uri/ /index.php?$args;
    }
...

... while the recommendation for laravel would be:

Code:
...
    location ~ /$ {
       index index.php index.html index.htm;
       try_files $uri $uri/ /index.php$is_args$args;
    }
    if (!-d $request_filename) {
        rewrite     ^/(.+)/$ /$1 permanent;
    }
...
 
Last edited by a moderator:
Hi Marian Miron,

can you confirm, that your nginx configuration file ( /var/www/vhosts/system/domain.com/conf/last_nginx.conf ) has been modified ( or additional nginx directives over the Plesk Control are added? ) to fit the needed laravel - rewrite rules ?

Standard Plesk with nginx + PHP-FPM configuration has for example:
Code:
...
    location ~ /$ {
        index index.html index.cgi index.pl index.php index.xhtml index.htm index.shtml;
        try_files $uri $uri/ /index.php?$args;
    }
...

... while the recommendation for laravel would be:

Code:
...
    location ~ /$ {
       index index.php index.html index.htm;
       try_files $uri $uri/ /index.php$is_args$args;
    }
    if (!-d $request_filename) {
        rewrite     ^/(.+)/$ /$1 permanent;
    }
...
Hi UFHH01,
Yes, the file is configured exactly as you said. The directives are added in plesk Control and it looks like follows:
Code:
include "/etc/nginx/hhvm.conf";
location ~ /$ {
    index index.php index.html index.htm;
    try_files $uri $uri/ /index.php$is_args$args;
}
if (!-d $request_filename) {
    rewrite     ^/(.+)/$ /$1 permanent;
}
The PHP settings are set to "FastCGI application served by Apache
The laravel is installed on a subdomain (dev.domain.com)
I have 1 route to /contact where it returns the phpinfo(); and another file created in the public folder (info.php) which returns the same. When accessing these 2 paths though, info.php returns the HHVM conf file (
SERVER_SOFTWARE nginx/1.9.4 ) while /contact page returns the normal php 5.6 info file ( _SERVER["SERVER_SOFTWARE"] Apache ).
As you probably know, the laravel public folder files are laying in public path of the subdomain ( dev.domain.com )..while other files are in /laravel directory. laravel bootstrap and config modified so the website works except that HHVM doesn`t kick-in for any of laravel routes.

THanks a lot for replying, hopefully you`d be able to help me because I`ve literally tried everything I found on Google so far (not much on plesk+hhvm though) and nothing worked.

PS: if it makes any difference, I have 2 IPs on the hosting and only one of them is used (for both domain and subdomain). Domain redirects to launch.domain.com for now...
 
Last edited:
Hi Marian Miron,

include "/etc/nginx/hhvm.conf";
You added a separate "hhvm.conf" in your configuration, please post this content as well, for investigations.


Did you just copy your additional directive from the Plesk Control Panel, or did you check the "last_nginx.conf" as suggested?

..while other files are in /laravel directory
Is there any additional ".htaccess" - file ( with possible rewrite rules ) located in the content folder(s) ? nginx can't read ".htaccess" - files and will ignore them. You have to convert that to nginx directives, in order to be sure, that nginx will serve files instead of apache.
 
Hi UFHH01,

Below is the hhvm.conf file
Code:
location ~* \.(hh|php)$ {
    fastcgi_keep_conn on;
    fastcgi_pass   127.0.0.1:9000;
    fastcgi_index  index.php;
    fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include        fastcgi_params;
}
I copied the directive from Plesk CP. Pelase find below the last_nginx.conf as well ( pretty long file... )
Code:
server {
     listen 176.126.245.123:443 ssl;

     server_name dev.domain.com;
     server_name www.dev.domain.com;
     server_name ipv4.dev.domain.com;

     ssl_certificate             /opt/psa/var/certificates/cert-MNX7IL;
     ssl_certificate_key         /opt/psa/var/certificates/cert-MNX7IL;
     ssl_client_certificate      /opt/psa/var/certificates/cert-8GSrfI;

     client_max_body_size 128m;

     root "/var/www/vhosts/domain.com/dev.domain.com";
     access_log "/var/www/vhosts/system/dev.domain.com/logs/proxy_access_ssl_log";
     error_log "/var/www/vhosts/system/dev.domain.com/logs/proxy_error_log";

     location / {
        proxy_pass https://176.126.245.123:7081;
        proxy_set_header Host             $host;
        proxy_set_header X-Real-IP        $remote_addr;
        proxy_set_header X-Forwarded-For  $proxy_add_x_forwarded_for;
        proxy_set_header X-Accel-Internal /internal-nginx-static-location;
        access_log off;
     }

     location /internal-nginx-static-location/ {
        alias /var/www/vhosts/domain.com/dev.domain.com/;
        add_header X-Powered-By PleskLin;
        internal;
     }

     include "/var/www/vhosts/system/dev.domain.com/conf/vhost_nginx.conf";
}

server {
     listen [2a04:ad80:1:51::d862]:443 ssl;

     server_name dev.domain.com;
     server_name www.dev.domain.com;
     server_name ipv6.dev.domain.com;

     ssl_certificate             /opt/psa/var/certificates/cert-MNX7IL;
     ssl_certificate_key         /opt/psa/var/certificates/cert-MNX7IL;
     ssl_client_certificate      /opt/psa/var/certificates/cert-8GSrfI;

     client_max_body_size 128m;

     root "/var/www/vhosts/domain.com/dev.domain.com";
     access_log "/var/www/vhosts/system/dev.domain.com/logs/proxy_access_ssl_log";
     error_log "/var/www/vhosts/system/dev.domain.com/logs/proxy_error_log";

     location / {
        proxy_pass https://[2a04:ad80:1:51::d862]:7081;
        proxy_set_header Host             $host;
        proxy_set_header X-Real-IP        $remote_addr;
        proxy_set_header X-Forwarded-For  $proxy_add_x_forwarded_for;
        proxy_set_header X-Accel-Internal /internal-nginx-static-location;
        access_log off;
     }

     location /internal-nginx-static-location/ {
        alias /var/www/vhosts/domain.com/dev.domain.com/;
        add_header X-Powered-By PleskLin;
        internal;
     }

     include "/var/www/vhosts/system/dev.domain.com/conf/vhost_nginx.conf";
}

server {
     listen 176.126.245.123:80;

     server_name dev.domain.com;
     server_name www.dev.domain.com;
     server_name ipv4.dev.domain.com;

     client_max_body_size 128m;

     root "/var/www/vhosts/domain.com/dev.domain.com";
     access_log "/var/www/vhosts/system/dev.domain.com/logs/proxy_access_log";
     error_log "/var/www/vhosts/system/dev.domain.com/logs/proxy_error_log";

     location / {
        proxy_pass http://176.126.245.123:7080;
        proxy_set_header Host             $host;
        proxy_set_header X-Real-IP        $remote_addr;
        proxy_set_header X-Forwarded-For  $proxy_add_x_forwarded_for;
        proxy_set_header X-Accel-Internal /internal-nginx-static-location;
        access_log off;
     }

     location /internal-nginx-static-location/ {
        alias /var/www/vhosts/domain.com/dev.domain.com/;
        add_header X-Powered-By PleskLin;
        internal;
     }

     include "/var/www/vhosts/system/dev.domain.com/conf/vhost_nginx.conf";
}

server {
     listen [2a04:ad80:1:51::d862]:80;

     server_name dev.domain.com;
     server_name www.dev.domain.com;
     server_name ipv6.dev.domain.com;

     client_max_body_size 128m;

     root "/var/www/vhosts/domain.com/dev.domain.com";
     access_log "/var/www/vhosts/system/dev.domain.com/logs/proxy_access_log";
     error_log "/var/www/vhosts/system/dev.domain.com/logs/proxy_error_log";

     location / {
        proxy_pass http://[2a04:ad80:1:51::d862]:7080;
        proxy_set_header Host             $host;
        proxy_set_header X-Real-IP        $remote_addr;
        proxy_set_header X-Forwarded-For  $proxy_add_x_forwarded_for;
        proxy_set_header X-Accel-Internal /internal-nginx-static-location;
        access_log off;
     }

     location /internal-nginx-static-location/ {
        alias /var/www/vhosts/domain.com/dev.domain.com/;
        add_header X-Powered-By PleskLin;
        internal;
     }

     include "/var/www/vhosts/system/dev.domain.com/conf/vhost_nginx.conf";
Also, below is the .htaccess file
Code:
<IfModule mod_rewrite.c>

<IfModule mod_negotiation.c>

Options -MultiViews

</IfModule>


RewriteEngine On


# Redirect Trailing Slashes...

RewriteRule ^(.*)/$ /$1 [L,R=301]

# HTTPS REDIRECTS
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^(dev)\. [NC]
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]

# Handle Front Controller...

RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond %{REQUEST_FILENAME} !-f

RewriteRule ^ index.php [L]
</IfModule>
 
Hi Marian Miron,

please note, that you should add this additional nginx directives over Plesk to your subdomain:

Code:
include "/etc/nginx/hhvm.conf";
 
    location ~ /$ {
        index index.php index.html index.htm;
        try_files $uri $uri/ /index.php$is_args$args;
        }
 
    if (!-d $request_filename) {
        rewrite ^/(.+)/$ /$1 permanent;
        }

    if ($http_host ~* "^(dev)\."){
        set $rule_1 2$rule_1;
        }
    if ($rule_1 = "21"){
        rewrite /(.*) https://$http_host$uri redirect;
        }
    if (!-d $request_filename){
        set $rule_2 1$rule_2;
        }
    if (!-f $request_filename){
        set $rule_2 2$rule_2;
        }
    if ($rule_2 = "21"){
        rewrite ^/ /index.php last;
        }

Hint: Odin offers the free Plesk extension "htaccess to nginx". This extension will help you to convert ".htaccess" - files into nginx directives. Please read more at:

htaccess to nginx ( Plesk Extensions catalog )
and
Extensions Management at "Home > Extensions" ( at your Plesk - Control - Panel )


The second thing I noticed, is the port - configuration ( 9000 ). Can you confirm, that PHP-FPM is listening on port 9000 and not on sockets on your server?
 
Hi again,

Thanks for the reply. Managed to get it done with htaccess to nginx tool + changed the php version used to "FPM application by apache" instead of "fastcgi by apache".
Funny thing is that I tried to use "FPM app by Nginx" to remove apache complete out of the equation but it doesn`t work. For some reason on a worse server hhvm works 40% faster than it does on this one ( except plesk nor other panel installed on that server).
 
Hi Marian Miron,

tweaking a server can take ages... ^^ . Please be aware that you can't compare servers, if they are not really identical with hard- and software, including identical configurations and web-content and current running processes. I'm glad you fixed your issue.
 
Back
Top