Troubleshooting (Apache): Difference between revisions
(Initial creation - content from Apache page) |
(Added "Permission denied - unable to check htaccess file") |
||
(One intermediate revision by the same user not shown) | |||
Line 7: | Line 7: | ||
Perform the following in <code>/etc/apache2</code> folder to identify where the entries and delete the unwanted duplicates.. | Perform the following in <code>/etc/apache2</code> folder to identify where the entries and delete the unwanted duplicates.. | ||
grep NameVir * -R | grep NameVir * -R | ||
== Address Already In Use == | |||
On restarting Apache you get presented with the following error | |||
(98)Address already in use: make_sock: could not bind to address 0.0.0.0:80 | |||
no listening sockets available, shutting down | |||
Unable to open logs | |||
[fail] | |||
Apache is attempting to start but cannot bind (start listening on) TCP port 80 (or 443 if you're using SSL and the error refers to <code>0.0.0.0:443</code>, or another port if you're using non-standard ports. | |||
The reason for the problem can vary, and you need ascertain what's already using the port by running netstat and grep'ing for port 80 (or whatever port Apache won't start on). | |||
root@web2:/etc/apache2# netstat -lnp | grep :80 | |||
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 20482/apache2 | |||
* If Apache is already listening on the port (as shown in above example, running with [[Acronyms#P|PID]] 20482) | |||
** There is either a problem with the Apache config, and its trying to listen on the port twice, or you've got an old rogue process knocking around. | |||
*# Kill the process using the process ID | |||
*#* EG <code> kill 20482 </code> | |||
*# Restart Apache, if it starts OK - problem solved!, otherwise continue | |||
*#* <code> service apache2 restart </code> | |||
*# Check your config for multiple servers on the port | |||
*#* EG <code> grep -r 80 /etc/apache2/conf.d/* /etc/apache2/*.conf /etc/apache2/sites-enabled/* </code> | |||
*#* Multiple <code> <VirtualHost *:80> </code> are OK, multiple <code> Listen 80</code> or <code> NameVirtualHost *:80</code> are not, fix as required | |||
* If its another process you need to track down the cause and resolve. | |||
** If you haven't accidentally caused the problem, your server may have been breached. | |||
*# Kill the process by name (dodgy.pl in example below, in-case there's more than one running) | |||
*#* EG <code> killall -9 dodgy.pl </code> | |||
*# From root, find the file and delete | |||
*#* EG <code> cd / </code> | |||
*#* EG <code> find -iname dodgy.pl </code> | |||
*#* EG <code> rm -f /path/to/dodgy.pl </code> | |||
== Permission denied - unable to check htaccess file == | |||
Files within certain directories cannot be found when viewing via a web browser, and the Apache error logs have entries like... | |||
* <code> [Fri Jul 20 07:40:55 2012] [crit] [client 123.234.12.123] (13)Permission denied: /var/www/folder/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable </code> | |||
...you needn't be using an htaccess file to get the above error! | |||
Caused by incorrect permissions on the affected folder(s), to fix ensure that the web server has execute rights over the folder. So, assuming your web server user (<code>www-data</code>) has group rights over your site use to give execute rights to the group... | |||
* <code> chmod g+x <folder> </code> | |||
Source: http://www.liamdelahunty.com/tips/apache_pcfg_openfile_unable_to_check_htaccess.php | |||
[[Category:Apache]] | [[Category:Apache]] |
Latest revision as of 06:53, 28 August 2012
NameVirtualHost *:80 has no VirtualHosts
On restarting Apache you get presented with the following warning
[Thu Jan 12 10:58:20 2012] [warn] NameVirtualHost *:80 has no VirtualHosts
This is generally caused by duplicate NameVirtualHost
entries in your config.
Perform the following in /etc/apache2
folder to identify where the entries and delete the unwanted duplicates..
grep NameVir * -R
Address Already In Use
On restarting Apache you get presented with the following error
(98)Address already in use: make_sock: could not bind to address 0.0.0.0:80 no listening sockets available, shutting down Unable to open logs [fail]
Apache is attempting to start but cannot bind (start listening on) TCP port 80 (or 443 if you're using SSL and the error refers to 0.0.0.0:443
, or another port if you're using non-standard ports.
The reason for the problem can vary, and you need ascertain what's already using the port by running netstat and grep'ing for port 80 (or whatever port Apache won't start on).
root@web2:/etc/apache2# netstat -lnp | grep :80 tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 20482/apache2
- If Apache is already listening on the port (as shown in above example, running with PID 20482)
- There is either a problem with the Apache config, and its trying to listen on the port twice, or you've got an old rogue process knocking around.
- Kill the process using the process ID
- EG
kill 20482
- EG
- Restart Apache, if it starts OK - problem solved!, otherwise continue
service apache2 restart
- Check your config for multiple servers on the port
- EG
grep -r 80 /etc/apache2/conf.d/* /etc/apache2/*.conf /etc/apache2/sites-enabled/*
- Multiple
<VirtualHost *:80>
are OK, multipleListen 80
orNameVirtualHost *:80
are not, fix as required
- EG
- If its another process you need to track down the cause and resolve.
- If you haven't accidentally caused the problem, your server may have been breached.
- Kill the process by name (dodgy.pl in example below, in-case there's more than one running)
- EG
killall -9 dodgy.pl
- EG
- From root, find the file and delete
- EG
cd /
- EG
find -iname dodgy.pl
- EG
rm -f /path/to/dodgy.pl
- EG
Permission denied - unable to check htaccess file
Files within certain directories cannot be found when viewing via a web browser, and the Apache error logs have entries like...
[Fri Jul 20 07:40:55 2012] [crit] [client 123.234.12.123] (13)Permission denied: /var/www/folder/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable
...you needn't be using an htaccess file to get the above error!
Caused by incorrect permissions on the affected folder(s), to fix ensure that the web server has execute rights over the folder. So, assuming your web server user (www-data
) has group rights over your site use to give execute rights to the group...
chmod g+x <folder>
Source: http://www.liamdelahunty.com/tips/apache_pcfg_openfile_unable_to_check_htaccess.php