PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, March 15, 2022

[FIXED] How do I set up LAMP without the forbidden message when viewing my site?

 March 15, 2022     apache2, lamp     No comments   

Issue

I use a Linux Mint 16 + newest LAMP + Laravel.

I'm getting this error when I try viewing my website either via "localhost" or "127.0.0.1".

Forbidden

You don't have permission to access / on this server.
------------------------------------------------------
Apache/2.4.6 (Ubuntu) Server at 127.0.0.1 Port 80

My setting are as follows:

on /etc/hostname

NameServer ynwlocalwebserver

on /etc/hosts

127.0.0.1       localhost
127.0.1.1       ynwlocalwebserver

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

I only have one site-enable named "ynwlocalwebserver.conf" it's current contents for the meantime are:

NameVirtualHost *:80

<VirtualHost *:80>

  ServerName ynwlocalwebserver
  DocumentRoot /home/ynwmint/ynw/public
  ErrorLog ${APACHE_LOG_DIR}/error.log
  CustomLog ${APACHE_LOG_DIR}/access.log combined

  <Directory /home/ynwmint/ynw/public>
    AllowOverride All
    Order allow,deny
    Allow from all
  </Directory>

</VirtualHost>

<VirtualHost *:80>

  ServerName localhost
  DocumentRoot /home/ynwmint/ynw/public
  ErrorLog ${APACHE_LOG_DIR}/error.log
  CustomLog ${APACHE_LOG_DIR}/access.log combined

  <Directory /home/ynwmint/ynw/public>
    AllowOverride All
    Order allow,deny
    Allow from all
  </Directory>

</VirtualHost>

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

The folder ynw in "/home/ynwmint/ynw/public" is the Laravel project.

I put the chmod of the public folder to 777 (for the meantime) and chown it under www-data:www-data

What am I doing wrong, or what else do I need to check?

Thanks.


Solution

Apache 2.4 has some minor changes with regards to config.

This:

ServerName ynwlocalwebserver
DocumentRoot /home/ynwmint/ynw/public
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

<Directory /home/ynwmint/ynw/public>
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>

Should be changed to this:

<VirtualHost *:80>

    ServerName ynwlocalwebserver
    DocumentRoot /home/ynwmint/ynw/public
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    <Directory /home/ynwmint/ynw/public>
        Options +Indexes +FollowSymlinks + MultiViews
        AllowOverride All
        Require all granted
    </Directory>

</VirtualHost>

Also for added security you may want to this directory rule:

<Directory />
    Options FollowSymlinks
    AllowOverride None
</Directory>

Source: http://httpd.apache.org/docs/2.4/upgrading.html



Answered By - JC Ricaro
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home
View mobile version

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing