I have an Apache server that handles two virtual host on port 8080, one is private (localhost) and a second one is public (internet). The private virtual host works fine but the public keeps redirecting all public requests to the localhost and I'm not sure what I'm doing wrong. Please help! Below is the httpd-vhost.conf file:
# Virtual Hosts
<VirtualHost *:8080>
ServerName localhost
DocumentRoot c:/wamp64/www
<Directory "c:/wamp64/www/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>
<VirtualHost *:8080>
ServerName mydomain.com
DocumentRoot c:/wamp64/www/App
<Directory "c:/wamp64/www/App/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require all granted
</Directory>
DirectoryIndex index.html index.php
</VirtualHost>
#
Also, this is running WAMP / Magento on Windows Server 2012 and hosted in Azure. Thanks a lot!
Please find the comments on virtual host settings.
#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any <VirtualHost> block.
#
Refer this
I found that the virtual host was configured correctly and the re-directing problem was in MySQL Magento Db, which was pointing to the localhost:8080. I changed core_config_data under web/unsecure/base_url and web/secure/base_url to my public domain and it worked fine. I posted this answer in case someone else lands here with a similar problem. Thanks
Related
I have a windows IIS server 2016 version 10 and i have a production server running in a virtualenv with wampp server running in https (ssl enabled)
I have a folder mainFolder in which my website is running https://mywebsite.com and i have a sub folder Mobile inside main MainFolder
I want to run a sub-domain using Mobile Folder http://mobile.website.com
After adding subdomain in go daddy my sub-domain is active and i made changes in C:\wamp\bin\apache\Apache2.2.21\conf\extra\httpd-vhosts.conf
<VirtualHost *:80>
ServerName localhost
DocumentRoot c:/wamp64/www
<Directory "c:/wamp64/www/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>
#
<VirtualHost *:80>
ServerName mobile.localhost.com
ServerAlias mobile.localhost.com
VirtualDocumentRoot c:/wamp64/www/website/Mobile
<directory "c:/wamp64/www/webiste/Mobile/">
Options Indexes FollowSymLinks
AllowOverride all
Order Deny,Allow
Deny from all
Allow from all
</directory>
</VirtualHost>
after seeing this tutorial https://web.archive.org/web/20180323082634/http://www.axertion.com/tutorials/2012/03/how-to-setup-local-subdomains-using-wampserver/
Now my subdomain is able to run in https but it access the main directory and i want to run my sub domain in http .
when i open my sub domian in http it says file not found (404 status code)
Any help would be appreciated
I have just downloaded the latest version of XAMPP with PHP version 7.2.4. I have made a very simple PHP validation for a HTML form and when I press submit it comes up with the following:
Access forbidden!
You don't have permission to access the requested object. It is either read-protected or not readable by the server.
If you think this is a server error, please contact the webmaster.
Error 403
localhost
Apache/2.4.33 (Win32) OpenSSL/1.1.0g PHP/7.2.4
I'd don't know what the problem is as I have tried changing Require none to Require all granted.
Please Help!
I have experienced this problem and found out that localhost link is not configured in
httpd_vhosts.conf.
So I added this line at the bottom part of httpd_vhosts.conf
<VirtualHost *:80>
DocumentRoot "E:/xampp/htdocs"
ServerName localhost
</VirtualHost>
Well, probably this must be happening because the localhost link is not configured in your xamp vhost, try to look for the vhosts configuration file and add the same one there. Just add this block of code making the appropriate path changes until your repository so that you can access the localhost:
# Virtual Hosts
#
<VirtualHost *:80>
ServerName localhost
ServerAlias localhost
DocumentRoot "${INSTALL_DIR}/www"
<Directory "${INSTALL_DIR}/www/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster#hcode.com.br
DocumentRoot "C:\ecommerce"
ServerName www.hcodecommerce.com.br
ErrorLog "logs/dummy-host2.example.com-error.log"
CustomLog "logs/dummy-host2.example.com-access.log" common
<Directory "C:\ecommerce">
Require all granted
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]
</Directory>
</VirtualHost>
By default in httpd.conf your entire system directory "/" is secured and not allowed access
in httpd.conf:
# Deny access to the entirety of your server's filesystem. You must
# explicitly permit access to web content directories in other
# <Directory> blocks below.
#
<Directory />
AllowOverride none
Require all denied
</Directory>
Add the below additional under the above
<Directory /home>
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
Change /home to your hosted installation public directory - e.g. /projects or /devsite.local etc...
For more info on Apache see here: https://httpd.apache.org/docs/current/mod/core.html#directory
The 'Options' are typical .htaccess directives - change as needed
The 'AllowOverride All' gives access to the /home folder and everything under it
The 'Require local' makes sure only localhost / 127.0.0.1 has access to folder and files under /home
Hope this helps :D
I have installed wamp on C:/wamp64/ folder
I have created a virtual host called sampleapp.dev. But when I access it It says "This site can’t be reached".
my httpd-vhosts file
# Virtual Hosts
#
<VirtualHost *:80>
ServerName localhost
ServerAlias localhost
DocumentRoot "${INSTALL_DIR}/www"
<Directory "${INSTALL_DIR}/www/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName sampleapp.dev
DocumentRoot "C:/wamp64/www/sampleapp/public"
</VirtualHost>
my hosts file
127.0.0.1 localhost
::1 localhost
127.0.0.1 sampleapp.dev
::1 sampleapp.dev
What I am doing wrong?
<VirtualHost *:80>
ServerName sampleapp.dev
ServerAlias sampleapp.dev
DocumentRoot "C:/wamp64/www/sampleapp/public"
</VirtualHost>
<Directory "C:/wamp64/www/sampleapp/public">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
</Directory>
my setting
it's working
As you can see from the Definition of the localhost Virtual Host, you need more than just the name of the VH defined, you also have to tell Apache who is allowed to access your new Virtual Host.
The <Directory...> block tell Apache this, specifically the Require local piece, but the other parameters also tell Apache useful information about whats allowed to be done in this new VH.
Try the below amendment.
I have changed sampleapp.dev to sampleapp.test. This is because if you ever use the Chrome browser, the .dev tLD does some odd things now. Google bought the .dev tLD and Chrome now will try and enforce the use of SSL (https) on all .dev tLD's. Simple solution it to just use something else like .local or .test
# Virtual Hosts
#
<VirtualHost *:80>
ServerName localhost
ServerAlias localhost
DocumentRoot "${INSTALL_DIR}/www"
<Directory "${INSTALL_DIR}/www/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName sampleapp.test
ServerAlias www.sampleapp.test
DocumentRoot "${INSTALL_DIR}/www/sampleapp/public"
<Directory "${INSTALL_DIR}/www/sampleapp/public/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>
As I use .test instead of .dev yo will also have to change your HOSTS file accordingly, and then reboot or refresh your dnscache like this from a command window started using "Run as Administrator".
Also avoid using Require all granted unless you actually want to allow the universe into your server. If your router blocks port 80, which they do by default nothing can actually get into your WAMPServer. But the second you decide you want to show a friend your nice new site and Port Forward port 80 to your WAMPServer PC, all sites that use Require all granted will become visible. Best to make that change only on the site you really want to be visible from the internet.
>net stop dnscache
>net start dnscahce
I have some virtual-host and I can access it on the PC that has the server intalled. But I have others Pc and I want to access via the domain name.
I just can access to the server configuration page changing the statement "Require local" to "Require all granted". This only allow me to access through the ip address.
<VirtualHost *:80>
ServerName localhost
DocumentRoot D:/wamp64/www
<Directory "D:/wamp64/www/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName laravel5.1.app
DocumentRoot "d:/wamp64/www/laravel5_1/public"
<Directory "d:/wamp64/www/laravel5_1/public/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
To access the site using your domain names you must tell each of the other PC's where to find the domain name.
So you either need a local DNS Server or you edit the HOSTS file on each PC that you want to access the site from by adding something like this to the other PC's HOSTS
192.168.1.100 laravel5.1.app
Assuming your WAMPServer (Apache) is running on ip address 192.168.1.100
I'm learning Symfony right now. I created 2 Symfony projects with 2 different domains. Nevertheless, my second domain points to the first, and don't know why.
I'm following this tutorial, the famous jobeet: http://www.symfony-project.org/jobeet/1 ... rine/en/01
Notice my configurations:
My /etc/apache2/httpd.conf
ServerName localhost
#From the symfony tutorial "jobeet"
# Be sure to only have this line once in your configuration
NameVirtualHost 127.0.0.1:8080
# This is the configuration for your project
<VirtualHost 127.0.0.1:80>
ServerName www.jobeet.com.localhost
DocumentRoot "/home/lola/sfprojects/jobeet/web"
DirectoryIndex index.php
<Directory "/home/lola/sfprojects/jobeet/web">
AllowOverride All
Allow from All
</Directory>
Alias /sf /home/lola/sfprojects/jobeet/lib/vendor/symfony/data/web/sf
<Directory "/home/lola/sfprojects/jobeet/lib/vendor/symfony/data/web/sf">
AllowOverride All
Allow from All
</Directory>
</VirtualHost>
#Another symfony tutorial
NameVirtualHost 127.0.0.1:8081
<VirtualHost 127.0.0.1:80>
ServerName www.tutorial.com.localhost
DocumentRoot "/home/sfprojects/tutorial/web"
DirectoryIndex index.php
<Directory "/home/sfprojects/tutorial/web">
AllowOverride All
Allow from All
</Directory>
Alias /sf /home/lola/sfprojects/tutorial/lib/vendor/symfony/data/web/sf
<Directory "/home/lola/sfprojects/tutorial/lib/vendor/symfony/data/web/sf">
AllowOverride All
Allow from All
</Directory>
</VirtualHost>
Notice that I'm listening to 8081 port in the tutorial domain. I tried the permutation of VirtualHost 127.0.0.1:80 and VirtualHost 127.0.0.1:81. Neither worked. (really don't know which use)
My /etc/hosts:
#From the symfony tutorial
127.0.0.1 www.jobeet.com.localhost
#From ANOTHER symfony tutorial
127.0.0.1 www.tutorial.com.localhost
After that I restarted Apache.
Now, when I do:
http://www.jobeet.com.localhost/frontend_dev.php/ I go to my Jobeet tutorial things, BUT when I do http://www.tutorial.com.localhost/frontend_dev.php/ I ALSO go to the Jobeet page. I should go to the one containing the tutorial part.
Why is not working??!
Well:
In /etc/apache2/httpd.conf is enough with:
NameVirtualHost 127.0.0.1:80
I repeated this command when creating the other ServeName (tutorial). Maybe that was the conflict. I left all in port 80. Now it resolve right.
So, this is the final /etc/apache2/httpd.conf:
ServerName localhost
NameVirtualHost 127.0.0.1:80
# This is the configuration for your project
<VirtualHost 127.0.0.1:80>
ServerName www.jobeet.com.localhost
DocumentRoot "/home/lola/sfprojects/jobeet/web"
DirectoryIndex index.php
<Directory "/home/lola/sfprojects/jobeet/web">
AllowOverride All
Allow from All
</Directory>
Alias /sf /home/lola/sfprojects/jobeet/lib/vendor/symfony/data/web/sf
<Directory "/home/lola/sfprojects/jobeet/lib/vendor/symfony/data/web/sf">
AllowOverride All
Allow from All
</Directory>
</VirtualHost>
#Another symfony tutorial
# DO NOT REPEAT NameVirtualHost 127.0.0.1:80 --------> ****HERE: do not repeat this****
<VirtualHost 127.0.0.1:80>
ServerName www.tutorial.com.localhost
DocumentRoot "/home/sfprojects/tutorial/web"
DirectoryIndex index.php
<Directory "/home/sfprojects/tutorial/web">
AllowOverride All
Allow from All
</Directory>
Alias /sf /home/lola/sfprojects/tutorial/lib/vendor/symfony/data/web/sf
<Directory "/home/lola/sfprojects/tutorial/lib/vendor/symfony/data/web/sf">
AllowOverride All
Allow from All
</Directory>
</VirtualHost>
The /etc/hosts (or in /etc/apache2/sites-avaiable for debian) is the same.
I can access to www.jobeet.com.localhost and www.tutorial.com.localhost
Sorry, it was my misconfiguration.
A common mistake is to have disabled the virtual host module for apache, for enable it try: sudo a2enmod virtualhost
put your vhost conf in /etc/apache2/sites-available/name-file-with-vhost-conf
all virtual host must be enabled, with sudo a2ensite name-file-with-vhost-conf
apache2 must be reloaded sudo service apache2 reload
you can try this github/rokemaster/virtual_hosts is all steps in one script