# change apache default port

## cghislai

Hi all

I want to run apache on port 81 (cause my router use the port 80 for his web interface)

I set 'Listen 81' in httpd.conf and restarted apache. But when im trying to go to 127.0.0.1:81, i get an 404 Not found, with a footnote saying "Apache Server at 127.0.0.1 Port 81". When i try 127.0.0.1:80, browser change adress to http://127.0.0.1/ and my page is showed.

Where is the matter?

thanks

Charly

----------

## hanj

 *Quote:*   

> I want to run apache on port 81 (cause my router use the port 80 for his web interface)
> 
> I set 'Listen 81' in httpd.conf and restarted apache. But when im trying to go to 127.0.0.1:81, i get an 404 Not found, with a footnote saying "Apache Server at 127.0.0.1 Port 81". When i try 127.0.0.1:80, browser change adress to http://127.0.0.1/ and my page is showed. 

 

Looks like you successfully changed the default port to 81.. and got apache to listen on it. You need to change your vhost and NameVirtualHost settings.

Are you using 00_default_vhost.conf?

If so... change this:

```
NameVirtualHost *:80
```

to this:

```
NameVirtualHost *:81
```

Also you need to change this:

```
<VirtualHost *:80>
```

to this:

```
<VirtualHost *:81>
```

Don't forget to restart apache.

Hope this helps.

hanji

----------

## cghislai

thanks for your reply

In fact, i had to add a line in my httpd.conf saying DocumentRoot /var/www/localhost/htdocs.

For some obscure reason, when i change the port, apache looks for these file in /usr/htdocs.... And the httpd.conf file did not provide a DocumentRoot option by default. Maybe i should submit a bug...

----------

## mordredP

 *cghislai wrote:*   

> Hi all
> 
> I want to run apache on port 81 (cause my router use the port 80 for his web interface)
> 
> I set 'Listen 81' in httpd.conf and restarted apache. But when im trying to go to 127.0.0.1:81, i get an 404 Not found, with a footnote saying "Apache Server at 127.0.0.1 Port 81". When i try 127.0.0.1:80, browser change adress to http://127.0.0.1/ and my page is showed.
> ...

 

no need to do that if you setup port forwarding correctly.. actually if your router displays his web interface while you try to access your web server just try to access your server from outside the LAN.. it should work fine..

----------

## cghislai

yes, it works fine  :Smile: 

i didnt know that, thanks

----------

## guldan

 *cghislai wrote:*   

> thanks for your reply
> 
> In fact, i had to add a line in my httpd.conf saying DocumentRoot /var/www/localhost/htdocs.
> 
> For some obscure reason, when i change the port, apache looks for these file in /usr/htdocs.... And the httpd.conf file did not provide a DocumentRoot option by default. Maybe i should submit a bug...

 

many thanks for that hint. I was fighting with exactlythe same problem (for a stll unknown reason, my port forwardign for port 80 will not work so for testing I wanted to use a different one).

Is there a way to check what config settings like "documentRoot,..." apache uses while running ? Or how did you foudn out that apache used a wrong DocumentRoot while running on a different port ? The apache config files on gentoo are too my understand a little bit confusing as some setting are missing in the httpd.conf file ?

----------

