Forum

Problem with drupal 8 on loading admin pages (404 ERROR)

Hamed
17 January 2018, 08:25
Hello
I'm a drupal developer but new to Hiawatha! (Thank you Hugo for such an amazing web server)
I just installed drupal 8 on my vm which runs ubuntu 16.04 with composer (https://github.com/drupal-composer/drupal-project)

every thing was good and I installed drupal 8 successfully. I have no problem for loading the home page of my drupal site, but no other pages load! (I get 404 error)
for example non of this pages load:
mysite/admin
mysite/profile
mysite/node/add (etc)

but the home page loads successfully. I also get no errors in my hiawatha error log

this is my hiawatha.conf:
# Hiawatha main configuration file
#

# VARIABLES
# With 'set', you can declare a variable. Make sure the name of the
# variable doesn't conflict with any of the configuration options.
# The variables are case-sensitive and cannot be redeclared.
#
#set LOCALHOST = 127.0.0.0/8


# GENERAL SETTINGS
#
ServerId = www-data
ConnectionsTotal = 1000
ConnectionsPerIP = 25
SystemLogfile = /var/log/hiawatha/system.log
GarbageLogfile = /var/log/hiawatha/garbage.log


# BINDING SETTINGS
# A binding is where a client can connect to.
#
Binding {
Port = 80
}
#
#Binding {
# Port = 443
# TLScertFile = tls/hiawatha.pem
# Interface = 127.0.0.1
# MaxRequestSize = 2048
# TimeForRequest = 30
#}


# BANNING SETTINGS
# Deny service to clients who misbehave.
#
#BanOnGarbage = 300
#BanOnMaxPerIP = 60
#BanOnMaxReqSize = 300
#KickOnBan = yes
#RebanDuringBan = yes


# COMMON GATEWAY INTERFACE (CGI) SETTINGS
# These settings can be used to run CGI applications.
#
#CGIhandler = /usr/bin/perl:pl
#CGIhandler = /usr/bin/php-cgi:php
#CGIhandler = /usr/bin/python:py
#CGIhandler = /usr/bin/ruby:rb
#CGIhandler = /usr/bin/ssi-cgi:shtml
#CGIextension = cgi
#
FastCGIserver {
FastCGIid = PHP7
ConnectTo = /run/php/php7.1-fpm.sock
Extension = php
}


# URL TOOLKIT
# This URL toolkit rule was made for the Banshee PHP framework,
# which can be downloaded from http://www.banshee-php.org/
#
#UrlToolkit {
# ToolkitID = banshee
# RequestURI isfile Return
# Match ^/(css|files|fonts|images|js)($|/) Return
# Match ^/(favicon.ico|robots.txt)$ Return
# Match [^?]*(\?.*)? Rewrite /index.php$1
#}

#UrlToolkit {
# ToolkitID = drupal
# RequestURI isfile Return
# Match ^/favicon.ico$ Return
# Match /(.*)\?(.*) Rewrite /index.php?q=$1&$2
# Match /(.*) Rewrite /index.php?q=$1
#}

UrlToolkit {
ToolkitID = drupal
Match /sites/default/files/private DenyAccess
Match /sites/default/files/(.*)\.php DenyAccess
Match \.(engine|inc|info|install|make|module|profile|test|po|sh|.*sql|theme|tpl(\.php)?|xtmpl)(~|\.sw[op]|\.bak|\.orig|\.save)?$|^(\..*|Entries.*|Repository|Root|Tag|Template|composer\.(json|lock))$|^#.*#$|\.php(~|\.sw[op]|\.bak|\.orig|\.save)$ DenyAccess
RequestURI isfile Return
Match ^/favicon.ico$ Return
Match /(.*)\?(.*) Rewrite /index.php?q=$1&$2
Match /(.*) Rewrite /index.php?q=$1
}
# DIRECTORY SETTINGS
# You can specify some settings per directory.
#
#Directory {
# DirectoryID = static
# Path = /css, /fonts, /images, /js
# ExpirePeriod = 2 weeks
#}
#
#Directory {
# DirectoryID = files
# Path = /files
# ShowIndex = yes
# StartFile = index.html
# ExecuteCGI = no
#}
Include /etc/hiawatha/hosts

# DEFAULT WEBSITE
# It is wise to use your IP address as the hostname of the default website
# and give it a blank webpage. By doing so, automated webscanners won't find
# your possible vulnerable website.
#
Hostname = devbox.test
WebsiteRoot = /var/www/hiawatha
StartFile = index.html
AccessLogfile = /var/log/hiawatha/access.log
ErrorLogfile = /var/log/hiawatha/error.log


# VIRTUAL HOSTS
# Use a VirtualHost section for each website you want to host.
#
#VirtualHost {
# Hostname = www.my-domain.com
# WebsiteRoot = /var/www/my-domain/public
# AccessLogfile = /var/www/my-domain/log/access.log
# ErrorLogfile = /var/www/my-domain/log/error.log
# TimeForCGI = 5
# UseFastCGI = PHP7
# UseToolkit = banshee
# UseDirectory = static, files
#}


and this my virtual host conf:
VirtualHost {
Hostname = test.test
WebsiteRoot = /home/hamed/sites/test/web
StartFile = index.php
#AccessLogfile = /home/hamed/sites/drultra/logs/access.log
ErrorLogfile = /home/hamed/sites/test/error.log
TimeForCGI = 5
UseFastCGI = PHP7
#PreventXSS = yes
#PreventCSRF = yes
#PreventSQLi = yes
#Alias = /mysql:/usr/share/phpmyadmin
#AccessList = allow all
}
Joe Schmoe
17 January 2018, 13:43
1) You are not using the Drupal urltoolkit. Add the following line to your VirtualHost configuration.

        UseToolkit = drupal


2) Replace these two lines in your Drupal urltoolkit

    Match /(.*)\?(.*) Rewrite /index.php?q=$1&$2
Match /(.*) Rewrite /index.php?q=$1


with this line

    Match [^?]*(\?.*)? Rewrite /index.php$1


3) For each new version of Drupal, always check the .htaccess file for which files to deny access. The latest version (v8.4.4) includes protections for Twig and YAML files.

        Match \.(engine|inc|install|make|module|profile|po|sh|.*sql|theme|twig|tpl(\.php)?|xtmpl|yml)(~|\.sw[op]|\.bak|\.orig|\.save)?$|^(\..*|Entries.*|Repository|Root|Tag|Template|composer\.(json|lock))$|^#.*#$|\.php(~|\.sw[op]|\.bak|\.orig|\.save)$ DenyAccess


4) In your virtualhost, the TimeForCGI seems low. I would set it to 30 and adjust if necessary, otherwise some operations in Drupal will not be able to finish.

Hope that helps!
Hamed
17 January 2018, 13:46
Thanks!
now everything runs smoothly
This topic has been closed.