Skip to content
Advertisement

404 Page Not Found when run Codeigniter project inside var/www/html/ on Ubuntu 16.04 LTS?

I have installed LAMP (Linux, Apache2, MySQL, and PHP) stack.

I have a project directory named ‘mahasiswa’. When i ran it on Windows 8 was working well (using XAMPP). Then, when i run it on my Ubuntu 16.04 LTS inside var/www/html/ is not working anymore.

The screen shot of the result :

image of the error message

Is there special configuration to run CodeIgniter project on Ubuntu 16.04 LTS ?

:: Any help would be much appreciate. Thank you.


EDIT

My configuration files :

  1. etc/apache2/sites-available/000-default.conf

enter image description here

  1. etc/apache2/sites-available/mahasiswa.conf

enter image description here

  1. etc/hosts

enter image description here

  1. mahasiswa/.htaccess

enter image description here

The current result on browser:

enter image description here

I don’t know exactly what i’ve missing at this configuration. I’ve followed @eeya instruction / answer below. Any body can help me, please 😀

Advertisement

Answer

For your question in setting up the apache virtual host configuration: Here’s how it goes. If you have [root] privilege, Open your [Terminal] and go to this directory: /etc/apache2/sites-available

Then create a new virtual host configuration, For now, we will name this configuration the name of your project.

sudo vim mahasiswa.conf or sudo nano mahasiswa.conf

<VirtualHost *:80>
    ServerName local.mahasiswa.com 
    DocumentRoot /var/www/html/mahasiswa
    <Directory /var/www/html/mahasiswa/>
        AllowOverride All
        Require all granted
        Allow from all
    </Directory>
</VirtualHost>

1) ServerName: serves as the the DNS (Think of it as another server name aside from http://localhost or http://127.0.0.1)

2) DocumentRoot: from the word itself, is your [project]’s directory (e.g /var/www/html/mahasiswa)

3) Directory: are used to enclose a group of directives that will apply only to the named directory, sub-directories of that directory, and the files within the respective directories. In this case, we wanted to place control access rights to a directory:

AllowOverride All (This can be either All or None)

Require all granted

Allow from all

You can learn more of this here: http://httpd.apache.org/docs/current/mod/core.html#directory

Going back, Once you’ve saved this new configuration, Go to your /etc/hosts (hosts file) (e.g sudo vim /etc/hosts) and add the ff:

127.0.0.1 localhost local.mahasiswa.com

Once you’ve saved these changes on your [hosts] file, Execute this command:

sudo a2ensite mahasiswa.conf

sudo a2enmod rewrite

This will now [enable] your new site configuration and enable the [url rewrite] module as well. Then execute this afterwards:

sudo service apache2 reload

From the command itself, it means you need to reload [apache2] thus the configuration takes affect afterwards.

Then try to access your new domain name: local.mahasiswa.com. You should be able to see your CI pages you’ve needed.

For further reference, check [Digital Ocean] guide here: https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-ubuntu-16-04

Hope this helps for your case.

Edit: In naming the [controller] file(s) (e.g mahasiswa), You might need to set [UpperCase] instead of [lowercase] format to (e.g Mahasiswa)

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement