# How do I verify if apache is only locally available?

## Kasumi_Ninja

I would like to run gtd-php. This a non password protected GTD application using mysql and apache. Initially I only want it to be locally accessible. How do I verify this? I tried punching in my ip address on another computer which resulted in a connection failure (I suspect this is due my routers firewall). Is this sufficient to ascertain that gtd-php isn't accessible for anyone not on my local network?

----------

## truc

```
netstat -laputen
```

----------

## Kasumi_Ninja

 *truc wrote:*   

> 
> 
> ```
> netstat -laputen
> ```
> ...

 

Thanks for your quick answer! Only I have troubles interpreting the output of this command. Where should I look for in order to determine Apache isn't accessible from outside?

Edit:

I didn't ran the command as root. Running it as root is more revealing:

```
tcp        0      0 :::80                   :::*                    LISTEN      0          35584      11393/apache2
```

This means apache is listening to the outside world   :Rolling Eyes: 

----------

## ToeiRei

Try to bind Apache to 127.0.0.1 address and you're safe.

Rei

----------

## truc

then go into your apache conf, and change or uncomment the line beginning with Listen localhost or Listen 127.0.0.1[:80] ...

----------

## Kasumi_Ninja

Thanks for the suggestions. Unfortunately I am a Apache n00b. That why I asked if there was a gui for Apache available. I hope this is the case otherwise I'll check out the various settings myself.

----------

## truc

Is editing a text file (in which you can even search for the string given above) *really* more complicated than tryin gto find  the right option in a GUI? 

Trust me, it isn't.

As far as I know there isn't any graphical configuration tool for apache anyway

----------

## ToeiRei

Webmin has a module for fucking up configuration files per mouseclick... 

Rei

----------

## Kasumi_Ninja

 *truc wrote:*   

> Is editing a text file (in which you can even search for the string given above) *really* more complicated than tryin gto find  the right option in a GUI? 
> 
> Trust me, it isn't.
> 
> As far as I know there isn't any graphical configuration tool for apache anyway

 

You're right however a gui is nice to have an overview of options avaialble. Moreover I am trying to find out how to bind Apache to the 127.0.0.1 address which seems a bit more complicated.

----------

## ToeiRei

Look for the 'Listen' directive.

----------

## Kasumi_Ninja

 *ToeiRei wrote:*   

> Look for the 'Listen' directive.

 

Ok now I understand! You mean 

Changing in /etc/apache2 httpd.conf

```
Listen 80
```

to

```
Listen 127.0.0.1
```

or 

```
#Listen 80
```

Right?

----------

## truc

 *Aniruddha wrote:*   

> to
> 
> ```
> Listen 127.0.0.1
> ```
> ...

 Right

----------

## Kasumi_Ninja

 *truc wrote:*   

>  *Aniruddha wrote:*   to
> 
> ```
> Listen 127.0.0.1
> ```
> ...

 

Lol. That indeed is far easier than  I thought it would be! Thanks all for helping me figuring this out!

----------

## Kasumi_Ninja

I have one question left. I changed the DocumentRoot line in /etc/apache2/vhosts.d/00_default_vhost.conf

```
<IfDefine DEFAULT_VHOST>

<VirtualHost *:80>

    #

    # DocumentRoot: The directory out of which you will serve your

    # documents. By default, all requests are taken from this directory, but

    # symbolic links and aliases may be used to point to other locations.

    #

    DocumentRoot "/var/www/localhost/htdocs"
```

to

```
<IfDefine DEFAULT_VHOST>

<VirtualHost *:80>

    #

    # DocumentRoot: The directory out of which you will serve your

    # documents. By default, all requests are taken from this directory, but

    # symbolic links and aliases may be used to point to other locations.

    #

    DocumentRoot "/var/www/gtd-php-08"
```

Does that matter?

----------

## Kasumi_Ninja

 *truc wrote:*   

>  *Aniruddha wrote:*   to
> 
> ```
> Listen 127.0.0.1
> ```
> ...

 

I get this error message, which port should I specify?   :Rolling Eyes: 

```
Syntax error on line 213 of /etc/apache2/httpd.conf:

Port must be specified

```

Update

I changed the line to:

```
Listen 127.0.0.1:80
```

Is this ok?

Update 2

# netstat -lapute now gives me:

```
tcp        0      0 127.0.0.1:80            0.0.0.0:*               LISTEN      0          819146     27477/apache2
```

Also when restarting Apache I get this message:

```
# /etc/init.d/apache2 restart

 * Stopping apache2 ...

apache2: Could not determine the server's fully qualified domain name, using 127.0.0.1 for ServerName                                                     [ ok ]

 * Starting apache2 ...

apache2: Could not determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
```

What does that mean?

----------

## ToeiRei

now relax and read the error message again.

Then think of it again.

If you got that you can either ignore it or set 'ServerName' in the default vhost config to your hostname

Rei

----------

## Asceta

 *Aniruddha wrote:*   

> I have one question left. I changed the DocumentRoot line in /etc/apache2/vhosts.d/00_default_vhost.conf
> 
> ```
> <IfDefine DEFAULT_VHOST>
> 
> ...

 

No, but you should search the directory directive for /var/www/localhost/htdocs and change it to /var/www/gtd-php-08 as well.

Regards

----------

## Kasumi_Ninja

 *ToeiRei wrote:*   

> now relax and read the error message again.
> 
> Then think of it again.
> 
> If you got that you can either ignore it or set 'ServerName' in the default vhost config to your hostname
> ...

 

Thanks for pointing that out. About the other question is it ok that I use port 80? Or is another port preferred?

```
Listen 127.0.0.1:80
```

If I am not mistaken # netstat -lapute shows that apache2 is running only locally right?

```
tcp        0      0 gentoo.home:http        *:*                     LISTEN      root       21575      9366/apache2

```

----------

## truc

use nestat -laputen instead and you'll have the answer

----------

## Rob1n

 *Aniruddha wrote:*   

> About the other question is it ok that I use port 80? Or is another port preferred?
> 
> ```
> Listen 127.0.0.1:80
> ```
> ...

 

Port 80 is the default for HTTP so will be fine.

 *Quote:*   

> 
> 
> If I am not mistaken # netstat -lapute shows that apache2 is running only locally right?
> 
> ```
> ...

 

Well, this one's not so clear but the one you posted earlier does show that apache is only listening on localhost (so can't be connected to from elsewehere).

----------

## Kasumi_Ninja

 *Rob1n wrote:*   

>  *Aniruddha wrote:*   If I am not mistaken # netstat -lapute shows that apache2 is running only locally right?
> 
> ```
> tcp        0      0 gentoo.home:http        *:*                     LISTEN      root       21575      9366/apache2
> 
> ...

 

This is where the aforementioned # netstat -laputen comes in handy   :Smile: 

```
tcp        0      0 127.0.0.1:80            0.0.0.0:*               LISTEN      0          21575      9366/apache2
```

It seems that everything is ok.

----------

