WordPress in subdirectory apache2 without browse index and .htaccess

.htaccessapache-2.2Wordpress

Sorry if this has been asked before but I looked through other posts and couldn't find my answer.

WordPress is up and running inside /var/www/wordpress/
However when I browse to www.mysite.com I get a listing of files & folders like the following:

Index of /

Name    Last modified   Size    Description
index.html  12-Mar-2013 18:31   177  
wordpress/  08-Jan-2012 17:01    -   

Apache/2.2.22 (Ubuntu) Server at www.mysite.com Port 80

If I click on the wordpress directory, I am brought to my site.

I asked a friend and he said modify .htaccess but there is no file with such name in /var/www/

How do I get apache to set my default homepage/directory to /var/www/wordpress/(index.php) ?

I tried uncommenting
ServerRoot "/var/www/wordpress"

But this led to errors trying to restart apache:
-cannot find ports.conf
-cannot find conf.d
things went downhill from there…

Do I modify sites-available/default?

Do I modify apache.conf?

Do I add an .htaccess file?

Also, since this is a new setup, how do I secure the installation which I read a lot of people use a specially crafted .htaccess file?

Thanks for your help!

Contents of sites-available/wordpress:

<VirtualHost *:80>
    ServerAdmin myemail@gmail.com

    DocumentRoot /var/www/wordpress/
    <Directory />
        Options FollowSymLinks
        AllowOverride None
    </Directory>
    <Directory /var/www/wordpress/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride None
        Order allow,deny
        allow from all
    </Directory>

    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    <Directory "/usr/lib/cgi-bin">
        AllowOverride None
        Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
        Order allow,deny
        Allow from all
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Contents of sites-available/default:

<VirtualHost *:80>
    ServerAdmin myemail@gmail.com

    DocumentRoot /var/www/
    <Directory />
        Options FollowSymLinks
        AllowOverride None
    </Directory>
    <Directory /var/www/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride None
        Order allow,deny
        allow from all
    </Directory>

    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    <Directory "/usr/lib/cgi-bin">
        AllowOverride None
        Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
        Order allow,deny
        Allow from all
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Contents of sites-enabled:

root@ip-0.0.0.0:/etc/apache2/sites-enabled# ll
drwxr-xr-x 2 root root 4096 Mar 20 19:58 ./
drwxr-xr-x 7 root root 4096 Mar 20 19:29 ../
lrwxrwxrwx 1 root root   26 Mar 12 18:31 000-default -> ../sites-available/default
lrwxrwxrwx 1 root root   28 Mar 20 19:58 wordpress -> ../sites-available/wordpress

Best Answer

You need to add the ServerName directive to your VirtualHosts, so your web server will know how to route the requests. Also be sure to restart your web server after you make configuration changes.

Also note that, depending on your situation, you may also need to add the ServerAlias directive to one or more of your VirtualHosts.

See here for more info:

Name-based Virtual Host Support

Related Topic