Friday, April 26, 2024
 Popular · Latest · Hot · Upcoming
24
rated 0 times [  24] [ 0]  / answers: 1 / hits: 339739  / 1 Year ago, tue, february 21, 2023, 5:03:09

I can access localhost but not the sub directories index.html



My default conf looks like:



<VirtualHost *:80>
ServerAdmin webmaster@localhost

DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/*/>
Allow from None
Order allow,deny
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>

ErrorLog ${APACHE_LOG_DIR}/error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog ${APACHE_LOG_DIR}/access.log combined




Even after allowing read/edit/write access to the directory, its showing Forbidden error. Tried all possible ways out in forums, didnt worked. Anyone has a solution.



Between above I tried something for sub directory access:



<Directory /var/www/*/>
Allow from None
Order allow,deny
</Directory>


Please suggest me possible solution. Thanks!


More From » apache2

 Answers
2

Let's make the vhost clear:



<VirtualHost *:80>
ServerAdmin webmaster@localhost

DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>

ErrorLog ${APACHE_LOG_DIR}/error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>


Then make sure you set the right permission like this:



sudo adduser <username> www-data
sudo chown -R www-data:www-data /var/www
sudo chmod -R g+rw /var/www

[#31300] Wednesday, February 22, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
tisglitter

Total Points: 307
Total Questions: 103
Total Answers: 119

Location: Bosnia and Herzegovina
Member since Thu, Jun 24, 2021
3 Years ago
tisglitter questions
Sun, Jan 9, 22, 16:18, 2 Years ago
Wed, Jun 1, 22, 18:03, 2 Years ago
Fri, Dec 10, 21, 14:31, 2 Years ago
;