G
G
GilbertAmethyst2020-11-22 02:56:13
symfony
GilbertAmethyst, 2020-11-22 02:56:13

Why does Apache 403 error occur?

Hello, dear experts) I was

creating a subdomain for the new version of my site (conditionally sub.domain.com). And ran into an unkillable 403 Apache error.
System: UBUNTU & Apache (DigitalOcean)
Framework: PHP Symfony

I will describe my actions.
Created folder:
/var/www/sub.domain.com

Created virtual host:
# /etc/apache2/sites-available/sub.domain.com.conf

<VirtualHost *:80>
        ServerAdmin [email protected]
    ServerName sub.domain.com
    ServerAlias www.sub.domain.com
        DocumentRoot /var/www/sub.domain.com

        <Directory /var/www/sub.domain.com>
            Options Indexes FollowSymLinks
            AllowOverride All
            Require all granted
        </Directory>

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

        <IfModule mod_dir.c>
            DirectoryIndex index.php index.pl index.cgi index.html index.xhtml index.htm
        </IfModule>
</VirtualHost>


Reloaded Apache:

systemctl reload apache2

Downloaded files, built the project:
php bin/console cache:clear APP_ENV=prod APP_DEBUG=0

Set maximum permissions on the folder:
chmod -R 777 /var/www/sub.domain.com

Downloaded /var/www /sub.domain.com/.htaccess:
RewriteEngine on
#RewriteCond %{HTTPS} off
#RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{REQUEST_URI} !public/
RewriteRule (.*) /public/$1 [L]


When I go to sub.domain.com I get an error:
Доступ запрещён!
У Вас нет прав доступа к этой директории. Отсутствует индексный файл, или директория недоступна для чтения. 
Error 403


Checked the Apache logs (only my attempts to restart Apache are visible):
[Sat Nov 21 18:48:27.288759 2020] [mpm_prefork:notice] [pid 31917] AH00169: caught SIGTERM, shutting down
[Sat Nov 21 18:48:27.396916 2020] [mpm_prefork:notice] [pid 32384] AH00163: Apache/2.4.29 (Ubuntu) OpenSSL/1.1.1 configured -- resuming normal operations
[Sat Nov 21 18:48:27.396988 2020] [core:notice] [pid 32384] AH00094: Command line: '/usr/sbin/apache2'


Also checked Symfony logs:
Just empty.

Checked folder permissions for www-data:
sudo -u www-data ls -l /var/www/sub.domain.com/
drwxrwxrwx  2 root root   4096 Nov 21 17:51 bin
-rwxrwxrwx  1 root root   2472 Nov 21 18:07 composer.json
-rwxrwxrwx  1 root root 262708 Nov 21 18:07 composer.lock
drwxrwxrwx  4 root root   4096 Nov 21 18:07 config
-rwxrwxrwx  1 root root      6 Nov 21 17:18 index.html
drwxrwxrwx  2 root root   4096 Nov 21 18:09 migrations
-rwxrwxrwx  1 root root   1065 Nov 21 18:09 phpunit.xml.dist
drwxrwxrwx  3 root root   4096 Nov 21 18:04 public
drwxrwxrwx  9 root root   4096 Nov 21 17:51 src
-rwxrwxrwx  1 root root  14176 Nov 21 18:20 symfony.lock
drwxrwxrwx 15 root root   4096 Nov 21 17:52 templates
drwxrwxrwx  2 root root   4096 Nov 21 17:52 tests
drwxrwxrwx  2 root root   4096 Nov 21 17:52 translations
drwxrwxrwx  4 root root   4096 Nov 21 18:09 var
drwxrwxrwx 20 root root   4096 Nov 21 18:20 vendor


How to figure out what the problem might be and solve it?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
G
galaxy, 2020-11-22
@GilbertAmethyst

Did you make a symlink in /etc/apache2/sites-enabled/?

K
Karpion, 2020-11-22
@Karpion

I read in the config:

<IfModule mod_dir.c>
  DirectoryIndex index.php index.pl index.cgi index.html index.xhtml index.htm
</IfModule>
mod_dir.cHave you connected the module ?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question