skiabox
asked on
How to config apache virtual host with automatic load of index.php
I have created a virtual host (www.myhost.org) that points to my machine (I have added 127.0.0.1 www.myhost.org to /etc/hosts).
How can I configure it so that it points to index.php ?
Now I have to write www.myhost.org/index.php
If I write www.myhost.org I get a simpe 'It Works!'
Thank you.
How can I configure it so that it points to index.php ?
Now I have to write www.myhost.org/index.php
If I write www.myhost.org I get a simpe 'It Works!'
Thank you.
I have added 127.0.0.1 www.myhost.org to /etc/hostsNothing except localhost and/or localhost.localdomain should be in your hosts file for 127.0.0.1.
How can I configure it so that it points to index.php ?You need to add index.php to the DirectoryIndex. This can be done in the main httpd.conf, in the virtualhost config block, per directory, or in .htaccess.
DirectoryIndex index.php
ASKER
I have the following code in my httpd.conf file :
Should I change this code?
#
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#
<IfModule dir_module>
DirectoryIndex index.html
</IfModule>
Should I change this code?
That will change it globally for all virtual servers. Unless you have a specific need NOT to let particular vhosts have that for their DirectoryIndex, do the global change so that you don't have to create a separate DirectoryIndex for each vhost.
*correction -- that will change DirectoryIndex for all of your hosts, not just virtual. Just wanted to make that clear.
ASKER
But that code is not working.
Probably the ifmodule never execute.
Probably the ifmodule never execute.
That is definitely possible, but I would be surprised if that were the case.
Let's see if apache is loading that module:
[root@broken ~]# grep mod_dir /etc/httpd/conf/httpd.conf
Let's see if apache is loading that module:
[root@broken ~]# grep mod_dir /etc/httpd/conf/httpd.conf
LoadModule dir_module modules/mod_dir.so
If it's commented out, uncomment and restart apache.ASKER
LoadModule dir_module libexec/apache2/mod_dir.so
exists and it is uncommented.
I wonder about that libexec directory.
The proper directory (at least in my system) is /etc/apache2
exists and it is uncommented.
I wonder about that libexec directory.
The proper directory (at least in my system) is /etc/apache2
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER