I am trying to set up the virtual host for my app written in Codeignitor. Here is what I am doing
In my config.php file in codeignitor I do this
$config['base_url'] = 'http://app.com';
Then in my hosts file I do this
127.0.0.1 www.myapp.com
127.0.0.1 api.myapp.com
127.0.0.1 files.myapp.com
Then in my vhosts file I add this code
NameVirtualHost 127.0.0.1
<VirtualHost 127.0.0.1>
DocumentRoot "C:\xampp\htdocs\
ServerName localhost
</VirtualHost>
<VirtualHost www.myapp>
DocumentRoot "C:\xampp\htdocs\myApp"
ServerName myapp.com
ServerAlias myapp.com
<Directory "C:\xampp\htdocs\myApp">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
When I type http://www.myapp.com/ in my browser it gives me Access forbidden! error. Can I get some headers?
Now it works. I a had to add .com in the VH files.
Related
I'm attempting to configure a virtualhost to a subdirectory into /opt/lampp/htdocs. This is the httpd-vhost.conf file:
NameVirtualHost *:80
<VirtualHost localhost:80>
ServerAdmin localhost
DocumentRoot /opt/lampp/htdocs
ServerName localhost
<Directory /opt/lampp/htdocs>
Options All
AllowOverride All
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *:80>
# This first-listed virtual host is also the default for *:80
ServerName www.localhostwmf.com
ServerAlias localhostwmf.com
DocumentRoot /opt/lampp/htdocs/wmf
DirectoryIndex index.php
<Directory /opt/lampp/htdocs/wmf>
Options All
AllowOverride All
Allow from all
</Directory>
</VirtualHost>
I uncommented this line in httpd.conf:
Include etc/extra/httpd-vhosts.conf
And i added the following line in etc/hosts:
127.0.0.1 www.localhostwmf.com
But it redirects me always in the dashboard page of xampp! Thank you in advance for answers!
I solved this morning the problem, i hope that this solution will be useful for another one:
I modified my httpd-vhosts.conf file as follows:
NameVirtualHost *:80
<VirtualHost localhost:80>
ServerAdmin localhost
DocumentRoot /opt/lampp/htdocs/wmf
ServerName localhost
<Directory /opt/lampp/htdocs>
Options All
AllowOverride All
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *:80>
# This first-listed virtual host is also the default for *:80
ServerName www.localhostwmf.com
ServerAlias localhostwmf.com
DocumentRoot /opt/lampp/htdocs/wmf
DirectoryIndex index.php
<Directory /opt/lampp/htdocs/wmf>
Options All
AllowOverride All
Allow from all
</Directory>
</VirtualHost>
(i added wmf folder in localhost document root)
I have created a virtual host for a new application in wamp.
In my httpd.conf
# Virtual hosts
Include conf/extra/httpd-vhosts.conf //<--- Removed #
In my httpd.vhosts.conf I added a new host
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot "C:/wamp/www/myapp"
ServerName myapp.local
ServerAlias 127.0.0.1
SetEnv APPLICATION_ENV "development"
<Directory "C:/wamp/www/myapp/">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
</Directory>
</VirtualHost>
The virtual host is working fine. But the problem is my other apps that run without virtual hosts are not working.
When i open http://localhost/fistapp/ it shows
Forbidden 403
You don't have permission to access / on this server.
Once you create a Virtual Host definition Apache basically ignores the localhost domain defined in the httpd.conf file, so you have to also define locahost in the httpd-vhosts.conf file as well. So your httpd-vhosts.conf file should look like this :
<VirtualHost *:80>
ServerName localhost
DocumentRoot c:/wamp/www
<Directory "c:/wamp/www/">
Options +Indexes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>
# made some amendments to this VH as well
<VirtualHost *:80>
DocumentRoot "C:/wamp/www/myapp"
ServerName myapp.local
# not sure why this is here ServerAlias 127.0.0.1
ServerAlias www.myapp.local
SetEnv APPLICATION_ENV "development"
<Directory "C:/wamp/www/myapp">
Options +Indexes +FollowSymLinks +MultiViews
AllowOverride all
Require local
</Directory>
</VirtualHost>
Dont forget to amend the C:\windows\system32\drivers\etc\hosts file to add your new domain like this
127.0.0.1 localhost
::1 localhost
127.0.0.1 myapp.local
::1 myapp.local
I tried to create a virtualhost to access to my local website using wampserver, but i get a 403 Forbidden when i'm trying to access to the webpage :
I put the following line in my browser :
mywebsite/html/start.html
Here is the content of my httpd-vhost file :
<VirtualHost *:80>
ServerName mywebsite
DocumentRoot "D:\pathToMySite"
<Directory "D:\pathToMySite">
AllowOverride All
Allow from all
Require all granted
</Directory>
</VirtualHost>
I put the alias also in my host file :
127.0.0.1 mywebsite
I will share my httpd.conf for AMPPS under windows(should be very similar to wamp)
<VirtualHost 127.0.0.1:80>
<Directory "{$path}/www">
Options FollowSymLinks Indexes
AllowOverride All
Order deny,allow
allow from All
</Directory>
ServerName localhost
ServerAlias localhost 127.0.0.1
ScriptAlias /cgi-bin/ "{$path}/www/cgi-bin/"
DocumentRoot "{$path}/www"
ErrorLog "{$path}/apache/logs/error.log"
CustomLog "{$path}/apache/logs/access.log" combined
</VirtualHost>
<VirtualHost *:80>
<Directory "F:/www">
Options FollowSymLinks Indexes
AllowOverride All
Order deny,allow
allow from All
</Directory>
DocumentRoot "F:/www"
ServerName site1.com
</VirtualHost>
I also use host file for local DNS
127.0.0.1 site1.com
hope that helps !
I would like Apache to serve documents from c:/Apache24/htdocs and d:/www resp on my Windows local machine. In httpd-vhosts.conf I'm trying:
<VirtualHost *:80>
DocumentRoot "c:/Apache24/htdocs"
ServerName test.localhost
Options Indexes FollowSymLinks
<Directory "D:/www">
AllowOverride All
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
</Directory>
</VirtualHost>
and in hosts
127.0.0.1 test.localhost
but browsing to http://test.localhost results in a list of directories under C:/htdocs being displayed?
Am I getting any closer with this:
Alias c:/Apache24/htdocs D:/www
<Directory c:/Apache24/htdocs>
Require all granted
</Directory>
If so, where do I add it? N.B. I want to store and serve web documents from D:/ since C:/ is getting rather full now.
check you have row: NameVirtualHost *:80 before your virtual host. That should usually be there already, but check it.
Change your host to point just into one folder like:
<VirtualHost *:80>
DocumentRoot "D:/www"
ServerName localserver
Options Indexes FollowSymLinks
<Directory "D:/www">
AllowOverride All
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
</Directory>
</VirtualHost>
Create symbolic link from your c:/Apache24/htdocs to for example D:/www/apache folder.
Then you can access to your c:/Apache24/htdocs folder from url:
localserver/apache
Read more about symlinks:
http://en.wikipedia.org/wiki/NTFS_symbolic_link
Another option is to create two urls (domains) and virtualhosts like (add this after above):
<VirtualHost *:80>
DocumentRoot "c:/Apache24/htdocs"
ServerName other.localserver
Options Indexes FollowSymLinks
<Directory "c:/Apache24/htdocs">
AllowOverride All
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
</Directory>
</VirtualHost>
and in your hosts:
127.0.0.1 localserver other.localserver
On Windows 7 with WAMP installed on C:\Apache24 and serving documents out of C:\Apache24\htdocs you may want to serve documents from the D drive instead, since C is getting full. Go to: C:\Apache24\conf\extra\httpd-vhosts.conf
<VirtualHost *:80>
DocumentRoot "D:/www/apache/site1"
ServerName site1.dev
<Directory "D:/www/apache/site1">
Options Indexes MultiViews
AllowOverride None
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "D:/www/apache/site2"
ServerName site2.dev
<Directory "D:/www/apache/site2">
Options Indexes MultiViews
AllowOverride None
Require all granted
</Directory>
</VirtualHost>
And edit: C:\Windows\System32\drivers\etc\hosts
127.0.0.1 site1.dev
127.0.0.1 site2.dev
You should now be able to serve (locally) you're web documents from D:\www\apache with no need for sym links.
I have installed zend framework to my wamp but muiple vitual host not working in my wamp
each time i opened for zend host my wamp home page get displayed
I have included the following code in httpd.conf file
NameVirtualHost 127.0.0.1
<VirtualHost 127.0.0.1 >
DocumentRoot "C:/zendy/public"
ServerName zendy
<Directory "C:/zendy/public">
AllowOverride Autconfig FileInfo Indexes Limited options
Order Deny,Allow
Allow from 127.0.0.1
</Directory>
</VirtualHost>
I have also bind the address in my hosts file
127.0.0.1 zendy
plz help...
Try adding the port in the virtualhost settings and restart your webserver, then it should work.
Later edit: Windows has the other slash if I recall ...
NameVirtualHost 127.0.0.1
<VirtualHost 127.0.0.1:80>
DocumentRoot "C:\zendy\public"
ServerName zendy
<Directory "C:\zendy\public">
AllowOverride Autconfig FileInfo Indexes Limited options
Order Deny,Allow
Allow from 127.0.0.1
</Directory>
</VirtualHost>