0

I managed to install virtual host on LAMP server and created the config file /etc/apache2/sites-available/site.com.conf

<Directory /home/ihab/Workspace/Webdev/site.com/public_html>
    AllowOverride All
</Directory>
<VirtualHost *:80>
        ServerName site.com
        ServerAlias www.site.com
        ServerAdmin webmaster@localhost
        DocumentRoot /home/ihab/Workspace/Webdev/site.com/public_html

        ErrorLog /home/ihab/Workspace/Webdev/site.com/logs/error.log
        CustomLog /home/ihab/Workspace/Webdev/site.com/logs/access.log combined

</VirtualHost>

While I have mod_rewrite enabled I did link my virtual host file from the sites-available directory to the sites-enabled directory:

sudo a2ensite site.com.conf

and added the assigned virtual host domain to my host file /etc/hosts:

127.0.1.1       site.com
127.0.1.1       www.site.com

I checked /site.com folder permission, reported as following:

drwxrwxr-x 4 www-data www-data 4096 Jul 18 13:55 .
drwxr-xr-x 4 ihab     www-data 4096 Jul 23 19:16 ..
drwxrwxr-x 2 www-data www-data 4096 Jul 18 13:56 logs
drwxrwxr-x 5 www-data www-data 4096 Jul 23 17:21 public_html

I went to my file explorer and discovered that directory site.com has lock icon while I have 403 Forbidden error when I go to site.com in browser. Any help solving the issue is much appeciated :)

0

Your problem may have its root in various causes, here are the solutions for two of them:

Folder and File Permissions

Not only the site.com folder, but also all parent folders need to have their permissions set so apache can traverse them. Please check if /home, /home/ihab, /home/ihab/Workspace and /home/ihab/Workspace/Webdev do have proper settings.
They either need to either

  • belong to the user as which apache runs (chown www-data:ihab - but that would prohibit you from modifying them if you do not pay close attention to their chmod)
  • their group has to be the one that the apache2 user has (chown ihab:www-data, that would work)
  • or you need to make sure the user www-data is in the group that those folders belong to (gpasswd -a www-data ihab or gpasswd -a www-data users for example)

Apache2 Grants

Under "normal" circumstances the webroot belongs at /var/www - for these folders the "grant" are set accordingly by the apache2 default configuration. You chose to have the files in another folder structure - which is fine but needs some tweaking:
add require all granted to those folders:

<Directory /home>
require all granted
</Directory>
<Directory /home/ihab>
require all granted
</Directory>
<Directory /home/ihab/Workspace>
require all granted
</Directory>
<Directory /home/ihab/Workspace/Webdev>
require all granted
</Directory>
<Directory /home/ihab/Workspace/Webdev/site.com>
require all granted
</Directory>
<Directory /home/ihab/Workspace/Webdev/site.com/public_html>
require all granted
</Directory>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy