Easy changing Apache root web folder “www”
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
</Directory>
ivan/workspace/apache2/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
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
ServerSignature On
Alias /doc/ "/usr/share/doc/"
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>
Restart Apache server:
sudo /etc/init.d/apache2 restart
The end.