Is HHVM or PHP5 Zend running? - php

After some struggle, I finally installed Facebook HipHop Virtual Machine in Ubuntu. It is running under FastCGI (Apache 2.22). Below, the service status:
marcelo#marcelo-VirtualBox:~$ service apache2 status
Apache2 is running (pid 3330).
marcelo#marcelo-VirtualBox:~$ service hhvm status
* hhvm is running
marcelo#marcelo-VirtualBox:~$ sudo service hhvm restart
* Restarting HHVM FastCGI Daemon hhvm [ OK ]
marcelo#marcelo-VirtualBox:~$
The same machine has PHP5 module enabled and configured in Apache.
Question:
I want to make sure that I am really rendering PHP code using HHVM and NOT Zend Framework.
All my PHP scripts are running on the webserver. But, when I disable PHP5 module using sudo a2dismod php5 the web server starts to render Internal Server Error.
Does HHVM need PHP5 module enabled to run? Supposedly, since I am using FastCGI, my answer is no. On the other hand, I think that my pages are being rendered by Zend and not HHVM.
What am I missing here? How can I make sure that I am really running HHVM? (in my mind, a clear test is to disable PHP5 module, but, as I said, when I disable, php stops working in the web browser).
If .php is not running with PHP5 module disabled does it means that my HHVM is not properly configured?
P.S.: The script that I am testing is a default Hello World example: <?php echo 'Hello World.'; ?>.
And, It works when I run from command line:
marcelo#marcelo-VirtualBox:/var/www$ sudo hhvm hello_world.php
Hello World.
marcelo#marcelo-VirtualBox:/var/www$
EDIT
Apache error.log:
marcelo#marcelo-VirtualBox:/var/log/apache2$ cat error.log
[Wed May 07 14:02:10 2014] [notice] FastCGI: process manager initialized (pid 2627)
[Wed May 07 14:02:10 2014] [notice] Apache/2.2.22 (Ubuntu) mod_fastcgi/mod_fastcgi-SNAP-0910052141 configured -- resuming normal operations
[Wed May 07 14:04:52 2014] [error] [client 127.0.0.1] (2)No such file or directory: FastCGI: failed to connect to server "/var/www/fastcgi/hhvm.fastcgi": connect() failed
[Wed May 07 14:04:52 2014] [error] [client 127.0.0.1] FastCGI: incomplete headers (0 bytes) received from server "/var/www/fastcgi/hhvm.fastcgi"
[Wed May 07 14:04:53 2014] [error] [client 127.0.0.1] File does not exist: /var/www/favicon.ico
marcelo#marcelo-VirtualBox:/var/log/apache2$
(Apparently, I should have 'hhvm.fastcgi' file. I only have the directory. Is anything wrong here?)
/var/www directory:
marcelo#marcelo-VirtualBox:~$ ls -l /var/www
total 20
drwxrwxrwx 2 root root 4096 May 6 23:45 fastcgi
-rw-r--r-- 1 root root 31 May 6 21:57 hello_world.php
-rw-r--r-- 1 root root 177 May 6 17:47 index.html
-rw-r--r-- 1 root root 21 May 6 17:50 info.php
-rw-r--r-- 1 root root 0 May 6 17:49 info.php~
drwxr-xr-x 13 997 1001 4096 May 6 18:13 mediawiki-1.22.6
marcelo#marcelo-VirtualBox:~$ ls -l /var/www/fastcgi/
total 0
marcelo#marcelo-VirtualBox:~$
- FastCGI configuration:
I added the lines below, as suggested here: https://github.com/facebook/hhvm/wiki/FastCGI, at the end of apache2.conf file. In other words, after all 'mods-enabled' were already loaded.
# fastcgi added by M. Sardelich
<IfModule mod_fastcgi.c>
Alias /hhvm.fastcgi /var/www/fastcgi/hhvm.fastcgi
FastCGIExternalServer /var/www/fastcgi/hhvm.fastcgi -socket /var/run/hhvm/socket -pass-header Authorization -idle-timeout 300
<Directory "/var/www/fastcgi">
<Files "hhvm.fastcgi">
Order deny,allow
</Files>
</Directory>
AddHandler hhvm-hack-extension .hh
AddHandler hhvm-php-extension .php
Action hhvm-hack-extension /hhvm.fastcgi virtual
Action hhvm-php-extension /hhvm.fastcgi virtual
</IfModule>

To make sure that you are in fact running HHVM, run the following command:
phpinfo();
It should produce HipHop as the output, instead of the normal php info.
To check for it programmatically, you can use the following (also mentioned here):
if (defined('HHVM_VERSION')) {
echo "ruuning HHVM";
}

As correctly noticed (thanks #Petah), my FastCGI config was wrong.
I changed it to the snippet below (from here: http://www.mediawiki.org/wiki/HHVM/Vagrant) and everything is working! (add it to your apache2.conf or httpd.conf file)
<IfModule mod_fastcgi.c>
Alias /hhvm.fastcgi /var/www/fastcgi/hhvm.fastcgi
FastCGIExternalServer /var/www/fastcgi/hhvm.fastcgi -host 127.0.0.1:9000 -pass-header Authorization -idle-timeout 300
<Directory "/var/www/fastcgi">
<Files "hhvm.fastcgi">
Order deny,allow
</Files>
</Directory>
AddHandler hhvm-hack-extension .hh
AddHandler hhvm-php-extension .php
Action hhvm-hack-extension /hhvm.fastcgi virtual
Action hhvm-php-extension /hhvm.fastcgi virtual
</IfModule>

Related

Windows WSL with Ubuntu LAMP - PHP not executing

I was about to test if Windows 10 Pro with WSL running Ubuntu LAMP stack is already a good options for web development.
I tested 2 guides:
https://www.freecodecamp.org/news/setup-a-php-development-environment-on-windows-subsystem-for-linux-wsl-9193ff28ae83/
https://nickjanetakis.com/blog/using-wsl-and-mobaxterm-to-create-a-linux-dev-environment-on-windows
First I tested with Nginx and PHP7.2 but I had the issue that PHP was not executed but displayed. Then I gave Apache2 a try with PHP7.0 and I have the same issue.
sudo a2enmod php7.0
Considering dependency mpm_prefork for php7.0:
Considering conflict mpm_event for mpm_prefork:
Considering conflict mpm_worker for mpm_prefork:
Module mpm_prefork already enabled
Considering conflict php5 for php7.0:
Module php7.0 already enabled
sudo update-alternatives --set php /usr/bin/php7.0
There was never a PHP5 installed and there is nothing in apache about PHP5.
/etc/apache2/mods-available contains
-rw-r--r-- 1 root root 867 Sep 2 15:31 php7.0.conf
-rw-r--r-- 1 root root 102 Sep 2 15:31 php7.0.load
/etc/apache2/mods-enabled contains the symlinks
lrwxrwxrwx 1 root root 29 Oct 22 12:03 php7.0.conf -> ../mods-available/php7.0.conf
lrwxrwxrwx 1 root root 29 Oct 22 12:03 php7.0.load -> ../mods-available/php7.0.load
php7.0.load contains
LoadModule php7_module /usr/lib/apache2/modules/libphp7.0.so
The module exists at this location.
Apache error.log looks also ok
[Tue Oct 22 14:06:32.548315 2019] [mpm_event:notice] [pid 1779:tid 140213335231424] AH00491: caught SIGTERM, shutting down
[Tue Oct 22 14:06:34.732188 2019] [mpm_prefork:notice] [pid 24776] AH00163: Apache/2.4.41 (Ubuntu) configured -- resuming normal operations
[Tue Oct 22 14:06:34.732298 2019] [core:notice] [pid 24776] AH00094: Command line: '/usr/sbin/apache2'
vHost
<VirtualHost *:80>
ServerAdmin admin#localhost.com
ServerName www.test.me
DocumentRoot /var/www/dev/test
<Directory /var/www/dev/test/>
Options Indexes FollowSymlinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error_www.test.me.log
LogLevel warn
</VirtualHost>
/var/www/dev is a symlink to the mounted windows user dev folder
lrwxrwxrwx 1 root root 19 Oct 22 11:30 dev -> /c/Users/name/dev/
Since Apache and Nginx have have the same issue it might be about the path to or the user/permissions but I couldn't find anything so far.
Would be nice if someone has an idea whats wrong.

Apache Server error 500 when DocumentRoot is a symlink

I have setup my fedora system, the default was that / size is 50gb while remaining drives where put on /home.
since I don't want to waste my precious 50gb for my web project I setup my apache web server as follow
since the default of apache is /var/www/html
i remove html dir and replace it with a symbolic link that points to my /home/user/www/html
note /home, /home/user, /home/user/www, /home/user/www/html have x permission for apache
my conf is like this
DocumentRoot "/var/www/html"
<Directory "/var/www">
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
<Directory "/var/www/html">
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
I already restart my httpd service and it was fine. The problem is when I try to access my index.php I get a server error. when it's index.html I get a 403.
my selinux is currently enabled and no plans on disabling it. I would Like to learn how to use it rather. so it this an selinux problem?
As I run ls -Zla on /home/user/www/html, this is the result
-rw-r--r--. 1 root root unconfined_u:object_r:user_home_t:s0 27 Dec 21 22:37 index.php
It seems that SELinux is preventing this
when accessing an html
[Mon Dec 21 23:35:33.749916 2015] [core:error] [pid 20579] (13)Permission denied: [client 127.0.0.1:45632] AH00132: file permissions deny server access: /var/www/html/index.html
when a php
[Mon Dec 21 23:39:36.801672 2015] [:error] [pid 20585] [client 127.0.0.1:45816] PHP Warning: Unknown: failed to open stream: Permission denied in Unknown on line 0
[Mon Dec 21 23:39:36.801730 2015] [:error] [pid 20585] [client 127.0.0.1:45816] PHP Fatal error: Unknown: Failed opening required '/var/www/html/index.php' (include_path='.:/usr/share/pear:/usr/share/php') in Unknown on line 0
~
to someone that may get this problem. change the selinux type of the folder using this command.
sudo chcon -R -t httpd_sys_content_t /home/user/www
more info

PHP not running on VirtualHost after upgrading to OS X Yosemite

Upgraded to OS X Yosemite and now my virtualhosts are spitting out the PHP file contents instead of executing the file.
This works correctly:
http://localhost
This spits out the file contents onto the screen:
http://localhost/~MYUSERNAME
<?php phpinfo();
http://testing.dev spits out the
<?php and the contents of this file (which is WordPress)
apachectl -t
Syntax OK
/etc/apache2/extra/httpd-vhosts.conf
<VirtualHost *:80>
ServerName localhost
DocumentRoot /Library/WebServer/Documents/
</VirtualHost>
<VirtualHost *:80>
ServerName testing.dev
ServerAlias www.testing.dev
DocumentRoot "/Users/*/Sites/testing"
ErrorLog "/private/var/log/apache2/testing.dev-error_log"
<Directory "/Users/*/Sites/testing-env/">
Options Indexes FollowSymLinks
AllowOverride AlL
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
/etc/hosts
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
fe80::1%lo0 localhost
127.0.0.1 testing.dev
Why is it spitting out the PHP file instead of executing it?
running php -v gives me
PHP 5.5.3 (cli) (built: Aug 28 2013 13:28:31)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2013 Zend Technologies
with Xdebug v2.2.2, Copyright (c) 2002-2013, by Derick Rethans
error log shows:
[Mon Nov 17 17:30:08.338143 2014] [auth_digest:notice] [pid 3633] AH01757: generating secret for digest authentication ...
[Mon Nov 17 17:30:08.339341 2014] [mpm_prefork:notice] [pid 3633] AH00163: Apache/2.4.9 (Unix) PHP/5.5.14 configured -- resuming normal operations
[Mon Nov 17 17:30:08.339391 2014] [core:notice] [pid 3633] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'
Upgrading OS X restores the Apache configuration files to their defaults. You’ll need to edit them again. From memory, this includes:
un-commenting the PHP handler so Apache executes files rather than serving them
Setting AllowOverride to All for your web root directory
un-commenting the line that loads the VirtualHosts configuration file
I had the same issue and found there was a missing configuration section in my httpd.conf. After adding the following and restarting Apache PHP files were processed correctly.
<IfModule php5_module>
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>
</IfModule>

Zend Framework - 500 Internal Server Error

Today I create my first project with Zend Framework but when I try to connect to my project I see only "500 Internal Server Error". I add some new rows in httpd.conf file:
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot C:\AppServ\www\data1\public
ServerName my_ip
</VirtualHost>
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot C:\AppServ\www\data1\public
ServerName http://my_ip
</VirtualHost>
And that is my htaccess file:
RewriteEngine On
#RewriteBase data1/public/
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
RewriteRule !\.(js|ico|gif|jpg|png|css|swf|html|pps)$ index.php [NC,L]
order allow,deny
allow from all
I read more topics for this problem but for now problem is not solved.
That is my error.log file(from server):
[Wed Aug 08 01:46:02 2012] [warn] NameVirtualHost *:80 has no VirtualHosts
PHP Warning: PHP Startup: Unable to load dynamic library 'C:/AppServ\\php5 \\ext\\php_exif.dll' - \xd3\xea\xe0\xe7\xe0\xed\xe0\xf2\xe0 \xef\xf0\xee\xf6\xe5\xe4 \xf3\xf0\xe0 \xed\xe5 \xe5 \xed\xe0\xec\xe5\xf0\xe5\xed\xe0.\r\n in Unknown on line 0
[Wed Aug 08 01:46:02 2012] [notice] Apache/2.2.8 (Win32) PHP/5.2.6 configured -- resuming normal operations
[Wed Aug 08 01:46:02 2012] [notice] Server built: Jan 18 2008 00:37:19
[Wed Aug 08 01:46:02 2012] [notice] Parent: Created child process 2392
[Wed Aug 08 01:46:02 2012] [warn] NameVirtualHost *:80 has no VirtualHosts
[Wed Aug 08 01:46:02 2012] [warn] NameVirtualHost *:80 has no VirtualHosts
PHP Warning: PHP Startup: Unable to load dynamic library 'C:/AppServ\\php5\\ext\\php_exif.dll' - \xd3\xea\xe0\xe7\xe0\xed\xe0\xf2\xe0 \xef\xf0\xee\xf6\xe5\xe4\xf3\xf0\xe0 \xed\xe5 \xe5 \xed\xe0\xec\xe5\xf0\xe5\xed\xe0.\r\n in Unknown on line 0
[Wed Aug 08 01:46:02 2012] [notice] Child 2392: Child process is running
[Wed Aug 08 01:46:02 2012] [notice] Child 2392: Acquired the start mutex.
[Wed Aug 08 01:46:02 2012] [notice] Child 2392: Starting 64 worker threads.
[Wed Aug 08 01:46:02 2012] [notice] Child 2392: Starting thread to listen on port 80.
[Wed Aug 08 01:46:15 2012] [alert] [client 46.40.124.225] C:/AppServ/www/data1/public/.htaccess: Invalid command 'RewriteEngine', perhaps misspelled or defined by a module not included in the server configuration
Thanks for posting the error log.
From the looks of it, you don't have mod_rewrite loaded.
Find your httpd.conf file and locate the line:
#LoadModule rewrite_module modules/mod_rewrite.so
Remove the # sign from the beginning of the line.
Next, add a new section to httpd.conf that looks like this:
<Directory "C:/AppServ/www/data1/public">
Options FollowSymLinks
AllowOverride All
</Directory>
The AllowOverride directive is important. By default, .htaccess files are not processed unless allowed. This line allows .htaccess files in that named directory.
After making those changes, restart Apache and then try loading your ZF page again.
First of all, a better debugging. Add
ErrorLog "PATH_TO/zfapp-error_log"
CustomLog "PATH_TP/zfapp-access_log" combined
to your virtualhost. Restart apache and reload your page. The files will be created in the specified path. There will be an exact error message wich will help you debug further.
I just had the exact same problem and the solution by drew010 did fix it indeed!
However, it seems Apache config structure changed, so the method to enable the missing module is slightly different:
$ cd /etc/apache2/mods-enabled
$ sudo ln -s ../mods-available/rewrite.load ./rewrite.load
This confirms you have the right stuff going:
$ cd /etc/apache2/mods-enabled
$ cat ./rewrite.load
LoadModule rewrite_module /usr/lib/apache2/modules/mod_rewrite.so
Cheers!

mod_rewrite causes apache to crash with Rewritemap prg directive

Apache configuration:
RewriteEngine on
RewriteLock /var/www/lib/rewrite.lock
RewriteMap sessionValid prg:/var/www/lib/allow.php
I fixed the obvious of setting the file executable, but now it is giving this:
[Fri Feb 12 01:55:31 2010] [error] (2)No such file or directory: exec
of '/var/www/lib/allow.php' failed
But the file clearly exists.
...Forgot to make allow.php executable for the apache user.

Categories