Skip to content

Easy changing Apache root web folder “www”

March 30, 2010

I have started to learn more about PHP.  I have basic PHP knowledge  but I ‘ve decided to learn advance concepts. So many people who love Java, C# and other pure OO languages, dislike PHP. I did it to, but I figure out that I learnt PHP  like procedural languages and I used it only for small piece of work. PHP is also object-oriented language (early versions had less implemented OO concepts than version 5). If  you want to work with PHP you have to install Apache and MySQL server. You can also run PHP on different web server and database server (for example Oracle) but this is common starting point for every person who  want to work with PHP.

There are so many tutorials and trick to install Apache, MySQL server and PHP (LAMP) on ubuntu. Here is instructions from Ubuntu documentation but you can always  google it.

After installation you have to deal with very annoying problem. The web root directory www is in /var folder and you don’t have permissions to create files or folder with IDE in that directory cause the root is owner. You have to change it. It easy, just type this command to change /etc/apache2/sites-available/default file.

sudo gedit /etc/apache2/sites-available/default

And gedit will open file. Change DocumentRoot value (/var/www/) to desired destination for web root file. In my case it is look like this:

NameVirtualHost *
<VirtualHost *>
	ServerAdmin webmaster@localhost

	DocumentRoot /home/ivan/workspace/apache2/
	<Directory />
		Options FollowSymLinks
		AllowOverride None
		Options Indexes FollowSymLinks MultiViews
		AllowOverride None
		Order allow,deny
		allow from all

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

	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
	ServerSignature On

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


Restart Apache server:

 sudo /etc/init.d/apache2 restart

The end.


From → ubuntu

  1. Romie permalink

    Hey nice tutorial..worked fine.
    Thanks a lot

  2. Everyone loves it when people come together and share opinions.
    Great blog, stick with it!

  3. s613420 permalink

    Great stuff!!
    Thanks a lot :).

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: