Run both HHVM and regular Apache server

This morning I started using HHVM as my default local server. Most things are great, but I still have applications that HHVM does not yet fully support.

Instead of changing my configuration and restarting the services, it would be much easier if I could just switch ports or directories.

My question is: Is it possible to run a regular Apache server on one port (80) and a server powered by HHVM on another port (8080)? Alternatively, is it possible to run HHVM only in a specific directory (and its "subdirectories")?

In scenario 1, the transition to the HHVM application would look like this:

localhost/my-project/index.php localhost:8080/my-project/index.php 

In scenario 2, the transition to the HHVM application would look like this:

  localhost/my-project/index.php localhost/hhvm/my-project/index.php 

I would suggest that this can be achieved using the Apache configuration file, but I don’t know enough about how the configuration files work to do this on their own, please help!


OS: Ubuntu 14.04
Apache Version: 2.4.7
HHVM Version: 3.2.0

+5
source share
2 answers

In / etc / apache2 / ports.conf add ...

 Listen 8080 

Then, to your vhost configuration (since you are using localhost as your domain, possibly / etc / apache 2 / sites-available / default.conf), copy everything there and paste it right below so that you have a second instance of VirtualHost. In the second case, change the value of *: 80 to *: 8080, then add your ProxyPassMatch to say that you want to use HHVM to expand hh and php files (do not forget to upgrade to the correct directory).

It should look something like this ...

 <VirtualHost *:80> ... keep the same ... </VirtualHost> <VirtualHost *:8080> ... keep the same ... ProxyPassMatch ^/(.+\.(hh|php)(/.*)?)$ fcgi://127.0.0.1:9000/var/www/$1 </VirtualHost> 

Go to / etc / apache 2 / mods-available / hhvm_proxy_fcgi.conf and comment out what is there. Otherwise, everything will be directed to HHVM.

Finally restart apache

 sudo service apache2 restart 

I quickly tested this on an existing local site and it redirected back 80 of the 8080 that it had to do. If this does not work, let me know.

UPDATE: Tested a bit more, and it looks like this will work for you. After adding the following, the jump between local.site.com/hhvm.php and local.site.com:8080/hhvm.php correctly reflected the echo.

 <?php if (defined('HHVM_VERSION')) { echo "golden!"; } else { echo "doh..."; } 
+6
source

Yes. You can listen to Apache on both port 80 and port 8080 (just add additional configurations for listening), and then add a virtual host for localhost: 8080, which transfers requests to HHVM via FastCGI.

+1
source

Source: https://habr.com/ru/post/1201609/


All Articles