add alias in apache2, sites-enabled, 000-default

Asked by paul88 on 2011-09-07

Hi,
I want to add a Alias in apache2, sites-enabled, 000-default. But it did not worked.
Anyone who have any comments and opinion to solve this problem?
Thanks in Advance.

Below is the 000-default content:

NameVirtualHost *:80

#Virtual Host 1 - html example
<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 ${APACHE_LOG_DIR}/error.log
  Errorlog /var/log/apache2/error.log

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

 #CustomLog ${APACHE_LOG_DIR}/access.log combined
 CustomLog /var/log/apache2/access.log combined
 ServerSignature On

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

</VirtualHost>

#Virtual Host 2 - htmlCD

NameVirtualHost *
<VirtualHost *:80>
 ServerAdmin webmaster@localhost

 DocumentRoot /var/www/htmlCD
 <Directory />
  Options FollowSymLinks
  AllowOverride None
 </Directory>
 <Directory /var/www/htmlCD>
  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
  Errorlog /var/log/apache2/error.log

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

 #CustomLog ${APACHE_LOG_DIR}/access.log combined
 CustomLog /var/log/apache2/access.log combined
 ServerSignature On

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

</VirtualHost>

Question information

Language:
English Edit question
Status:
Answered
For:
Ubuntu apache2 Edit question
Assignee:
No assignee Edit question
Last query:
2011-09-08
Last reply:
2011-09-15
svens (svens) said : #1

Is it the htmlCD?

If yes, do this:

1. remove or comment:

#Virtual Host 2 - htmlCD

NameVirtualHost *
<VirtualHost *:80>
 ServerAdmin webmaster@localhost

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

2. add these lines to /etc/apache2/apache2.conf:

Alias /htmlCD /var/www/htmlCD
<Directory/var/www/htmlCD>
    Order allow,deny
    Allow from all
    AllowOverride All
    Options +Indexes
</Directory>

3. restart apache: /etc/init.d/apache2 restart

4. run "apache2ctl configtest" to check for apache config errors or "apache2ctl status"

5. Good luck.

paul88 (deasysyeung) said : #2

1) May i know which one i need to remove from part I: "1. remove or comment:" Is this: "NameVirtualHost *"
2) I add in line to apache2.conf what you suggest in "2. add these lines to /etc/apache2/apache2.conf:"
3) I restart "apache: /etc/init.d/apache2 restart"
4) It appear error message: /etc/apache2/sites-enabled/000-default: Action-configtest failed.
5) Is that a correct way what I put ALIAS to 000-default?
5) If i have 3 ALAIS program to test. What is the best way to do for ALIAS?
Thanks Constantin R

svens (svens) said : #3

it is from Line 49 in the output through line 65.
In fact, it is just the htmlCD alias section.

Yes, that is the correct place to put aliases in Ubuntu.
You might also want to enable the rewrite module if you use php generated links.
and also t he default site (depending on the error you get in the logs)

sudo a2enmod rewrite
sudo a2ensite default

service apache2 restart
or
/etc/init.d/apache2 restart

Can you help with this problem?

Provide an answer of your own, or ask paul88 for more information if necessary.

To post a message you must log in.