Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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
share|improve this question
    
Can you add the full contents of your sites-available/default and sites-available/wordpress files? Also, do you have a symlink to your config file from the sites-enabled folder? –  user1936123 Mar 20 '13 at 20:13

3 Answers 3

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

share|improve this answer

Do you only want to host one site (a wordpress site)? You can either add a .htaccess file to redirect, or you could use a virtualhost setting in apache to point to yoursite/wordpress as the document root. There are a lot of ways to do it. When you install wordpres it should have an .htaccess file I thought. If you are using .htaccess you will need an allow override directive for your wordpress section of your httpd.conf/apache.conf. Perhaps you can just dump the contents of your wordpress folder into your current document root. Either w

share|improve this answer
    
I'm hoping to add more sites to my server in the future but for now I want the default site to point to /var/www/wordpress/. Later I may wish to go to a different site by browsing directly to mysite.com/newsite but for now just set the wordpress as default. –  JasonC Mar 20 '13 at 20:08

View this link http://wiki.cnic.edu.cu/index.php/Adicionar_sitio_web_al_apache

This is my configuration in apache2 "wordpress.conf":


Alias / /var/www/wordpress


    Options FollowSymLinks
    #DirectoryIndex index.php
    Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all


share|improve this answer
    
I followed the instructions in the link. This is my sites-available/default file that is now sites-available/wordpress: <VirtualHost *:80> ServerAdmin myemail@email.com DocumentRoot /var/www/wordpress/ <Directory /> Options FollowSymLinks AllowOverride None </Directory> <Directory /var/www/wordpress/> Options Indexes Fol... I ran sudo a2ensite & reload but not work. –  JasonC Mar 20 '13 at 20:01
    
I'm not sure how I configure the alias in the 2nd part of your comment. I don't see a wordpress.conf file. –  JasonC Mar 20 '13 at 20:05
    
He is using an additional configuration called wordpress.conf, this would either exist as a section of apache.conf, or it could be its own file in sites-enabled. The name is arbitrary, but is common practice to name the file sitename.conf. You could just add this in your apache.conf between <directory> </directory> tags. –  user160910 Mar 20 '13 at 20:20
    
what is your system operative ? –  josecarlos Mar 20 '13 at 20:24
    
I tried adding the alias inside of <directory> </directory> tags inside of apache.conf, but apache wouldn't restart because "directive requires additional arguments." –  JasonC Mar 20 '13 at 20:51

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.