title: Test your site locally with Apache on Ubuntu Linux
body: <p>I have various websites in my <em>/home/user/projects</em> folder and I want to be able to test them on the browser with <strong>Apache2</strong> (they have PHP files and connect to databases). </p>
  
  <p>I don't want to copy them to <em>var/www</em> each time I change something. I just want to open an URL in the browser and Apache should do the rest. Would also be great to assign fake domains by editing the hosts file but I don't know how to achieve it. I tried this <a href="http://www.elxis.org/guides/developers-guides/local-apache-and-virtual-hosts.html" rel="nofollow">solution</a> but I can't access the files.</p>
  
  <p><strong>UPDATE</strong>
  This is what I did up to now:</p>
  
  <ol>
  <li><p>Firstly, I configure the hosts file.  I open the <em>etc/hosts</em> file with <code>sudo</code> and add the following line: <code>127.0.0.2    projects</code>. Now I am supposed to be able to access <code>http://projects</code> from the browser</p></li>
  <li><p>Secondly, the Apache Virtual Directory. Inside the etc/apache2/sites-available folder I create a new file called projects and add the following code (inside <em>/home/user/projects</em> I have an <em>index.html</em> file): </p>
  
  <p><code>&lt;VirtualHost *:80&gt;
      ServerName com
      DocumentRoot /home/user/projects
  &lt;/VirtualHost&gt;</code></p>
  
  <p>I saved and executed <code>sudo a2ensite projects</code>, to activate the host. The symbolic links have been created in <code>/etc/apache2/sites-enabled</code></p></li>
  <li><p>Testing, after restarting Apache with <code>sudo service apache2 restart</code>. I only get this warning twice: </p>
  
  <p><code>Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName</code></p>
  
  <p>Now I enter <code>http://projects</code> in my browser but a <strong>403 Forbidden error</strong> is displayed (<code>You don't have permission to access / on this server</code>). I changed permissions of the /home/user/projects with <code>sudo chmod -R 755 /home/user/projects</code>, it is executable yet the same result.</p></li>
  </ol>