CodeIgniter Forums
php webserver works, apache2 doesn't - Printable Version

+- CodeIgniter Forums (
+-- Forum: Using CodeIgniter (
+--- Forum: Installation & Setup (
+--- Thread: php webserver works, apache2 doesn't (/showthread.php?tid=78559)

php webserver works, apache2 doesn't - ps258 - 02-07-2021


I'm working my way through the tutorial at and am stuck.

My environment is a fresh install of raspbian on a pi-4 ( which I'm accessing from my windows 10 desktop.

This is what I've done.

# get composer from
mv composer.phar composer
cd /var/www/html
~/composer create-project codeigniter4/appstarter gallery

# Set document root
vim /etc/apache2/sites-available/000-default.conf
DocumentRoot /var/www/html/gallery/public
# enable .htaccess
vim /etc/apache2/apache2.conf
# in '<Directory /var/www/>' change:
AllowOverride None
# to:
AllowOverride All
# then
systemctl restart apache2

# enable writable writable
cd /var/www/html/gallery
find writable/ -type d -print | xargs chmod 777
find writable/ -type f -print | xargs chmod 666

# set development mode
cp env .env
vim .env
CI_ENVIRONMENT = development

# setup for remote use on port 80
vim app/Config/App.php
# change:
public $baseURL = 'http://localhost:8080/';
# to your url
public $baseURL = '';

# starting the custom php web server
systemctl stop apache2
cd /var/www/html/gallery
php spark serve --host --port 80

It seems to work correctly when I use 'php spark serve' in that I can get the home page at

But when I switch to apache shows just the text 'index.php', just exactly those letters.

The home page is shown if I access it via From this forum, I think that suggests a problem with .htaccess in /public. In particular RewriteBase, but I can't work out what's wrong. /public/.htaccess so it still has RewriteBase commented out although I have experimented with various values in there like '/' and '/public' with no success.

Any suggestions welcome!


RE: php webserver works, apache2 doesn't - ps258 - 02-10-2021

It was mod_rewrite. This fixed it

a2enmod rewrite