Reputation: 6810
I'm trying to set up a virtualHost for mampstack (NOT MAMP). This is what I've done so far:
In my httpd.conf file I've checked
Listen 8080
This is correct (I'm listening to the port 8080, NOT 80).
Then I've uncommented: Include conf/extra/httpd-vhosts.conf
in my httpd.conf
file
In my hosts file I have added the following: 127.0.0.1 mext-pst.local
.
In httpd-vhosts.conf
I've added:
NameVirtualHost *:8080
<VirtualHost *:8080>
DocumentRoot "/Applications/mampstack-5.4.20-0/apache2/htdocs"
ServerName 127.0.0.1
ServerAlias localhost
SetEnv APPLICATION_ENV development
SetEnv APPLICATION_DOMAIN localhost
</VirtualHost>
<VirtualHost *:8080>
DocumentRoot "/Applications/mampstack-5.4.20-0/apache2/htdocs/mext-pst-dashboard/web"
ServerName mext-pst.local
ServerAlias mext-pst.local
SetEnv APPLICATION_ENV development
SetEnv APPLICATION_DOMAIN mext-pst.local
RewriteEngine on
RewriteCond %{SERVER_PORT} ^80$
RewriteRule ^ http://%{HTTP_HOST}:8080%{REQUEST_URI} [P]
</VirtualHost>
Now when I go to http://mext-pst.local/
I just get an error of my browser that he can't connect with the page ... .
When I go to http://mext-pst.local:8080/
I get the following error:
Proxy Error
The proxy server received an invalid response from an upstream server.
The proxy server could not handle the request GET /index.php.
Reason: DNS lookup failure for: mext-pst.local:8080
When I go to http://mext-pst.local:8080/index.php
it works ...
Upvotes: 5
Views: 1290
Reputation: 111
Since you are not listening on port 80
, getting an error when you go to the URL without a port seems to be the correct result, right?
And when you go to port 8080
you are getting a Proxy Error
. Are you sure there is no other software running on port 8080
or your browser doesn't have a proxy entered? Apache
would not be giving a Proxy Error
. I suspect this error is coming from somewhere else.
About your configuration, I am not exactly sure what it is that you are trying to achieve but, if you are trying to get some documents served when you go to localhost:8080
and another set of documents served when you go to mext-pst.local:8080
than you are almost there, NameVirtualHost *:8080
is correct and needs to be there, remove redirect lines as you don't need them (unless my assumption is wrong).
Upvotes: 0
Reputation: 1270
Change 8080 to 80 its the default. But if you want your site to run on 8080, then you have to use it. Another solution might be to rewrite the url, that is when your server gets the url, it rewrites it with port number (8080).
First of all change Listen 8080 to Listen 80, as you want your application to be accessible only with http. In your http-vhost.conf file put following lines (of course after removing previous changes). In the following configuration yourDefaultHttpFolder means the default http folder. You might have changed it. So correct it depending on your system.
<VirtualHost *:80>
DocumentRoot "/Applications/mampstack-5.4.20-0/apache2/htdocs/yourDefaultHttpFolder"
ServerName 127.0.0.1
ServerAlias localhost
SetEnv APPLICATION_ENV development
SetEnv APPLICATION_DOMAIN localhost
<Directory /Applications/mampstack-5.4.20-0/apache2/htdocs/yourDefaultHttpFolder>
RewriteEngine on
RewriteCond %{SERVER_PORT} ^80$
RewriteRule ^ http://%{HTTP_HOST}:8080%{REQUEST_URI} [P]
</Directory>
</VirtualHost>
<VirtualHost *:8080>
DocumentRoot "/Applications/mampstack-5.4.20-0/apache2/htdocs/mext-pst-dashboard/web"
ServerName mext-pst.local
ServerAlias mext-pst.local
SetEnv APPLICATION_ENV development
SetEnv APPLICATION_DOMAIN mext-pst.local
</VirtualHost>
This configuration is working on my server, when ever I try to access using 80 it rewrites the URL to my 8080 port and I see the content of that folder, not the the default index page.
Upvotes: 2
Reputation: 93
You've got to change the port to *:80 and also if you're going to use a different name then the servername make sure to take up NameVirtualHost *:80 in your httpd.conf.
Upvotes: 2