Jump to content

I'm getting a Forbidden error on my local server


foxclone
Go to solution Solved by kicken,

Recommended Posts

I'm getting a "Forbidden You don't have permission to access this resource." on my local Apache2 server. Here's my foxclone.conf

		<VirtualHost *:80>
			ServerAdmin webmaster@localhost
			ServerName foxclone
			ServerAlias foxclone
			DocumentRoot /var/www/foxclone/public_html
			<Directory />
				AllowOverride All
			</Directory>
			<Directory /var/www/foxclone/public_html>
				Options Indexes FollowSymLinks MultiViews
				AllowOverride all
				Require all granted
			</Directory>
			ErrorLog /var/log/apache2/foxclone-error.log
			LogLevel error
			CustomLog /var/log/apache2/foxclone-access.log combined
		</VirtualHost>

It is shown in /etc/hosts as 127.0.0.1  foxclone.

I have no idea where to go from here and appreciate any guidance on how to fix this.

Link to comment
Share on other sites

@kicken - When I ran 'sudo apachectl configtest' I got a warning as follows: AH00112: Warning: DocumentRoot [/var/www/html] does not exist. Doc Root is declared in the config file I posted. There were no errors shown in the error log.
 

Edited by foxclone
Link to comment
Share on other sites

I just checked permissions. They are okay. OOPs...found a file in root group, changed it to my group. Now getting a http 500 error.

BTW - I don't have a .htaccess file on my local server.

Edited by foxclone
Link to comment
Share on other sites

45 minutes ago, foxclone said:

When I ran 'sudo apachectl configtest' I got a warning as follows: AH00112: Warning: DocumentRoot [/var/www/html] does not exist.

You probably have another/default host that is declaring the document root /var/www/html.  You could either find that configuration and remove it, or create that directory.

Your error log should have some indication as to what the problem is.  Either in the one you defined (/var/log/apache2/foxclone-error.log), a default one (probably /var/log/apache2/error.log), or if the 500 error is related to a PHP problem then in PHP's error log.

 

Link to comment
Share on other sites

I was checking the apache error log. When I checked the foxclone error log, I found this:

Quote

[Thu Apr 07 15:44:24.587110 2022] [php7:error] [pid 7672] [client 127.0.0.1:40790] PHP Fatal error:  require(): Failed opening required '../php/PDO_Connection_Select.php' (include_path='.:/usr/share/php') in /var/www/foxclone/public_html/index.php on line 3

Here's what I have in that section of code:

<?php 
$php_scripts = '../../php/';
require $php_scripts . 'PDO_Connection_Select.php';
require $php_scripts . 'GetUserIpAddr.php';

The $php_scripts points to a php directory one level above public_html/

Edited by foxclone
Link to comment
Share on other sites

  • Solution
31 minutes ago, foxclone said:

Where is it getting (include_path='.:/usr/share/php') from?

From PHP's include_path configuration.

The error message you show doesn't match the code you posted.  The error shows '../php' but the code shows '../../php'.

You need to get your path fixed, whatever you have is incorrect.  When it comes to requiring files, it's usually best to use __DIR__ and build a path from there.  For example, if your code file is /var/www/foxclone/public_html/index.php and you want to include the file /var/www/foxclone/php/PDO_Connection_Select.php, you'd do this:

require __DIR__.'/../php/PDO_Connection_Select.php'

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.