Configuring HHVM 3.7 with Apache 2.4 gives me a 404? - php

I can't seem to configure HHVM and Apache, it keeps giving me a 404 file not found error. My configuration file for the website is saved as www.example.com.conf, it contains:
<VirtualHost *:80>
ServerName website.com
ServerAdmin mail#website.com
DocumentRoot /var/www/website.com/public_html/
ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9000/var/www/website.com.com/public_html/$1
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Note that I've removed my actual website name, but it's for a subdomain so it's this: subdomain.xyz.com. I've tried looking up how to fix this, but whatever I've tried doesn't seem to work; even the GitHub issues people have posted on the official repository don't seem to work. I also haven't changed the default apache configuration, the only thing I have changed is the root directory of my website which does much up to the directory in the configuration file above.
Any ideas? Thanks.

I know it's been two months already, but maybe it helps someone else (I had a similar issue occur many times when configuring HHVM + Apache2).
Try to enable the vhost if you haven't yet done so. Issue sudo a2ensite www.example.com and reload apache afterwards with sudo service apache2 reload.
If the vhost is ok and you have your browser requests visible in the vhost access log, then it means that it's not Apache2 that's the culprit there.
So if you're still with me and the first two steps didn't help, try the following, although in HHVM 3.7 it shoulnd't be the case anymore (but it might, I just follow the try-and-check method when it comes to configuring HHVM, and it usually works). Open /etc/hhvm/server.ini and append the following line to that file:
hhvm.server.fix_path_info = true
After changing the HHVM's configuration, issue sudo service hhvm restart. Then try to refresh your website. It should be all good.
I had similar issues and back then it was the most common fix on all webservers I configured to work with HHVM. But, after the latest updates, I had to comment that line out of my hhvm server.ini in order for my code to work - I read that they have somehow changed the parameters of the server and this parameter does no good anymore, AFAIK.
I have also tried to put that line in /etc/hhvm/php.ini but as far as I remember, it should go to server.ini because it's a server parameter.
So. Try it and let me know if that helped. If not then please issue the following commands on your webserver and paste the output here, so I can see if you have the necessary modules installed
ls /etc/apache2/mods-available | grep -E 'proxy|alias|fcgi|hhvm'
ls /etc/apache2/mods-enabled | grep -E 'proxy|alias|fcgi|hhvm'
Oh, and please include your full HHVM and Apache2 version output:
hhvm --version
apache2 -v

Related

localhost/~username is not working, gives 404 Not Found error

I am fairly new to server-side web development and am trying to get a local server up and running. I'm using an apache 2 server on my mac, but can't for the life of me get localhost to give me anything but 404 Not Found error. I'm putting localhost/~ and my username in the search bar and still nothing. I've been following a lynda.com tutorial to configure my personal site folder and haven't had any luck.
I'm trying to configure a personal site folder, or at least that is the terminology used in the tutorial. I created a "Sites" folder in my home directory. Then, I put an "index.html" file in the "Sites" folder to test.
After that, I configured a "httpd.conf" file through my terminal by entering "sudo nano/etc/apache2/httpd.conf". He had me un-comment the following lines:
LoadModule userdir_module libexec/apache2/mod_userdir.so
Include /private/etc/apache2/extra/httpd-userdir.conf
After doing this, I exited the file and saved the changes. I then entered into the terminal:
sudo nano /etc/apache2/extra/httpd-userdir.conf
Here I uncommented the following line:
Include /private/etc/apache2/users/*.conf
I then entered into the terminal
cd /etc/apache2/
And then:
cd users
I entered:
sudo nano jacobbryant.conf
In this file, I made sure it only contained:
<Directory "/Users/jacobbryant/Sites/">
Options Indexes MultiViews
AllowOverride None
Require all granted
</Directory>
I then exited this file and restarted the apache server with:
sudo apachectl restart
After this, I went to my browser and typed in "localhost/~jacobbryant" and got a "404 Not Found" error.
I am not sure what #jhilgeman is talking about. Apache has an extension for Per-user web directories that must be setup in order to map ~username to the home directory specified in the configuration. It looks like you have enabled the correct extension but missed the UserDir directive.
For Example: UserDir public_html will serve /home/myuser/public_html at http://your.host.tld/~myuser/
For you example, ditch the <Directory> and use the UserDir directive instead. Please read over https://httpd.apache.org/docs/2.4/howto/public_html.html for setup instructions.

Post request not working Drupal and Ubuntu 14.04

In my ubuntu 14.04 OS machine for drupal 7 login not working, may be it is not only login but all post request not working here. For the same filesystem and codebase it works fine in windows 7 machine.
Here is my apache server configuration:
<VirtualHost *:80>
ServerName somedomain.local
DocumentRoot "/home/mycompany/Development/Projects/Drupal/cbb"
<Directory "/home/mycompany/Development/Projects/Drupal/cbb/">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
for above configuration when i try to submit data for login it showing..
"NetworkError: 404 Not Found - http://somedomain.local/user".
#UPDATE:
I just find out that login not working only from www.domainname.local/user path but if this login form in homepage sidebar it works fine, for all of drupal sire in ubuntu machine. With this no error message also not display.
I am in trouble for two of my drupal site in Ubuntu machine. Any help will be appreciated.
Check if .htaccess file present in drupal root directory.
Check if you've added your domain to /etc/hosts file
127.0.0.1 domain.name
Domains with 'www' and without it are totally different. Add both to /etc/hosts and to apache's config file to avoid problems.
Clear cache to avoid previous domain name which could be stored in cache.
drush cc all
If you've just added new site to apache's configuration be sure to run:
sudo service apache2 graceful
Your Apache vhost file looks like it has the key components set and I'm assuming that the .htaccess file exists in your document root and hasn't been modified from the Drupal default.
When you click on the login link in the sidebar, does it take you to http://somedomain.local?q=user/login ?
Your #update suggests that even though your Apache environment may be set up for "clean URLs", the feature is not enabled in Drupal at Administer > Configuration > Search and metadata > Clean URLs.
If modifying this compromises your access to Drupal, you can apply/disable this change via Drush (drush vset clean_url 0 --yes) or directly through MySQL (UPDATE variable SET value = 's:1:"0";' WHERE name = 'clean_url';) as per https://www.drupal.org/node/5590.
Also worth mentioning, seeing it on this related question (Very strange Drupal 7 404 behaviour): make sure that Apache modules mod_rewrite and mod_headers are enabled:
sudo a2enmod rewrite
sudo service apache2 restart

Run both HHVM and Normal Apache Server

This morning I started using HHVM as my default local server. Most things are fine, but I still have applications that HHVM doesn't fully support yet.
Rather than changing my configuration and restarting services, it would be much easier if I could just switch ports or directories.
My Question: Is it possible to run a normal Apache server on one port (80) and a HHVM powered server on another port (8080)? Alternatively, is it possible to only run HHVM in a specific directory (and its' sub-directories)?
In scenario 1 switching to HHVM application would look like this:
localhost/my-project/index.php
localhost:8080/my-project/index.php
In scenario 2 switching to HHVM application would look like this:
localhost/my-project/index.php
localhost/hhvm/my-project/index.php
I would guess that this can be achieved via Apache's config file, but I don't know enough about how the config files work to do it myself, please help!?
OS: Ubuntu 14.04
Apache Version: 2.4.7
HHVM Version: 3.2.0
To /etc/apache2/ports.conf add...
Listen 8080
Then, to your vhost configuration (since using localhost as your domain, probably /etc/apache2/sites-available/default.conf), copy everything in there and paste it right below so you have a second VirtualHost instance. To the second instance, change the *:80 to *:8080, then add your ProxyPassMatch to tell it you're wanting to use HHVM for hh and php file extensions (don't forget to update to correct directory).
It should look something like...
<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 into /etc/apache2/mods-available/hhvm_proxy_fcgi.conf and comment out what's in there. Otherwise everything will be headed toward HHVM.
Finally, restart apache
sudo service apache2 restart
I tested this quickly on an existing local site and it was redirecting back to 80 from 8080 which it should have done. If this doesn't work out, let me know.
UPDATE: Tested a bit more, and it looks like this should work out for you. After adding the following, jumping between local.site.com/hhvm.php and local.site.com:8080/hhvm.php flipped the echo correctly.
<?php if (defined('HHVM_VERSION')) {
echo "golden!";
} else {
echo "doh...";
}
Yes. You can have Apache listen on both port 80 and port 8080 (just add in additional listen configurations), then add a virtual host for localhost:8080 that passes requests off to HHVM through FastCGI.

I can't seem to get started with Zend Framework 2 skeleton app

I'm following through the getting started skeleton app tutorial on the Zend homepage:
http://framework.zend.com/manual/2.2/en/user-guide/skeleton-application.html
I've got as far as being able to enter into the browser address bar "zf2-tutorial.localhost/" and my Zend welcome page should appear. It doesn't, the apache web folder (/var/www) directory appears instead. If I enter "http://zf2-tutorial.localhost/1234" to test whether the Zend 404 page appears, it doesn't. The default apache Not Found page appears.
I created my app by running in terminal:
php composer.phar create-project --repository-url="http://packages.zendframework.com" zendframework/skeleton-application:dev-master /var/www/zf2-tutorial
.. this created all the files in the desired folder (/var/www/zf2-tutorial).
I then created the file /etc/apache2/sites-enabled/zf2-tutorial with the following:
<VirtualHost *:80>
ServerName zf2-tutorial.localhost
DocumentRoot /var/www/zf2-tutorial/public
SetEnv APPLICATION_ENV "development"
<Directory /var/www/zf2-tutorial/public>
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
I updated my /etc/hosts file with:
127.0.0.1 zf2-tutorial.localhost localhost
I restarted apache
sudo service apache2 restart
.. and by this point I should be able to see the Zend welcome page so I can proceed with the rest of the tutorial but nothing.
By the way, I'm using Ubuntu 12.04, Apache/2.4.9 (Ubuntu) and PHP 5.5.14.
Is there anything obvious that I've missed out? I've got a feeling that it has something to do with the mod_rewrites but I'm a little confused which I should be updated and how. Any help would be much appreciated.
Add the
<VirtualHost *:80>
[... same code ....]
</VirtualHost>
in the /etc/apache2/sites-enabled/000-default file and restart the apache2
Update -
If it still doesn't work then try the below command and check -
sudo a2enmod rewrite
sudo service apache2 restart
This will enable the rewrite module if not already is.
After entering the URL in the browser, if the required page is not displayed then check the apache error log file located at /var/log/apache2/error.log
By this, you could get some idea as where its going wrong.
Your problem was in config file name. In directory sites-enabled files should have .conf in the end of name.
Good: zf2-tutorial.conf
Bad: zf2-tutorial

Can't view index.php of Zend Framework 1.0 after setting up Apache/Host requirements?

UPDATE: the following error is coming up in the Apache error logs...
[Sat Dec 08 16:41:39 2012] [error] [client 127.0.0.1]
PHP Fatal error: require_once():
Failed opening required 'Zend/Application.php'
(include_path='/Library/WebServer/Documents/quickstart/library:.:/php/includes:/Users/markmcdonnell/Dropbox/Library/PHP/ZendFramework-1.12.0/library')
in /Library/WebServer/Documents/quickstart/public/index.php on line 18
I'm using Mac OSX 10.8.2 (Mountain Lion) and I'm having problems getting the Zend framework set-up and running (just the basic QuickStart).
I'm using Apache 2.2.22
My localhost files are accessible from /Library/WebServer/Documents
I have PHP 5.3.15 running as well.
I've created a new project via the command line (using the zf.sh file) called 'quickstart' (as per the section on the Zend website recommends) and that is stored here: /Library/WebServer/Documents/quickstart
I've followed both the official Zend website instructions and also an online book about installing Zend: http://www.survivethedeepend.com/zendframeworkbook/en/1.0/creating.a.local.domain.using.apache.virtual.hosts
My php.ini (/private/etc/php.ini) file has been updated to include the path to the library folder inside the ZendFramework directory...
include_path = ".:/php/includes:/Users/<home>/Dropbox/Library/PHP/ZendFramework-1.12.0/library"
I've updated /etc/apache2/httpd.conf so it includes...
#
# Use name-based virtual hosting.
#
NameVirtualHost *:80
# Ensure "localhost" is preserved unchanged pointed
# to the default document root for our system.
<VirtualHost *:80>
ServerName localhost
DocumentRoot /Library/WebServer/Documents
</VirtualHost>
#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any <VirtualHost> block.
#
<VirtualHost *:80>
ServerName quickstart.local
DocumentRoot /Library/WebServer/Documents/quickstart/public
SetEnv APPLICATION_ENV "development"
<Directory /Library/WebServer/Documents/quickstart/public>
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
...I've also updated /etc/hosts so it includes...
127.0.0.1 localhost
127.0.0.1 quickstart.local
I'm restarting Apache using sudo apachectl graceful (I've also used sudo apachectl restart)
So if I try and now access http://localhost/ I see my /Library/WebServer/Documents directory and I can see PHP is running still with no problems. But if I try and access http://quickstart.local/ I just get an empty page?
Can any one advise as to what the problem might be, what I'm missing and what I can do to get the initial 'welcome' page to display.
I'm sure I'm just missing someone small, but it's obviously causing problem enough for the basic page not to show.
Thanks.
Mark
Just for others who may have followed this. The answer by Kamil, above, will work, but opens a security hole outside Apache's security configuration. That's fine as long as you know it and have another layer of security above Apache.
Another way to resolve the problem is to put the ZendFramework somewhere inside the root directory's hierarchy. Like:
DocumentRoot/Library/WebServer/Documents/ZendFramework-1.12.0/library
or
DocumentRoot/Library/WebServer/Documents/quickstart/public/ZendFramework-1.12.0/library
Any path that's inside the root directory of your Apache server.
Maybe a user permissions issue between the Zend files and the Apache process.
Since you can create the project using zf.sh, the Zend files are obviously there. But the fail you get via Apache suggests that the Zend files might not be accessible via the Apache process (that is, the user under which the Apache process runs).
$ chmod 0777 /Users/markmcdonnell/Dropbox/Library/PHP/ZendFramework-1.12.0/library
to test.
You could probably get away with much less expansive permissions - 0644, for example - but I confess I'm terrible at that aspect of it. ;-)

Categories