Forum

Installation of Joomla on virtual host problem, help needed. Thanks in advance.

Andrew
2 January 2016, 21:09
Hi,
For the last two months I was trying to setup my home based web server using Hiawatha but now I feel that I need your help please. First I went through earlier postings in this forum and found a lot of helpful information and good discussions but unfortunately the problem that I am facing at is still there. That probably could be some simple solution to it but currently I am stuck and don;t know what else to try, sorry for that as it seems I tried almost everything.
The current situation: - Hiawatha is running on debian, Apache2 is not ranning; -BIND9 DNS server is running; php5-fpm is configured and running; - if I type my ip address in URL I get Hiawatha Welcome page. I can even see the index.html test page if I would place it in virtual host directory where should be Joomla files and type my domain name BUT when I place the Joomla files themselves and would try to install Joomla from the browser I have the page with the note: Service Unavailable 503. Please help me as I stuck at this point. Thank you in advance.

PS: I tried before to install Wordpress in the same virtual host directory and that unfortunately gave the same results. So only index.html page could be displayed if I put in config file at Virtual Host StartFile = Index.html. Because I have already built Joomla template that is why I continue with Joomla rather then with Wordpress. I could be wrong but that test indicates to me that the problem is not related to Joomla or Wordpress themselves but the configuration of my server. Please help. Thanks a lot.
Hugo Leisink
3 January 2016, 11:36
This looks like Hiawatha can't connect to the PHP FastCGI daemon properly. What if you create a simple 'hello world' PHP script. Does that work?
Andrew
3 January 2016, 12:15
Hi Hugo, Thanks a lot for your prompt response and a Happy New Year! I just tried it for testing to use the simple PHP script. Unfortunately it does not work. You are right it seems that Hiawatha does not read php files. But how to figure out where that connection is broken? Thanks, Andrew
Hugo Leisink
3 January 2016, 12:16
Can you show me your Hiawatha configuration (only the FastCGI part) and your PHP configuration (also only the FastCGI part)?
Andrew
3 January 2016, 12:42
Yes, sure. The Hiawatha config file:
FastCGIserver {
FastCGIid = PHP5
ConnectTo = /var/lib/hiawatha/php5-fcgi.sock
Extension = php
}

And PHP-fpm.config that is located at /etc/php5/fpm/php-fpm.conf. I could not find the section there regarding FastCGI so there is a complete file please.
;;;;;;;;;;;;;;;;;;;;;
; FPM Configuration ;
;;;;;;;;;;;;;;;;;;;;;

; All relative paths in this configuration file are relative to PHP's install
; prefix (/usr). This prefix can be dynamically changed by using the
; '-p' argument from the command line.

; Include one or more files. If glob(3) exists, it is used to include a bunch of
; files from a glob(3) pattern. This directive can be used everywhere in the
; file.
; Relative path can also be used. They will be prefixed by:
; - the global prefix if it's been set (-p argument)
; - /usr otherwise
;include=/etc/php5/fpm/*.conf

;;;;;;;;;;;;;;;;;;
; Global Options ;
;;;;;;;;;;;;;;;;;;

[global]
; Pid file
; Note: the default prefix is /var
; Default Value: none
;pid = /var/run/php5-fpm.pid
;pid = /run/php-fpm/php-fpm.pid

; Error log file
; If it's set to "syslog", log is sent to syslogd instead of being written
; in a local file.
; Note: the default prefix is /var
; Default Value: log/php-fpm.log
error_log = log/php5-fpm.log

; syslog_facility is used to specify what type of program is logging the
; message. This lets syslogd specify that messages from different facilities
; will be handled differently.
; See syslog(3) for possible values (ex daemon equiv LOG_DAEMON)
; Default Value: daemon
;syslog.facility = daemon

; syslog_ident is prepended to every message. If you have multiple FPM
; instances running on the same server, you can change the default value
; which must suit common needs.
; Default Value: php-fpm
;syslog.ident = php-fpm

; Log level
; Possible Values: alert, error, warning, notice, debug
; Default Value: notice
log_level = debug

; If this number of child processes exit with SIGSEGV or SIGBUS within the time
; interval set by emergency_restart_interval then FPM will restart. A value
; of '0' means 'Off'.
; Default Value: 0
;emergency_restart_threshold = 0

; Interval of time used by emergency_restart_interval to determine when
; a graceful restart will be initiated. This can be useful to work around
; accidental corruptions in an accelerator's shared memory.
; Available Units: s(econds), m(inutes), h(ours), or d(ays)
; Default Unit: seconds
; Default Value: 0
;emergency_restart_interval = 0

; Time limit for child processes to wait for a reaction on signals from master.
; Available units: s(econds), m(inutes), h(ours), or d(ays)
; Default Unit: seconds
; Default Value: 0
;process_control_timeout = 0

; The maximum number of processes FPM will fork. This has been design to control
; the global number of processes when using dynamic PM within a lot of pools.
; Use it with caution.
; Note: A value of 0 indicates no limit
; Default Value: 0
; process.max = 128

; Specify the nice(2) priority to apply to the master process (only if set)
; The value can vary from -19 (highest priority) to 20 (lower priority)
; Note: - It will only work if the FPM master process is launched as root
; - The pool process will inherit the master process priority
; unless it specified otherwise
; Default Value: no set
; process.priority = -19

; Send FPM to background. Set to 'no' to keep FPM in foreground for debugging.
; Default Value: yes
daemonize = yes

; Set open file descriptor rlimit for the master process.
; Default Value: system defined value
;rlimit_files = 1024

; Set max core size rlimit for the master process.
; Possible Values: 'unlimited' or an integer greater or equal to 0
; Default Value: system defined value
;rlimit_core = 0

; Specify the event mechanism FPM will use. The following is available:
; - select (any POSIX os)
; - poll (any POSIX os)
; - epoll (linux >= 2.5.44)
; - kqueue (FreeBSD >= 4.1, OpenBSD >= 2.9, NetBSD >= 2.0)
; - /dev/poll (Solaris >= 7)
; - port (Solaris >= 10)
; Default Value: not set (auto detection)
;events.mechanism = epoll

; When FPM is build with systemd integration, specify the interval,
; in second, between health report notification to systemd.
; Set to 0 to disable.
; Available Units: s(econds), m(inutes), h(ours)
; Default Unit: seconds
; Default value: 10
;systemd_interval = 10

;;;;;;;;;;;;;;;;;;;;
; Pool Definitions ;
;;;;;;;;;;;;;;;;;;;;

; Multiple pools of child processes may be started with different listening
; ports and different management options. The name of the pool will be
; used in logs and stats. There is no limitation on the number of pools which
; FPM can handle. Your system will tell you anyway

; To configure the pools it is recommended to have one .conf file per
; pool in the following directory:
include=/etc/php5/fpm/pool.d/*.conf
[www]
user = www-data
group = www-data
listen = /var/lib/hiawatha/php5-fcgi.sock;
listen = 127.0.0.1:9000
listen.owner = www-data
listen.group = www-data
listen.mode = 0660
pm = static
pm.max_children = 100
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3
chroot = /var/www/
chdir = /

Hugo, I just noticed that in Hiawatha config file the FastCGI points to php5-fcgi.sock file which for some reason does not exists. Should that be like this or I should create a blank file with this name at this location? Thanks a lot, Andrew
Hugo Leisink
3 January 2016, 12:49
Hiawatha looks for a Unix socket at /var/lib/hiawatha/php5-fcgi.sock. The php-fpm daemon should create it. Now, look in the PHP configuration file. There are two 'listen' options. It could be that the last one overrides the first. Remote the one with 127.0.0.1:9000. The one with /var/lib/hiawatha/php5-fcgi.sock has a semicolon at the end. I don't know it that screws something up, but remove it to be sure. After that, restart php-fpm.
Andrew
3 January 2016, 13:07
That is great! There are some very promising improvements Now after I type my domain name I got message on the screen "No input file specified."
Here my virtual host part of my Hiawatha config file and it looks like it should pick up index.php file from location /var/www/clevedon There is currently Joomla index.php file located at that location but for some reason it does not pick it up. Thanks, Andrew
Andrew
3 January 2016, 13:09
Hi Hugo, I am sorry as I forgot to attach the part of virtual host config
VirtualHost {
HTTPAuthToCGI = yes
Hostname = www.clevedon.cu.cc, *.clevedon.cu.cc
WebsiteRoot = /var/www/clevedon
StartFile = index.php
TimeForCGI = 60
UseFastCGI = PHP5
CustomHeader = X-Frame-Options: sameorigin
CustomHeader = Vary: Accept-Encoding
RandomHeader = 64
UseToolkit = joomla
EnforceFirstHostname = yes
PreventXSS = yes
PreventCSRF = yes
PreventSQLi = yes
ExecuteCGI = yes
EnablePathInfo = yes
}

Thanks, Andrew
Hugo Leisink
3 January 2016, 13:20
The "No input file specified." proofs that PHP is being executes, as that message is generated by PHP. This message means that the requested PHP script could not be found, so all you have to make sure is that the WebsiteRoot is correct, the UrlToolkit does a correct rewriting and the called PHP script actually exists.
Andrew
3 January 2016, 13:43
It looks like the index.php file located at the correct location that is pointed by WebsiteRoot. I just for the test purpose created a simple index.html page and placed it at the same location and it works. It looks like for some reason it does not like only PHP script You can check that html page at www.clevedon.cu.cc Thanks, Andrew
Andrew
3 January 2016, 14:23
Hi Hugo,
I just tried to put the test PHP file with a simple script in the same location and it gives the same message "No input file specified". It looks like it does not like only PHP scripts Thanks, Andrew
Andrew
3 January 2016, 14:56
Hi Hugo,
Just thinking if the server does not read only PHP scripts and the UrlToolkit is doing rewriting may be there is something in UrlToolkit that does not allow to complete this rewriting process? I am just thinking as at the moment have a very limited number of those ideas Thank you in advance.

PS: Here is my UrlToolkit that I use in Hiawatha.conf file:
UrlToolkit {
ToolkitID = joomla
Match base64_encode[^(]*\([^)]*\) DenyAccess
Match (<|%3C)([^s]*s)+cript.*(>|%3E) DenyAccess
Match GLOBALS(=|\[|\%[0-9A-Z]{0,2}) DenyAccess
Match _REQUEST(=|\[|\%[0-9A-Z]{0,2}) DenyAccess
Match ^/index\.php Return
RequestURI exists Return
Match .* Rewrite /index.php
}
Andrew
3 January 2016, 16:48
Hi Hugo,
After puzzling about this issue I decided to reinstall the complete server from the very beginning so hopefully that would make easy to figure out what happen with PHP script reading I will let you know after that would be completed. Have a nice day! Cheers, Andrew
Hugo Leisink
3 January 2016, 20:35
That's quite a drastic approach. Now, you'll never know what you did wrong.
Matthias L.
10 January 2016, 18:38
Problem:
[php-fpm.conf]
chroot = /var/www/

[hiawatha.conf]
WebsiteRoot = /var/www/clevedon

since you've set chroot the PHP-FPM is looking for /var/www/index.php even though it's real path is /var/www/clevedon/index.php.

The same thing applies to doc_root setting in php.ini.

Solution:
Either make sure that hiawatha.conf's WebsiteRoot and PHP's chroot & doc_root are identical
OR unset (empty value) chroot and doc_root. This way PHP-FPM will use any path that is passed by the Hiawatha Webserver.

See: http://php.net/doc-root
Joe Schmoe
22 January 2016, 17:49
Be aware that chroot will also affect the path of the socket file. The PHP process cannot see /anything/ outside the chroot directory since it is really root as far as its concerned. As configured, Hiawatha is going to be looking for:

/var/lib/hiawatha/php5-fcgi.sock


But php is going to create the file here based on your chroot path:

/var/www/var/lib/hiawatha/php5-fcgi.sock


You also may get tripped up with some other files PHP needs (timezone files, DNS resolution if you are doing any HTTP requests, etc) which will need to be copied into your chroot directory.

More on this: http://ae.koroglu.org/chrooted-php-fpm-with-nginx-on-centos-6/


Here are examples of my working configuration files.

Hiawatha Virtual Host file
# FASTCGI SETTINGS
# Settings for connections to the PHP daemon
#
FastCGIserver {
FastCGIid = somedomain-php7
ConnectTo = /home/somedomain/tmp/php7.0-fpm-somedomain.sock
Extension = php
ServerRoot = /home/somedomain
}

# VIRTUAL HOSTS
# Use a VirtualHost section for each website you want to host.
#
VirtualHost {
Hostname = somedomain.com, www.somedomain.com
RequiredBinding = somedomain-http
WebsiteRoot = /home/somedomain/html
AccessLogfile = /var/log/hiawatha/somedomain-access.log
ErrorLogfile = /var/log/hiawatha/somedomain-error.log
TimeForCGI = 60
UseFastCGI = somedomain-php7
UseToolkit = drupal
StartFile = index.php
ExecuteCGI = yes
TriggerOnCGIstatus = no
EnforceFirstHostname = yes
}



PHP Configuration
[somedomain]
prefix = /home/$pool
user = $pool
group = $pool
listen = tmp/php7.0-fpm-$pool.sock
listen.owner = www-data
listen.group = www-data
listen.mode = 0660
pm = ondemand
pm.max_children = 5
chroot = $prefix
chdir = /


Best of luck!
This topic has been closed.