Syed Jahanzaib Personal Blog to Share Knowledge !

December 27, 2012

Short notes for Ubuntu 12.4 Apache Server


Following are some short notes / references for APACHE related configuration in Ubuntu
[I used Ubuntu 12.4 version in this post]

1- Howto Disable DIRECTORY BROWSING in apache2 / Ubuntu 12.4

If you want to Disable Browsing on every folder inside /var/www/ then Edit following file

nano /etc/apache2/sites-available/default

& Change the Options

‘Options Indexes FollowSymLinks MultiViews’
‘Options FollowSymLinks MultiViews’

(means Remove the Indexes word).
and restart apache2 service by

service apcahe2 restart

OR to Disable Directory Browsing for ‘specific folder’ like /var/www/backup

Remove the following directive from your required folder.


For example,  you want to remove directory browsing for /var/www/backup folder.
Edit the below file /etc/apache2/sites-enabled/000-default by using following command

nano /etc/apache2/sites-enabled/000-default

The Default config is below.

Alias /backup /var/www/backup

DirectoryIndex index.html
Options Includes Indexes FollowSymLinks MultiViews

Change it below

Alias /backup /var/www/backup

#DirectoryIndex index.html
Options Includes FollowSymLinks MultiViews

Save & Exit , then Restart APACHE Service by

service apache2 restart

2- Howto create Alias/Virtual Folder

To create Alias, for we want to access a folder inside apache by short name like /panel,

Edit the below file, and add the data as showed below

nano /etc/apache2/sites-enabled/000-default

now paste following before </VirtualHost> word (this word is usually the last line in this config file

DirectoryIndex admin.php
Options Includes FollowSymLinks MultiViews
AllowOverride None
order allow,deny
allow from all

Save & Exit , then Restart APACHE Service by

service apache2 restart

Now you can access the panel by


and default page admin.php will be page as we have configured it in above code.

4- Howto Password Protect Apache Folder with .htaccess

If you want to password protect specific folder in Apache so unauthorized users cannot access it, use the following method. There are other better methods available, You can follow them for best practices. I just achieved it this way,,,

First Create password file

htpasswd -c /etc/apache2/passwd zaibtest

(Replace zaibtest with your required username, It will ask you for password, enter password you like to set for user zaibtest. Also you can save this file anywhere you like)

Now protect your required folder, for example I want to protect /var/www/backup folder, then use the following directives in in /etc/apache2/sites-enabled/000-default

nano /etc/apache2/sites-enabled/000-default

Now in end before </Virtualhost> , add following lines …

AllowOverride All
Require all granted

Save & Exit , then Restart APACHE2 Service by

service apache2 restart

Now try to access the folder, it will ask you the password.

After providing valid id password, you can access your folder. (I use it to download backup data from remote location)




apache2: Could not reliably determine the server’s fully qualified domain name,

 … waiting ..
apache2: Could not reliably determine the server’s fully qualified name

If you see above error while restarting apache2 service, To fix that problem, you need to add and directive in the the httpd.conf file. Open the terminal and type,

nano /etc/apache2/httpd.conf

By default httpd.conf file will be blank. Now, simply add the following line to the file.

ServerName localhost

Save & EXIT.

Now restart the server.

service apache2 restart
This time, you will not see any error. 🙂

6- Howto set Default page to some other page/extension

Edit file `etc/apache2/mods-available/dir.conf` by

nano /etc/apache2/mods-available/dir.conf

and add your option like

DirectoryIndex admin.php index.html index.cgi index.php index.xhtml index.htm
Save & restart apache2 service
service apache2 restart

7- Creating Short name (ALIAS) for Radius Manager

If you want to access your radius manager admin panel via short name (like alias)
Example: You want to use short path to actually access the

Then edit file /etc/apache2/sites-enabled/000-default

and add lines before /virtualhost directive, so the last line of this file should be like this…
Please remove Hash Sign in below lines , because wordpress does not accept the coding with slah /

Alias /panel /var/www/radiusmanager

DirectoryIndex admin.php
Options Includes FollowSymLinks MultiViews
AllowOverride None
order allow,deny
allow from all

Now restart apache by service apache2 restart and try to access the site using /panel alias.

Change apache default port


nano /etc/apache2/ports.conf

# Change Listen 80 to some other port example 1235

Listen 1235

Save and exit.

Now edit

nano /etc/apache2/sites-enabled/000-default

and change <VirtualHost *:80> to some other port like

save and exit,

restart apache

service apache2 restart



Syed Jahanzaib

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: