0

I installed lamp server on my Ubuntu 16.04 with these commands:

sudo apt-get install tasksel
sudo tasksel install lamp-server

and then added the PHPMyAdmin via basic apt-get command.

My directory root is at /var/www/html.

I created simple PHP file in http://localhost/info.php and http://localhost/info/info.php containing <?php phpinfo(); ?> to see if PHP works and it does.

Now when I try to open my Laravel or Nette websites, located in http://localhost/test/ and http://localhost/fri/ I get directory listing instead of website execution.enter image description here

I thought this is caused by .htaccess file since Nette project has it, but Laravel project doesn't have it and behaves the same.

apache2.conf contains this:

<Directory /var/www/html/>
    Options +FollowSymLinks    
    AllowOverride All
    Require all granted
</Directory>
Nebster
  • 884
  • 1
  • 11
  • 19
  • Possible duplicate of [index.php not loading by default](https://stackoverflow.com/questions/2384423/index-php-not-loading-by-default) – revo May 26 '17 at 11:09
  • http://localhost/test/ works and loads index.php just fine. – Nebster May 26 '17 at 11:11
  • AFAIK you don't have to keep Laravel projects in `/var/www/html` directory. Simply run `php artisan serve` command in command line and it'll run localhost:8000. For more see [this](https://gist.github.com/hootlex/da59b91c628a6688ceb1) gist. – Shashanth May 26 '17 at 11:11
  • I know about Laravel php artisan, it works fine, but I want to be able to run also any other website the "classic" way. – Nebster May 26 '17 at 11:13

2 Answers2

1

It seems that you don't have the PHP enabled as module.

Check the folder mods-enabled in the Apache directory (default: /etc/apache2/) to see if you find a file named php.

You can tail -f in: var/log/apache2/error.log to see if you have errors.

If no, you can add to apache2.conf this:

DirectoryIndex index.php index.html index.pl index.cgi

If none of this works, find DirectoryIndex in your apache config files (probably in the httpd.conf), and check whether index.php is there (it should be there).

Hope it helps!

JP. Aulet
  • 4,375
  • 4
  • 26
  • 39
  • PHP module is enabled. mods-enabled folder contains php7.0.conf and php7.0.load files. Also there is no error.log file. – Nebster May 26 '17 at 11:15
  • As above you need to ensure index.php comes before index.html in apache2.conf, by default .html is first. Also in both those directory listings I can't see an index.php file, which is probably why you are getting the directory listing. Try going to 'www' or 'public' and see if it loads. – Blueline May 26 '17 at 13:24
1

sudo vim /etc/apache2/sites-available/mysite.conf

<Directory /var/www/html/zhyfin/public>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    allow from all
    Require all granted
</Directory>

sudo service apache2 reload

DevonDahon
  • 7,460
  • 6
  • 69
  • 114