[SOLVED] Apache2 / Unable to start

Kernels & Hardware, configuring network, installing services

[SOLVED] Apache2 / Unable to start

Postby Antanaclase » 2013-07-03 08:52

Hi everyone,

I've started using Linux for the first time a few days ago, as I tried to install a Home server. I've followed a tutorial for the most part, but I'm stuck at a weird issue. A few google searches didn't help solving it :/

The issue:
If I type
Code: Select all
service apache2 start

I get
Code: Select all
Starting web server: apache2(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
Action 'start' failed.


However, a quick
Code: Select all
netstat -lnp

gives this
Code: Select all
tcp        0      0 0.0.0.0:10000           0.0.0.0:*               LISTEN      2683/perl
tcp        0      0 0.0.0.0:21              0.0.0.0:*               LISTEN      2154/proftpd: (acce
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      2347/sshd
tcp        0      0 127.0.0.1:3306          0.0.0.0:*               LISTEN      2469/mysqld
udp        0      0 0.0.0.0:21958           0.0.0.0:*                           1844/dhclient
udp        0      0 0.0.0.0:10000           0.0.0.0:*                           2683/perl
udp        0      0 0.0.0.0:68              0.0.0.0:*                           1844/dhclient
udp        0      0 192.168.2.107:123       0.0.0.0:*                           2011/ntpd
udp        0      0 127.0.0.1:123           0.0.0.0:*                           2011/ntpd
udp        0      0 0.0.0.0:123             0.0.0.0:*                           2011/ntpd


So... No port 80 is being used it seems here. I don't get it. Most of the google search answer had another process running through port 80, and simply killing it was enough to solve the issue. It doesn't seem to be the case for me...


Also I wonder whether this is related/normal:

Code: Select all
service apache2 stop
[ ok ] Stopping web server: apache2.
service apache2 stop
[ ok ] Stopping web server: apache2.
service apache2 stop
[ ok ] Stopping web server: apache2.
service apache2 stop
[ ok ] Stopping web server: apache2.


Should I be able to chain-stop apache2? Is this normal behaviour?

Thanks a lot for the answers, I a bit lost!
Last edited by Antanaclase on 2013-07-04 09:17, edited 1 time in total.
Antanaclase
 
Posts: 6
Joined: 2013-07-03 08:37

Re: Apache2 / Unable to start

Postby dilberts_left_nut » 2013-07-03 09:02

What tutorial did you follow?
What does 'service apache2 status' say?
You are running these as root?
AdrianTM wrote:There's no hacker in my grandma...
User avatar
dilberts_left_nut
 
Posts: 4992
Joined: 2009-10-05 07:54
Location: enzed

Re: Apache2 / Unable to start

Postby Antanaclase » 2013-07-03 10:05

Hello!

I followed this tutorial: http://my-music.mine.nu/images/rpi_rasp ... _setup.pdf

The status is "NOT running"

And yes, I am running as root.
Antanaclase
 
Posts: 6
Joined: 2013-07-03 08:37

Re: Apache2 / Unable to start

Postby dilberts_left_nut » 2013-07-03 11:04

OK.
I don't know Raspbian or what, if anything, is different from vanilla debian.

Antanaclase wrote:I get
Code: Select all
Starting web server: apache2(98)Address already in use: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down

No other webservers been installed?
All net interfaces up and working?

Code: Select all
Unable to open logs
Action 'start' failed.

This also seems significant.
/var/log writable?
AdrianTM wrote:There's no hacker in my grandma...
User avatar
dilberts_left_nut
 
Posts: 4992
Joined: 2009-10-05 07:54
Location: enzed

Re: Apache2 / Unable to start

Postby Antanaclase » 2013-07-03 16:56

I don't think I have any other webserver installed, I strictly followed the tutorial, so I have those programs installed:
Apache2
PHP5
MySQL
ZenMap
PHPMyAdmin
Webmin
Webalizer

As I mentioned in my first post, this is my first "contact" with any Linux distribution, so I'm not exactly sure what you mean by
All net interfaces up and working?

or
/var/log writable?


Sorry for the hassle, I'm starting to wonder whether this was a good idea at all as an "introduction" to Linux.
Antanaclase
 
Posts: 6
Joined: 2013-07-03 08:37

Re: Apache2 / Unable to start

Postby js3915 » 2013-07-03 19:58

Sounds like you have a service already running.. Have you tried A. rebooting the computer.. and/or B seeing if you can open up the default apache2 webpage? simply by going to a browser and entering in http://localhost or the IP address of the machine your on?

Ive never used Raspberry PI i dont know whats different than pure debian.. I know in debian on a clean install if you run by root or sudo tasksel.. You can install a web-server by 1 click.. Ubuntu which is based on debian also running apt-get install tasksel then running sudo tasksel gives you same option but believe ubuntu versions you can select LAMP which is your Apache Mysql and PHP.. Hopefully someone will be able to help.. it might even be in your apache.conf file the error too you should be able to copy the file and paste here not sure on Raspberry but might be in /etc/apache2/apache2.conf or something like that
js3915
 
Posts: 3
Joined: 2013-06-21 15:40

Re: Apache2 / Unable to start

Postby Antanaclase » 2013-07-03 21:38

Hi

I have rebooted the computer a few times already since the problem occured with no change.

The local IP of the computer has worked for a while, I could access the "PHPMyAdmin" configuration tool from another computer. But since the problem started, the load doesn't seem to work.

Here is the apache2.conf file:
Code: Select all
#       /etc/apache2/
#       |-- apache2.conf
#       |       `--  ports.conf
#       |-- mods-enabled
#       |       |-- *.load
#       |       `-- *.conf
#       |-- conf.d
#       |       `-- *
#       `-- sites-enabled
#               `-- *
#
#
# * apache2.conf is the main configuration file (this file). It puts the pieces
#   together by including all remaining configuration files when starting up the
#   web server.
#
#   In order to avoid conflicts with backup files, the Include directive is
#   adapted to ignore files that:
#   - do not begin with a letter or number
#   - contain a character that is neither letter nor number nor _-:.
#   - contain .dpkg
#
#   Yet we strongly suggest that all configuration files either end with a
#   .conf or .load suffix in the file name. The next Debian release will
#   ignore files not ending with .conf (or .load for mods-enabled).
#
# * ports.conf is always included from the main configuration file. It is
#   supposed to determine listening ports for incoming connections, and which
#   of these ports are used for name based virtual hosts.
#
# * Configuration files in the mods-enabled/ and sites-enabled/ directories
#   contain particular configuration snippets which manage modules or virtual
#   host configurations, respectively.
#
#   They are activated by symlinking available configuration files from their
#   respective *-available/ counterparts. These should be managed by using our
#   helpers a2enmod/a2dismod, a2ensite/a2dissite. See
#   their respective man pages for detailed information.
#
# * Configuration files in the conf.d directory are either provided by other
#   packages or may be added by the local administrator. Local additions
#   should start with local- or end with .local.conf to avoid name clashes. All
#   files in conf.d are considered (excluding the exceptions noted above) by
#   the Apache 2 web server.
#
# * The binary is called apache2. Due to the use of environment variables, in
#   the default configuration, apache2 needs to be started/stopped with
#   /etc/init.d/apache2 or apache2ctl. Calling /usr/bin/apache2 directly will not
#   work with the default configuration.


# Global configuration
#

# ServerRoot: The top of the directory tree under which the server's
# configuration, error, and log files are kept.
#
# NOTE!  If you intend to place this on an NFS (or otherwise network)
# mounted filesystem then please read the LockFile documentation (available
# at <URL:http://httpd.apache.org/docs/2.2/mod/mpm_common.html#lockfile>);
# you will save yourself a lot of trouble.
#
# Do NOT add a slash at the end of the directory path.
#
#ServerRoot "/etc/apache2"

#
# The accept serialization lock file MUST BE STORED ON A LOCAL DISK.
#
LockFile ${APACHE_LOCK_DIR}/accept.lock

#
# PidFile: The file in which the server should record its process
# identification number when it starts.
# This needs to be set in /etc/apache2/envvars
#
PidFile ${APACHE_PID_FILE}

#
# Timeout: The number of seconds before receives and sends time out.
#
Timeout 300

#
# KeepAlive: Whether or not to allow persistent connections (more than
# one request per connection). Set to "Off" to deactivate.
#
KeepAlive On

#
# MaxKeepAliveRequests: The maximum number of requests to allow
# during a persistent connection. Set to 0 to allow an unlimited amount.
# We recommend you leave this number high, for maximum performance.
#
MaxKeepAliveRequests 100

#
# KeepAliveTimeout: Number of seconds to wait for the next request from the
# same client on the same connection.
#
KeepAliveTimeout 5

##
## Server-Pool Size Regulation (MPM specific)
##

# prefork MPM
# StartServers: number of server processes to start
# MinSpareServers: minimum number of server processes which are kept spare
# MaxSpareServers: maximum number of server processes which are kept spare
# MaxClients: maximum number of server processes allowed to start
# MaxRequestsPerChild: maximum number of requests a server process serves
<IfModule mpm_prefork_module>
    StartServers          5
    MinSpareServers       5
    MaxSpareServers      10
    MaxClients          150
    MaxRequestsPerChild   0
</IfModule>

# worker MPM
# StartServers: initial number of server processes to start
# MinSpareThreads: minimum number of worker threads which are kept spare
# MaxSpareThreads: maximum number of worker threads which are kept spare
# ThreadLimit: ThreadsPerChild can be changed to this maximum value during a
#              graceful restart. ThreadLimit can only be changed by stopping
#              and starting Apache.
# ThreadsPerChild: constant number of worker threads in each server process
# MaxClients: maximum number of simultaneous client connections
# MaxRequestsPerChild: maximum number of requests a server process serves
<IfModule mpm_worker_module>
    StartServers          2
    MinSpareThreads      25
    MaxSpareThreads      75
    ThreadLimit          64
    ThreadsPerChild      25
    MaxClients          150
    MaxRequestsPerChild   0
</IfModule>

# event MPM
# StartServers: initial number of server processes to start
# MinSpareThreads: minimum number of worker threads which are kept spare
# MaxSpareThreads: maximum number of worker threads which are kept spare
# ThreadsPerChild: constant number of worker threads in each server process
# MaxClients: maximum number of simultaneous client connections
# MaxRequestsPerChild: maximum number of requests a server process serves
<IfModule mpm_event_module>
    StartServers          2
    MinSpareThreads      25
    MaxSpareThreads      75
    ThreadLimit          64
    ThreadsPerChild      25
    MaxClients          150
    MaxRequestsPerChild   0
</IfModule>

# These need to be set in /etc/apache2/envvars
User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}

#
# AccessFileName: The name of the file to look for in each directory
# for additional configuration directives.  See also the AllowOverride
# directive.
#

AccessFileName .htaccess

#
# The following lines prevent .htaccess and .htpasswd files from being
# viewed by Web clients.
#
<Files ~ "^\.ht">
    Order allow,deny
    Deny from all
    Satisfy all
</Files>

#
# DefaultType is the default MIME type the server will use for a document
# if it cannot otherwise determine one, such as from filename extensions.
# If your server contains mostly text or HTML documents, "text/plain" is
# a good value.  If most of your content is binary, such as applications
# or images, you may want to use "application/octet-stream" instead to
# keep browsers from trying to display binary files as though they are
# text.
#
# It is also possible to omit any default MIME type and let the
# client's browser guess an appropriate action instead. Typically the
# browser will decide based on the file's extension then. In cases
# where no good assumption can be made, letting the default MIME type
# unset is suggested  instead of forcing the browser to accept
# incorrect  metadata.
#
DefaultType None


#
# HostnameLookups: Log the names of clients or just their IP addresses
# e.g., www.apache.org (on) or 204.62.129.132 (off).
# The default is off because it'd be overall better for the net if people
# had to knowingly turn this feature on, since enabling it means that
# each client request will result in AT LEAST one lookup request to the
# nameserver.
#
HostnameLookups Off

# ErrorLog: The location of the error log file.
# If you do not specify an ErrorLog directive within a <VirtualHost>
# container, error messages relating to that virtual host will be
# logged here.  If you *do* define an error logfile for a <VirtualHost>
# container, that host's errors will be logged there and not here.
#
ErrorLog ${APACHE_LOG_DIR}/error.log

#
# LogLevel: Control the number of messages logged to the error_log.
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
#
LogLevel warn

# Include module configuration:
Include mods-enabled/*.load
Include mods-enabled/*.conf

# Include list of ports to listen on and which to use for name based vhosts
Include ports.conf

#
# The following directives define some format nicknames for use with
# a CustomLog directive (see below).
# If you are behind a reverse proxy, you might want to change %h into %{X-Forwarded-For}i
#
LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %O" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent

# Include of directories ignores editors' and dpkg's backup files,
# see the comments above for details.

# Include generic snippets of statements
Include conf.d/

# Include the virtual host configurations:
Include sites-enabled/


Not sure it helps a lot though :/
Antanaclase
 
Posts: 6
Joined: 2013-07-03 08:37

Re: Apache2 / Unable to start

Postby dilberts_left_nut » 2013-07-03 22:19

Maybe as a test, try changing your ports.conf to listen on a different port.

Is /var/log mounted on local storage?
If apache can't write to it's logfiles, you won't have much info to track down this (or any other) issues. It may also be a reason for it to refuse to start.
AdrianTM wrote:There's no hacker in my grandma...
User avatar
dilberts_left_nut
 
Posts: 4992
Joined: 2009-10-05 07:54
Location: enzed

Re: Apache2 / Unable to start

Postby Antanaclase » 2013-07-04 09:06

A bit of news:

Upon another reboot this morning, I could access the Webmin page from another computer through the local IP of the server. I could reach this page:
Image

However, according to the Terminal, "service apache2 status" is still "NOT running".

As for the log issue, there is an apache2 folder in /var/log, which contains access.log, error.log and other_vhosts_access.log. The last error message was on moday (about when the issue started occuring) and is:
Code: Select all
[Mon Jul 01 22:23:31 2013] [notice] caught SIGTERM, shutting down
(2)No such file or directory: apache2: could not open error log file /var/www/website1/log/error.log.
Unable to open logs
(2)No such file or directory: apache2: could not open error log file /var/www/website1/log/error.log.
Unable to open logs
(2)No such file or directory: apache2: could not open error log file /var/www/website1/log/error.log.
Unable to open logs
(2)No such file or directory: apache2: could not open error log file /var/www/website1/log/error.log.
Unable to open logs
(2)No such file or directory: apache2: could not open error log file /var/www/website1/log/error.log.
Unable to open logs
(2)No such file or directory: apache2: could not open error log file /var/www/website1/log/error.log.
Unable to open logs
(2)No such file or directory: apache2: could not open error log file /var/www/website1/log/error.log.
Unable to open logs
(2)No such file or directory: apache2: could not open error log file /var/www/website1/log/error.log.
Unable to open logs


I have fixed a part of the issue here, as the "website1" folder had a capital W, not small one, and that was not typed correctly in the configuration, but I still get the issue ("unable to open logs").
Do I have to manually create the "error.log" file the this folder? If so, through which command?

If I change the "NameVirtualHost" and "Listen" ports to 90 for instance (in ports.conf), I get the following error message:

Code: Select all
Starting web server: apache2[Thu Jul 04 10:49:20 2013] [warn] NameVirtualHost *:90 has no VirtualHosts
Antanaclase
 
Posts: 6
Joined: 2013-07-03 08:37

Re: Apache2 / Unable to start

Postby Antanaclase » 2013-07-04 09:15

Ok, I think I solved the issue!

I simply removed this part:
Code: Select all
NameVirtualHost *:80
Listen *:80

from the ports.conf.

I had this idea since I noticed I had another "Listen 80" in my own website.conf file (see C2 step, page 8 of the tutorial I followed):
Code: Select all
# oursites.conf
# KA Spencer 201211
#
# First, the listening port (if not specified elsewhere):
Listen 80
#
# Next, the IP address and port for the virtual host. This assumes
# that you have only one IP address and port for this server.
# Be sure to substitute your own parameters throughout this file!
NameVirtualHost 10.0.0.97:80
#
# Next, add the default server, because creating a virtual host
# causes Apache2 to ignore the default server configured in the
# /etc/apache2/sites-available/default file.
# If you do not do this,any html files in /var/www will be ignored!
<VirtualHost 10.0.0.97:80>
DocumentRoot /var/www
DirectoryIndex index.htm index.html index.php
</VirtualHost>
#
# Next your first virtual server details:
<VirtualHost 10.0.0.97:80>
ServerAdmin email@youraddress.com
ServerName oursite1
DocumentRoot /var/www/oursite1
DirectoryIndex index.htm index.html index.php
ErrorLog /var/www/oursite1/log/error.log
CustomLog /var/www/oursite1/log/access.log
</VirtualHost>
# This will allow you to access your "oursite1" website by that name


I wondered whether this would conflict apache2, and after removing it, I get:
Code: Select all
root@raspberrypi:/home/pi# service apache2 start
[ ok ] Starting web server: apache2.

Code: Select all
root@raspberrypi:/home/pi# service apache2 status
Apache2 is running (pid 3450).


I have one last question here. Is it better I keep the Listen 80 in the ports.conf or in this very file?

Thanks everyone for the help!
Antanaclase
 
Posts: 6
Joined: 2013-07-03 08:37

Re: [SOLVED] Apache2 / Unable to start

Postby kyij » 2014-01-29 07:09

I know this is solved, but I figured I would say thanks - especially for posting your fix and not just "running" off, as it fixed my problem too :D
kyij
 
Posts: 26
Joined: 2014-01-08 00:01


Return to System configuration

Who is online

Users browsing this forum: No registered users and 8 guests

fashionable