1

I have virtual machine running Ubuntu. I want to type in browser "http://localhost/mwiki" and see my MediaWiki site. I put this site into /var/www/mwiki folder and I configured Apache "default" file. But when I try to open this site in browser - following web page opened: " The requested URL /mwiki/ was not found on this server Apache/2.2.11 (Ubuntu) mod_python/3.3.1 Python/2.6.2 Server at localhost Port 80".

Also on this server is running another site (ReviewBoard system). And it runs perfectly. When I type "localhost/reviews" I get the index page of this site. I have minimal knowledge of configuring Apache.

Please, help.

/etc/apache2/sites-available/default:

<VirtualHost *:80>
ServerName localhost
DocumentRoot "/var/www/mwiki"
AddDefaultCharset UTF-8 

    <Location "/mwiki">
    Order allow,deny
    Deny from all
</Location>

</VirtualHost>

<VirtualHost *:80>
ServerName localhost
DocumentRoot "/var/www/reviews.mysite.com/htdocs"
AddDefaultCharset UTF-8 

# Error handlers
ErrorDocument 500 /errordocs/500.html

# Serve django pages
<Location "/reviews/">
    PythonPath "['/var/www/reviews.mysite.com/conf'] + sys.path"
    SetEnv DJANGO_SETTINGS_MODULE reviewboard.settings
    SetEnv PYTHON_EGG_CACHE "/var/www/reviews.mysite.com/tmp/egg_cache"
    SetEnv HOME "/var/www/reviews.mysite.com/data"
    SetHandler mod_python
    PythonHandler django.core.handlers.modpython
    PythonAutoReload Off
    PythonDebug Off
    # Used to run multiple mod_python sites in the same apache
    PythonInterpreter reviewboard_reviews_mysite_com
</Location>

<Location "/reviews/media">
    SetHandler None
</Location>

# Serve static media without running it through mod_python
# (overrides the above)
<Location "/reviews/errordocs">
    SetHandler None
</Location>

<Directory "/var/www/reviews.mysite.com/htdocs">
    AllowOverride All
</Directory>

# Alias static media requests to filesystem
Alias /reviews/media "/var/www/reviews.mysite.com/htdocs/media"
Alias /reviews/errordocs "/var/www/reviews.mysite.com/htdocs/errordocs"
</VirtualHost>

<VirtualHost *:80>
ServerAdmin webmaster@localhost

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 /var/log/apache2/error.log

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

CustomLog /var/log/apache2/access.log combined

Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
    Options Indexes MultiViews FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all
    Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>

</VirtualHost>
1

1 Answer 1

2

You've a misunderstanding of how <VirtualHost > works. When using name-based virtual hosting (that is, same IP, multiple hostnames to distinct them), you need to have unique ServerNames.

Furthermore, you've set your DocumentRoot to /var/www/mwiki which causes http://localhost/ to show your wiki. Since you've one ServerName only (localhost), I suggest you to add an Alias instead of a virtual host.

<VirtualHost *:80>
    ServerName localhost
    DocumentRoot "/var/www/reviews.mysite.com/htdocs"
    AddDefaultCharset UTF-8
    Alias /mywiki /var/www/mwiki
    # ...

Virtual Hosts are only useful if you've multiple IPs or hostnames. Examples:

# Use ServerNames to distinct virtual hosts on 127.0.0.1
NameVirtualHost 127.0.0.1:80
<VirtualHost 127.0.0.1:80>
    ServerName site1.example.com
    DocumentRoot /var/www/site1.example.com
</VirtualHost>
<VirtualHost 127.0.0.1:80>
    ServerName site2.example.com
    DocumentRoot /var/www/site2.example.com
</VirtualHost>
<VirtualHost 127.0.0.2:80>
    ServerName meh.example.com
    DocumentRoot /var/www/meh.example.com
</VirtualHost>

Added to /etc/hosts:

127.0.0.1   site1.example.com
127.0.0.1   site2.example.com
# note: the next line is not included in the vhost config
127.0.0.1   invalid.example.com
127.0.0.2   meh.example.com

You can now visit the hosts using the {site1,site2,meh}.example.com domains. If you open 127.0.0.1 or invalid.example.com, the first vhost (site1.example.com) will be picked.

2
  • thanks! I was trying to solve this problem for 3 days :)
    – upstream
    May 26, 2011 at 14:54
  • @upstream: ouch, remember that if you've no clue, read the manual at httpd.apache.org/docs/2.2
    – Lekensteyn
    May 26, 2011 at 15:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .