Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am new to linux/ubuntu, but I want to set up an apache webserver on an ubuntu VM. I created a VM on amazon AWS, installed the apache. But now I can not reach it via browser. I am not sure if the apache server is running correctly or if any ports are blocked.

I checked the apache version. Seems to be installed with "apache -version" and it shows me a valid version and installation date.

I check the open ports. It seems apache is listening on some ports (3609, 3614, 3615), but not on port 80? Could that be the issue? How can it be fixed?

Edit 1 : Acutally i wanted to add some sceenshots, but I can't do that with repuation lower than ten.

Edit 2:

  • "sudo /etc/init.d/apache2 status" tells me it is running
  • The error.log also looks good. It only says: "Apache/2.2.22 (Ubuntu) configured -- resuming normal operations

Edit 3: Localhost is reachable from the server. So it seems to be a firewall/connection problem. But the strange thing is: I can ping the port 80 on the server ip via telnet from outside.

Edit 4: I can reach my webserver from an other Amazon VM! So what does it mean: Is that a problem with the security groups from amazon then? I opend a lot of ports in my security group for testing purposes: enter image description here

The apache2.conf looks like this:

#
# 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/

The ports.conf looks like this:

NameVirtualHost *:80
Listen 80

<IfModule mod_ssl.c>
    # If you add NameVirtualHost *:443 here, you will also have to change
    # the VirtualHost statement in /etc/apache2/sites-available/default-ssl
    # to <VirtualHost *:443>
    # Server Name Indication for SSL named virtual hosts is currently not
    # supported by MSIE on Windows XP.
    Listen 443
</IfModule>

<IfModule mod_gnutls.c>
    Listen 443
</IfModule>

Edit 5:

If I try to reach the webserver, I get the message: "Website not available:" enter image description here

Edit 6:

"etc/apache2/sites-available/default" looks like this:

<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>

Edit 7:

Actually I can't ping my host, only telnet on port 80 works.

Edit 8:

local telnet "localhost 80" and "netstat -l" results:

"telnet":

enter image description here

"netstat -l": enter image description here

Edit 9:

Because it seems, that the webserver is listening on the ip6 ip, I changed my "ports.conf" and added the entry "Listen YOUR_AWS_IP:80" like "Christoph Eicke" suggested. Now the webserver seems listen on the ip4 adress. But I still can not reach the webserver.

enter image description here

share|improve this question
    
Have you checked if any Security Groups are applied to your (EC2?) instance? Perhaps they are preventing you from accessing apache from your IP address/network? –  KM. Aug 12 '13 at 13:56
    
@KM: Yes, for testing purposes I opend the TCP ports from 0-65535. –  jan Aug 12 '13 at 14:26
1  
Do you have another VM on the same segment that you can attempt to reach the web server with? –  Bob Baller Aug 12 '13 at 15:29
    
@Bob Baller: It works from an other Amazon VM! So what does it mean: Is that a problem with the security groups from amazon then? –  jan Aug 12 '13 at 15:41
    
How about posting the relevant pieces of your httpd configs? Listen ports, address, allow, denys, etc. Also, just a sanity check, but are you hitting the correct IP address? –  KM. Aug 12 '13 at 15:51

3 Answers 3

In you netstat -l command, I don't see anything listening on port 80 for IPv4. You webserver does however listen on the IPv6 interface.

It makes sense that locally you can connect to it because your tools probably can speak IPv6 already, and localhost resolves to a valid IPv6 IP through /etc/hosts. But your network probably doesn't speak IPv6 yet.

share|improve this answer
    
Good point. I just installed it with "apt-get install apache2". Should't that provide some kind of standard and working configuration? How can I change to config so the webserver listens on IP4? –  jan Aug 14 '13 at 9:30
    
To make sure that it listens on IPv4 you can write the listen parameter explicitly with the IPv4 address in ports.conf: Listen YOUR_AWS_IP:80. It's strange that it doesn't listen on the IPv4 interface. What does netstat -l give after you did this? –  Christoph Eicke Aug 14 '13 at 15:04
    
Changed it to IP4, but still not reachable (see "edit 9" in my post) –  jan Aug 15 '13 at 11:17

It's not 100% obvious from your question, so can I ask if you started Apache after you installed it? "sudo /etc/init.d/apache2 status" will tell you if it's actually running or not.

The next place I'd check would be Apache's log file, which you'll find under /var/log/apache2/.

Edit: Since both of those check out, are you able to see Apache locally from the server? Run a web browser on the server, point it at http://localhost and see what happens.

Edit 2: If Apache's running and no firewall rules are in place, then it's time to look at Apache's config itself for directives that would allow local connections but not remote ones. The assorted config files should be in /etc/apache2; have a look for lines like "deny from all" or "allow from < address range >".

share|improve this answer
    
Apache seems to be running and error.log shows no error -> I also updated my question with that information. –  jan Aug 12 '13 at 13:53
    
Localhost is reachable from the server. So it seems to be a firewall/connection problem. But the strange thing is: I can ping the port 80 on the server ip via telnet from outside. –  jan Aug 12 '13 at 15:15
    
I can't find anything like a deny or allow.... –  jan Aug 13 '13 at 9:37
    
So what actually do you see or what happens when you browse to your site using a browser? If you can telnet to the port, it is not a FW issue, and most likely it is a config issue as RainyRat points out. Try issuing some HTML commands over telnet to ascertain: stackoverflow.com/questions/13544857/… –  KM. Aug 13 '13 at 12:53
    
If I use commands like "GET" in my telnet session, I get the error, that it is not a valid command. –  jan Aug 13 '13 at 15:14

Probably you have standard set of Security Groups as well as one instance of EC2, but remember that you can make multiple Security Groups and multiple EC2 instances, so:

You have to assingn Security Group to EC2 instance.

Go to AWS website -> EC2 -> Instances -> select your instance -> Actions button -> Networking/Change Security Groups -> here you can assingn, in most cases just check 'default' and save.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.