Getting 403 Error when setting up virtual host in Ubuntu

Problems with the Linux version of XAMPP, questions, comments, and anything related.

Getting 403 Error when setting up virtual host in Ubuntu

Postby jaknife » 19. July 2015 18:29

Using Xampp 5.6.8-0
Ubuntu 14.04

Trying to set up a virtual host. Have followed the advice in a number of tutorials and keep getting the same error.

I set up a folder on my desktop, as per tutorial instructions, called phpcourse
Put a file inside it called index.php with "Hello World" as the text.

Added the following line to /etc/hosts file:
Code: Select all
127.0.0.1    phpcourse.dev


Uncommented the following line in /opt/lampp/etc/httpd.conf
Code: Select all
Include etc/extra/httpd-vhosts.conf


Added the following code to /opt/lampp/etc/extra/httpd-vhosts.conf
Code: Select all
<VirtualHost *:80>
    DocumentRoot "/home/username/Desktop/phpcourse"
    ServerName phpcourse.dev
    <Directory "/home/username/Desktop/phpcourse">
        Require all granted
    </Directory>
</VirtualHost>


After making these changes, I type phpcourse.dev into my address bar and get the following error. Incidentally this also happens when I type localhost into my address bar. So not only does it not work but it also prevents xampp from working at all until I undo the changes again.

Code: Select all
Access forbidden!

You don't have permission to access the requested directory. There is either no index document or the directory is read-protected.

If you think this is a server error, please contact the webmaster.
Error 403
phpcourse.dev
Apache/2.4.12 (Unix) OpenSSL/1.0.1m PHP/5.6.8 mod_perl/2.0.8-dev Perl/v5.16.3
jaknife
 
Posts: 2
Joined: 19. July 2015 17:07
Operating System: Ubuntu 14.04

Re: Getting 403 Error when setting up virtual host in Ubuntu

Postby Nobbie » 19. July 2015 19:03

1) Error 403 means, that Apache cannot access /home/username/Desktop/phpcourse. Apache runs with a certain UserID (this is specified by "User = ...." in httpd.conf), this User obviously cannot read the DocumentRoot. You have to grant sufficient rights on operating system level (it is NOT a question of Apache configuration) and keep in mind, that you have to grant sufficient rights recursively to all(!) parent directories as well (that is how Linux Rights Management works).

2) As you applied a VirtualHost, the "external" configuration of localhost is obsolete, Apache ignores this. When using VirtualHosts, you MUST specify a VirtualHost for every host, i.e. for "localhost" as well. If you do not so, Apache takes the FIRST VirtualHost(in this case the only one VirtualHost) for unknown hostnames (i.e. "localhost"), therefore localhost now fails also, as it also yields to /home/username/Desktop/phpcourse
Nobbie
 
Posts: 13183
Joined: 09. March 2008 13:04

Re: Getting 403 Error when setting up virtual host in Ubuntu

Postby jaknife » 19. July 2015 21:16

Okay, thx. I'll tackle one thing at a time. I did a search in the text-file /opt/lampp/etc/httpd.conf for "user" but I never found any phrase like "user=" or "prefix_user_suffix=" or anything like that. Is there any other file, or a command that will tell me the user?
jaknife
 
Posts: 2
Joined: 19. July 2015 17:07
Operating System: Ubuntu 14.04

Re: Getting 403 Error when setting up virtual host in Ubuntu

Postby Nobbie » 19. July 2015 22:56

jaknife wrote:but I never found any phrase like "user="


The equation ("=") is optional, simply look for "user" or "User".
Nobbie
 
Posts: 13183
Joined: 09. March 2008 13:04


Return to XAMPP for Linux

Who is online

Users browsing this forum: No registered users and 20 guests