Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Install Apache 2.4.7 on Ubuntu 14.04

Tags:

apache

ubuntu

I have a following problem. Install Apache 2.4.7 on Ubuntu. I created file in directory /etc/apache2/sites-available/

<VirtualHost ooo.net:80>

ServerName ooo.net
ServerAlias www.ooo.net
ServerAdmin [email protected]
DocumentRoot /home/user/ooo/

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

in hosts

127.0.0.1   ooo.net
127.0.1.1   pc

I visited ooo.net and saw following result

Forbidden You don't have permission to access / on this server. Apache/2.4.7 (Ubuntu) Server at localhost Port 80

What am I doing wrong?

error.log -

[Sat Apr 12 19:30:57.276525 2014] [core:error] [pid 1213:tid 140219565360896] (13)Permission denied: [client 127.0.0.1:37136] AH00035: access to / denied (filesystem path '/home/user/ooo') because search permissions are missing on a component of the path
[Sat Apr 12 19:30:57.539816 2014] [core:error] [pid 1213:tid 140219556968192] (13)Permission denied: [client 127.0.0.1:37136] AH00035: access to /favicon.ico denied (filesystem path '/home/user/ooo') because search permissions are missing on a component of the path

access.log -

127.0.0.1 - - [12/Apr/2014:19:30:57 +0400] "GET / HTTP/1.1" 403 495 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/33.0.1750.152 Chrome/33.0.1750.152 Safari/537.36"
127.0.0.1 - - [12/Apr/2014:19:30:57 +0400] "GET /favicon.ico HTTP/1.1" 403 505 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/33.0.1750.152 Chrome/33.0.1750.152 Safari/537.36"

ls -ltr after first answer -

drwxr-sr-x 2 user www-data   4096 апр.  10 20:41 errors
-rwxr-sr-x 1 user www-data   9062 апр.  10 20:41 about.htm
-rwxr-sr-x 1 user www-data   7116 апр.  10 20:41 admin.htm
-rwxr-sr-x 1 user www-data   2884 апр.  10 20:41 admin_art.inc
-rwxr-sr-x 1 user www-data 367112 апр.  10 20:41 ARIAL.TTF
-rwxr-sr-x 1 user www-data   4767 апр.  10 20:41 admin_d2.inc
-rwxr-sr-x 1 user www-data   2958 апр.  10 20:41 admin_exb.inc
-rwxr-sr-x 1 user www-data   2369 апр.  10 20:41 admin_faq.inc
-rwxr-sr-x 1 user www-data   1846 апр.  10 20:41 admin_fbk.inc
-rwxr-sr-x 1 user www-data   1791 апр.  10 20:41 admin_fbk2.inc
-rwxr-sr-x 1 user www-data   2657 апр.  10 20:41 admin_gbk.inc
-rwxr-sr-x 1 user www-data   3881 апр.  10 20:41 admin_frm.inc
-rwxr-sr-x 1 user www-data   2616 апр.  10 20:41 admin_gbl.inc
-rwxr-sr-x 1 user www-data   8197 апр.  10 20:41 admin_img.inc
-rwxr-sr-x 1 user www-data   7352 апр.  10 20:41 admin_new.inc
like image 260
serezha93 Avatar asked Apr 10 '14 18:04

serezha93


4 Answers

The problem relies in the fact that Apache default configuration is a bit more restrictive from 2.4.3 onwards. Directories outside the default Document Root are prohibited by default and have to be enabled explicitly. See: Install Apache web server on Ubuntu 13.10

Basically you should add:

Require all granted

Underneath somewhere under the Directory directive.

like image 159
Irve Avatar answered Nov 14 '22 18:11

Irve


Your webserver is running as www-data. Therefore you need to add the user account that owns your new docroot to this www-data group using the following command.

xxx$ sudo usermod -a -G groupName userName

where groupname is www-data and userName is your username that owns the docroot.

You can reference this SO answer that explains why you are doing this.

Lastly, that command I asked you to execute the first time, ls -ltr would have provided all the info I needed to answer this yesterday. If your going to ask questions, please provide the details asked for when asked.

Hope this helps, Pat

like image 41
apesa Avatar answered Nov 14 '22 19:11

apesa


Just in case any other user have same problem. From Ubuntu 14.04, if you are hosting virtual host outside of /var/www or /usr/share, you need to add the path to white list in /etc/apache2/apache2.conf. In this case, like this

<Directory /home/user/>
        Options Indexes FollowSymLinks
        AllowOverride None
        Require all granted
</Directory>

Of course, permission need to be granted like @ptheo suggested

like image 2
hiennt Avatar answered Nov 14 '22 17:11

hiennt


They changed something with how they handle files. By default apache can only access files in /var/www or /usr/share. I just changed my folder over to be under /usr/share and the necessary configurations and voila. There is more guidance in the default index.html file at /var/www/html/index.html. Hope this helps.

like image 1
Pat Avatar answered Nov 14 '22 17:11

Pat