Forbidden, you don't have permission to access this resource after Ubuntu update - apache2

The last time I applied updates to my Ubuntu 22.04.1 LTS it clobbered my /etc/apache2/sites-available/000-default.conf file resetting it to the default. There was a file 000-default.dpkg-old which seemed to have the old contents, so I copied that back to replace 000-default.conf. I restarted the Apache2 server, but now I get "Forbidden, you don't have permission to access this resource". I have not changed anything else
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and por...
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin webmaster#localhost
DocumentRoot /home/jcobban/public_html
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
I have not changed the access to the web site directory.
$ ls -ld public_html
drwxrwxr-x 26 jcobban www-data 12288 Jan 20 18:27 public_html
/etc/apache2/sites-available$ ls -l
total 16
-rw-r--r-- 1 root root 1344 Feb 18 2020 000-default.conf
-rw-r--r-- 1 root root 1286 Jan 17 22:41 000-default.conf.new
-rw-r--r-- 1 root root 6219 Jan 17 22:41 default-ssl.conf
000-default.conf.new is what I renamed the version installed by Ubuntu
Exactly what "resource" is Apache complaining about?

Related

magento2 board doesn't show up properly

Hello i am trying to configure a magento site in my localhost i have to change the url from localhost/magento2 to localhost here my apache configuration
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin webmaster#localhost
DocumentRoot /var/www/magento2/
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
In my database i change the url
but my site looks like this
if a click y link i get 404 not found error for example
http://localhost/women/tops-women/jackets-women.html
Can you please check if you have a .htaccess default file on pub/static location ?
If you are missing that, put one there by copying from default Magento files..
Also if check if you have enabled mod_rewrite module in apache2.

How to enable a web server and webdav server simultaneously on Raspberry Pi 3?

My Pi version is:
pi#raspberrypi:~ $ uname -a
Linux raspberrypi 4.19.66-v7+ #1253 SMP Thu Aug 15 11:49:46 BST 2019 armv7l GNU/Linux
Apache version installed on Pi:
pi#raspberrypi:~ $ apache2 -version
Server version: Apache/2.4.25 (Raspbian)
Server built: 2019-10-13T15:43:54
The web-server is successfully serving a WordPress site on http://localhost. I am trying to enable WebDAV based access simultaneously. I have following two sites configured:
pi#raspberrypi:/etc/apache2/sites-available $ pwd
/etc/apache2/sites-available
pi#raspberrypi:/etc/apache2/sites-available $ cat 000-default.conf
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
pi#raspberrypi:/etc/apache2/sites-available $ cat 001-default.conf
DavLockDB /usr/local/apache2/var/DavLock
NameVirtualHost *
<VirtualHost *>
ServerAdmin webmaster#localhost
DocumentRoot /var/www/web1/web/
<Directory /var/www/web1/web/>
DAV On
Options Indexes MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
Alias /webdav /var/www/web1/web
<Location /webdav>
AuthType Basic
AuthName "webdav"
AuthUserFile /var/www/web1/passwd.dav
Require valid-user
</Location>
</VirtualHost>
I can see the two sites loaded:
pi#raspberrypi:/etc/apache2/sites-available $ pwd
/etc/apache2/sites-available
pi#raspberrypi:/etc/apache2/sites-available $ apachectl -D DUMP_VHOSTS
AH00548: NameVirtualHost has no effect and will be removed in the next release /etc/apache2/sites-enabled/001-default.conf:2
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
VirtualHost configuration:
*:80 127.0.1.1 (/etc/apache2/sites-enabled/000-default.conf:1)
*:* 127.0.1.1 (/etc/apache2/sites-enabled/001-default.conf:3)
pi#raspberrypi:/etc/apache2/sites-available $
However, cadaver cannot reach the webDAV:
pi#raspberrypi:/etc/apache2/sites-available $ cadaver http://localhost/webdav/
Could not access /webdav/ (not WebDAV-enabled?):
405 Method Not Allowed
Connection to `localhost' closed.
dav:!>
What am I doing wrong?

Adding another port apache2

I'm trying to run a website on both port 80 and 1998 on apache2 and in sites-available my config looks like this:
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin admin#mafiakampen.com
DocumentRoot /var/www/html/mv
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
<VirtualHost *:1998>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin admin#mafiakampen.com
DocumentRoot /var/www/html/
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
Then I restarted apache2 and rsent the command iptables -A INPUT -p tcp --dport 1998 --jump ACCEPT.
Now when I'm going to myserverip:1998 I get that the page isn't available and under that ERR_CONNECTION_REFUSED. How can I fix this?
I forgot to go to /etc/apache2/ports.conf and add Listen 1998
then i added NameVirtualHost *:1998 in my virtualhost

I need "/var/www" but Apache2 try to use an empty "/var/www/html"

This days I sleep with my http://localhost working, and reading pages from /var/www...
I woke up with an "AH00094" error at Apache2 log, and (Apache2 created?) a surprised /var/www/html, that Apache2 try to use.
Now my http://localhost/anything not works (error 404 at browser).
How to fix it? I need back my http://localhost working with files at /var/www!
Context
I am using Ubuntu12 with Apache2, all default and standard.
I checked out error log by tail /var/log/apache2/error.log in order to find out exact path that Apache, that shows
... [core:notice] [pid 1597] AH00094: Command line: '/usr/sbin/apache2'
... [:error] [pid 1604] [client 127.0.0.1:40624] script '/var/www/html/info.php' not found or unable to stat
The folder /var/www/html is new, all, like '/var/www/info.php', are at /var/www, not at /var/www/html.
I fixed the "AH00094" error editing
sudo nano /etc/apache2/apache2.conf
and adding at last line
ServerName localhost
(now no log errors about localhost, but nothing works)
PS: I checked other related issues, but not is the same problem: Permissions for /var/www/html , Attempting to use symbolic link for var/www/html
I'm afraid to use the clues of this answer ... in my Ubuntu there are no the .conf indicated files. I must create it? Is secure?
As #RahilWazir suggested, here is also my "/etc/apache2/sites-available/000-default.conf",
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
See here:
Why has the apache2 www dir been moved to /var/www/html?
The default directory apparently (we were also surprised) moved from /var/www to /var/www/html for htdocs in Debian, and Ubuntu copied this change. The reasons given are somewhat sound, but the upgrade path is probably “interesting” (as in the Chinese proverb)… as you have encountered.
If you want to use /www as root folder instead of /www/html you can simply edit the apache2 config file to have /var/www
Edit 000-default.conf
sudo gedit /etc/apache2/sites-available/000-default.conf
then change
DocumentRoot /var/www/html
to
DocumentRoot /var/www
Restart apache2 server :
sudo service apache2 restart

New site conf file for Apache 2.4.6

I had just upgraded to Ubuntu 13.10 earlier today. The version of Apache2 is 2.4.6 now. I removed the old site config file and tried to create a new one. When I was trying to copy default.conf, I found the format had been changed significantly. And here is an example of the new conf file. As lots of people do, I also have the forbidden problem even if I set my folder permission to 777.
1 <VirtualHost *:80>
2 # The ServerName directive sets the request scheme, hostname and port th at
3 # the server uses to identify itself. This is used when creating
4 # redirection URLs. In the context of virtual hosts, the ServerName
5 # specifies what hostname must appear in the request's Host: header to
6 # match this virtual host. For the default virtual host (this file) this
7 # value is not decisive as it is used as a last resort host regardless.
8 # However, you must set it for any further virtual host explicitly.
9 ServerName www.janicezhang.me
10
11 ServerAdmin webmaster#localhost
12 DocumentRoot /home/yifan/www/janice
13
14 # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
15 # error, crit, alert, emerg.
16 # It is also possible to configure the loglevel for particular
17 # modules, e.g.
18 #LogLevel info ssl:warn
19
20 ErrorLog ${APACHE_LOG_DIR}/error.log
21 CustomLog ${APACHE_LOG_DIR}/access.log combined
22
23 # For most configuration files from conf-available/, which are
24 # enabled or disabled at a global level, it is possible to
25 # include a line for only one particular virtual host. For example the
26 # following line enables the CGI configuration for this host only
27 # after it has been globally disabled with "a2disconf".
28 #Include conf-available/serve-cgi-bin.conf
29 </VirtualHost>
I am just wondering if there is some toturial to set up virtual host for apache 2.4.6 in ubuntu 13.10. Thanks.
OK, I solved the problem by myself. Two things need to be done.
First, add lines in your site config file like this:
<Directory "/home/yifan/www/janice">
Options ExecCGI
AllowOverride all
Require all granted
</Directory>
After this, I can browse into the site without the forbidden error. However, the php file is displayed as plain text. I check the folder mods-enabled and find php5 is not here. I have no idea why php5 is lost during upgrading. So just reinstall it by
sudo apt-get install libapache2-mod-php5
Then, the site is recovered.

Resources