Create VirtualHost on port 81

5

I have two Apaches installed for two versions of PHP (5 and 7), on port 80 and 81 respectively.

I would like to create virtualhost for port 81 of apache

The host file has this line:

Host

127.0.0.1        projeto.dev
127.0.0.1        localhost81

I created a file called project81.conf inside a folder called alias

NameVirtualHost *:81
<VirtualHost *:81> 
  DocumentRoot C:/www81/projeto/public
  ServerName projeto.dev
  <Directory "C:/www81/projeto/public">
        Require all granted
    </Directory>
</VirtualHost> 

Inside the httpd.conf file I added the line:

link

# Alias

Include conf/alias/*.conf

I restarted the service, but it did not work.

What do I have to do over?

For localhost81:81 it works

From there I would like to make this vhost available on the local network

    
asked by anonymous 07.06.2018 / 18:51

4 answers

2

In this case you use the proxies, apache continues to receive the requests on port 80, and then it forwards to another host and port, so you do not need to set directories on this type of vhost, apache only re-routes the request. would look something like this:

<VirtualHost *:80> 
  ProxyPreserveHost On
  ProxyRequests Off
  ServerName localhost81
  ServerAlias localhost81
  ProxyPass / http://localhost:81/
  ProxyPassReverse / http://localhost:81/
</VirtualHost>

In the hosts file, you continue with the localhost81 alias. I hope I have helped.

    
21.06.2018 / 13:45
2

When I configure other ports in apache, I usually put the following statement together with VirtualHost:

Listen 81
Listen 8080

<VirtualHost *:81>
    ServerName localhost
    DocumentRoot "/www/domain-81"
</VirtualHost>

<VirtualHost *:8080>
    ServerName localhost
    DocumentRoot "/www/domain-8080"
</VirtualHost>
    
21.06.2018 / 13:54
0

I think we just need to put the listen in the httpd.conf file

Listen 0.0.0.0:81

For access change the door after the (2 points)

Ex:

http://localhost:81
http://localhost:82

To run on all machines on the network use the IP of the machine where apache is configured.

Ex:

http://192.168.0.43:81
http://192.168.0.43:82
    
22.06.2018 / 22:38
0

This setup is simple, first step and put the apache to listen on the port you want, the second step and configure the vhost to point the port to a directory that you want loaded when prompted, after that and only a reload or restart the service.

First step

  

In some OS you will find this option in link , if it is in Debian you will find it in /etc/apache2/ports.conf

Listen 81 Listen 80

Second step

  

In some OS you will find this option in link , if it is in Debian you will find it in /etc/apache2/sites-available / , to enable in Debian and just run the a2ensite [config file name] command.

<VirtualHost *:81> #ServerName localhost DocumentRoot /srv/www_81 </VirtualHost> <VirtualHost *:80> #ServerName localhost DocumentRoot /srv/www_80 </VirtualHost>

Note: The ServerName is commented on because you do not need to specify a hostname, if you have a valid and public domain you can place it.

~# service apache2 reload or ~# service apache2 restart

Follow example

To facilitate, follow an example of the case informed, using the same port only changing the address (host).

Host 127.0.0.1 projeto.dev 127.0.0.1 localhost81

Create 2 files within the folder called alias, which you created.

project81.conf <VirtualHost *:80> DocumentRoot C:/www81/projeto/public ServerName localhost81 <Directory "C:/www81/projeto/public"> Require all granted </Directory> </VirtualHost>

project_dev.conf <VirtualHost *:80> DocumentRoot C:/www/projeto/public ServerName projeto.dev <Directory "C:/www/projeto/public"> Require all granted </Directory> </VirtualHost>

Inside the httpd.conf file it remains the way it has already been configured by you.

I believe it is in a suitable way for what you want and you do not need to specify the port :), it will only change the host (address) entered in the browser URL.

Att.

    
24.06.2018 / 20:18