foxclone Posted April 7, 2022 Share Posted April 7, 2022 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. Quote Link to comment https://forums.phpfreaks.com/topic/314681-im-getting-a-forbidden-error-on-my-local-server/ Share on other sites More sharing options...
kicken Posted April 7, 2022 Share Posted April 7, 2022 Look in the error log, see if it has any additional information about why it's returning that response. Could be a file permission problem, apache might not have permission to read /var/www/foxclone/public_html. Quote Link to comment https://forums.phpfreaks.com/topic/314681-im-getting-a-forbidden-error-on-my-local-server/#findComment-1595136 Share on other sites More sharing options...
foxclone Posted April 7, 2022 Author Share Posted April 7, 2022 (edited) @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 April 7, 2022 by foxclone Quote Link to comment https://forums.phpfreaks.com/topic/314681-im-getting-a-forbidden-error-on-my-local-server/#findComment-1595137 Share on other sites More sharing options...
foxclone Posted April 7, 2022 Author Share Posted April 7, 2022 (edited) 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 April 7, 2022 by foxclone Quote Link to comment https://forums.phpfreaks.com/topic/314681-im-getting-a-forbidden-error-on-my-local-server/#findComment-1595138 Share on other sites More sharing options...
kicken Posted April 7, 2022 Share Posted April 7, 2022 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. Quote Link to comment https://forums.phpfreaks.com/topic/314681-im-getting-a-forbidden-error-on-my-local-server/#findComment-1595139 Share on other sites More sharing options...
foxclone Posted April 7, 2022 Author Share Posted April 7, 2022 (edited) 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 April 7, 2022 by foxclone Quote Link to comment https://forums.phpfreaks.com/topic/314681-im-getting-a-forbidden-error-on-my-local-server/#findComment-1595140 Share on other sites More sharing options...
foxclone Posted April 7, 2022 Author Share Posted April 7, 2022 Where is it getting (include_path='.:/usr/share/php') from? Quote Link to comment https://forums.phpfreaks.com/topic/314681-im-getting-a-forbidden-error-on-my-local-server/#findComment-1595141 Share on other sites More sharing options...
Solution kicken Posted April 7, 2022 Solution Share Posted April 7, 2022 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' Quote Link to comment https://forums.phpfreaks.com/topic/314681-im-getting-a-forbidden-error-on-my-local-server/#findComment-1595142 Share on other sites More sharing options...
foxclone Posted April 7, 2022 Author Share Posted April 7, 2022 Thanks, that took care of it. I'll put a sticky on my computer to remind me. Quote Link to comment https://forums.phpfreaks.com/topic/314681-im-getting-a-forbidden-error-on-my-local-server/#findComment-1595143 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.