I have just installed CentOS, Apache and PHP. When I visit my site http://example.com/myapp/, it says "forbidden". By default it's not loading the index.php file.
When I visit http://example.com/myapp/index.php, it works fine.
Any idea how to fix that issue?
Try creating a .htaccess file with the following
Edit: Actually, isn't there a 'php-apache' package or something that you're supposed to install with both of them?
I had same problem with a site on our direct admin hosted site. I added
as a custom httd extension (which adds code to a sites
httpd
file) and the site then ran theindex.php
by default.I had a similar symptom. In my case though, my idiocy was in unintentionally also having an empty index.html file in the web root folder. Apache was serving this rather than index.php when I didn't explicitly request index.php, since
DirectoryIndex
was configured as follows inmods-available/dir.conf
:That is, 'index.html' appears ahead of 'index.php' in the priority list. Removing the index.html file from the web root naturally resolved the problem. D'oh!
Apache needs to be configured to recognize index.php as an index file.
The simplest way to accomplish this..
Create a .htaccess file in your web root.
Add the line...
Here is a resource regarding the matter...
http://www.twsc.biz/twsc_hosting_htaccess.php
Edit: I'm assuming apache is configured to allow .htaccess files. If it isn't, you'll have to modify the setting in apache's configuration file (httpd.conf)
Same issue for me. My solution was that mod_dir was not enabled and apache2 was not issuing an error when reading the directive in my VirtualHost file:
Using the commands:
Fixed the issue.
Step by step and Full instruction for Ubuntu 16.04.4 LTS and Apache/2.4.18
"
sudo -s
""
cd /etc/apache2/mods-enabled
""
vi dir.conf
" and move index.php to right after DirectoryIndex like below and save file then restart apache server."
service apache2 restart
"If you do not see dir.conf then you will need to load it (google for how to)
Done.