Forum

PHP Config

Michael
2 December 2015, 03:59
I am trying to run Mediawiki (https://www.mediawiki.org/wiki/MediaWiki) through an AWS instance using Hiawatha as the web server, but for some reason after setting up all of the configurations under VIRTUAL HOSTS in the hiawatha.conf file it still does not load the index.php file as the default load page (and instead it just downloads the php file.) Please help!
# VIRTUAL HOSTS
# Use a VirtualHost section to declare the websites you want to host.
#
#VirtualHost {
Hostname = ec2-52-27-93-242.us-west-2.compute.amazonaws.com
WebsiteRoot = /var/www/mediawiki
StartFile = index.php
AccessLogfile = /var/log/hiawatha/access.log
ErrorLogfile = /var/log/hiawatha/error.log
# TimeForCGI = 5
# UseFastCGI = PHP5
# UseToolkit = banshee
Include /etc/hiawatha/enable-sites/
#}
David Oliver
2 December 2015, 17:39
Do you have an active and configured FastCGIserver stanza in your Hiawatha config?
Michael
3 December 2015, 02:43
I don't believe so. I'm relatively new to using webservers in general esp. Hiawatha, would you mind explaining to me in further detail why it would be important to set up the FastCGIserver/how it might relate to my issue?
Fraggle
3 December 2015, 13:42
The default action when getting a file on a webserver is to simply download it. With a PHP app, what you want instead is for the webserver to execute it as code, but the webserver needs to be told how to do that in the configuration. See this page from the HOWTOs for an example:
https://www.hiawatha-webserver.org/howto/cgi_and_fastcgi
David Oliver
3 December 2015, 16:43
The whole HOWTO [www.hiawatha-webserver.org] is well worth a read.

In addition to the CGI and FastCGI page, see PHP Config [www.hiawatha-webserver.org].

Here are some of my notes I use when setting up a server (Debian/Ubuntu).

Install PHP

Particular packages desired may differ depending on use case.

sudo apt-get install php5-fpm php5-mcrypt php5-cli php5-curl php5-mysql php5-xsl php5-gd


/etc/php5/fpm/php.ini:

cgi.fix_pathinfo = 0
zlib.output_compression = On
zlib.output_compression_level = 6
expose_php = Off
display_errors = Off
allow_url_include = Off


sudo service php5-fpm restart


For once PHP-FPM is installed and configured...

In Ubuntu, I believe PHP-FPM's default socket is /var/run/php5-fpm.sock:

FastCGIserver {
FastCGIid = PHP5
ConnectTo = /var/run/php5-fpm.sock
Extension = php
}


You'll need to uncomment the 'UseFastCGI = PHP5' line in your VirtualHost, which refers to the FastCGIserver above.
Michael
11 December 2015, 03:46
So I followed all of these directions and read through both sections of the HOWTO guide for PHP Config and CGI/FastCGI Config, but still to no avail.

Are there any other ways that I can check to see what exactly is wrong/what exactly I am missing?
Wimivo
13 December 2015, 20:10
Here are another couple of steps that might be worth trying.

1. Install the php5-cgi package.

2. In hiawatha.conf, FastCGIServer defaults to php-cgi.sock for my installs (using Ubuntu server). Make sure to change that to php5-fpm.sock if it needs it. (Same directory for me.)

3. Uncomment
CGIhandler = /usr/bin/php-cgi:php


4. Add
ExecuteCGI = yes
at the bottom of the DEFAULT WEBSITE section. (Also might want to change StartFile to index.php if you want MediaWiki.)
Wimivo
13 December 2015, 20:12
Oh, and be sure to 'sudo service hiawatha restart' after saving hiawatha.conf.
This topic has been closed.