Setting Up Virtual hosts for XAMPP on windows - windows-xp

XAMPP for Windows 1.8.2 PHP 5.4,
Operating System : windows xp
I am using username and passowrd on XAMPP
c:\windows\system32\drivers\etc\hosts
127.0.0.1 hindustans.local
127.0.0.1 read.local
E:\My Projects\wesites\read
index.html
httpd-vhosts.conf
<Directory "E:/My Projects/wesites/read">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "E:/My Projects/wesites/read"
ServerName read
Options +Indexes
</VirtualHost>
read.local works fine with c:\xampp\htdocs
But
read.local doesn't work with E:\My Projects\wesites\read\index.html
I brief want to run my project from E:\My Projects\wesites\read

You need match the ServerName to the address you have in hosts and give it permission
<VirtualHost *:80>
DocumentRoot "E:/My Projects/wesites/read"
ServerName read.local
<Directory "E:/My Projects/wesites/read" >
Options Indexes FollowSymLinks Includes ExecCGI
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
then try to access the site at read.local.
More info here

Related

Reset project directory of apache web server virtual host having let's encrypt ssl certificate installed

I have a website www.example.com that is hosted on apache2 web server in /var/www/example.com directory and the virtual host config file is
<VirtualHost *:80>
ServerAdmin admin#gmail.com
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/example.com/public
<Directory /var/www/example.com/public/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<IfModule mod_dir.c>
DirectoryIndex index.php index.pl index.cgi index.html index.xhtml >
</IfModule>
</VirtualHost>
I have installed let's encrypt certificate for this domain.
Now I have to change configuration settings and the config file should be like this:
<VirtualHost *:80>
ServerAdmin admin#gmail.com
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/example.com/dist //here is the change
<Directory /var/www/example.com/dist/> //here is the change
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<IfModule mod_dir.c>
DirectoryIndex index.php index.pl index.cgi index.html index.xhtml >
</IfModule>
</VirtualHost>
I have edited the config file and ran command certbot --apache -d example.com -d www.example.com.
Chose reinstall and renew both options and the installation was successful in both cases. But when I go to example.com then it shows 404 error.
How can I solve my problem?
HTTPS uses port 443, not port 80. Port 443 is closed. You need to add a new virtual host to handle HTTPS request
<VirtualHost *:443>
ServerName example.com
#ServerAlias www.example.com
ServerAdmin admin#gmail.com
DocumentRoot /var/www/example.com/dist
LogLevel debug ssl:info
SSLEngine on
SSLCertificateFile /path/to/yout/cert
SSLCertificateKeyFile //path/to/yout/key
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
If you check ports.conf under /etc/apache2, you will see this:
<IfModule ssl_module>
Listen 443
</IfModule>
Apache2 will open port 443 when the SSL module is enabled. So remember to run:
sudo a2dismod ssl
sudo systemctl restart apache2

zf2 virtual host loading localhost/xampp

I'm trying to get zf2 running on my xampp.
I have this vhosts.conf file
NameVirtualHost 127.0.0.1:80
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
ServerName zf2-tutorial.localhost
DocumentRoot "C:/xampp/htdocs/zf2-tutorial"
SetEnv APPLICATION_ENV "development"
<Directory "C:/xampp/htdocs/zf2-tutorial">
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
Require all granted
</Directory>
</VirtualHost>
and this host file
127.0.0.1 zf2-tutorial.localhost
Now, when I run zf2-tutorial.localhost, the browser goes to zf2-tutorial.localhost/xampp and shows xampp page.
When I run localhost it goes to localhost/xampp too.
Please help.
Try http://zf2-tutorial.localhost/public
If that works you could change the following entries in your vhosts file
DocumentRoot "C:/xampp/htdocs/zf2-tutorial/public"
<Directory "C:/xampp/htdocs/zf2-tutorial/public">

Zend Framework - don't have permission to access file in public

That is my iframe:
<iframe allowtransparency="true" class="igm" src="/flash/dewplayer-vol.xml&
amp;container=enterprise&view=default&lang=en&country=ALL&sanitize=0&
amp;v=cb90d5949f2275bc&up_CCOL=%23d1dae3&up_START=No&
amp;up_MP3=http://www.youtube-mp3.org/get?video_id=z0FERtqhwHs&
h=6a29a4973a0431d2638ba3f5a1aecfeb&r=1373776845504&up_LOOP=No&
amp;libs=analytics:core:flash&mid=55&rpctoken=-1666220716119396559"
frameborder="0" height="400" scrolling="yes" width="500"></iframe>
But when I open my page it appears:
Forbidden
You don't have permission to access /flash/dewplayer-vol.xml&container=enterprise&view=default&lang=en&country=ALL&sanitize=0&v=cb90d5949f2275bc&up_CCOL=#d1dae3&up_START=No&up_MP3=http://www.youtube-mp3.org/get on this server.
Apache/2.2.8 (Win32) PHP/5.2.6 Server at 212.43.43.254 Port 80
That is my httpd.conf file:
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot C:\AppServ\www\site\public
</VirtualHost>
<Directory "C:/AppServ/www/site/public">
Options Indexes MultiViews FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
There some several step you have to follow in web server just go throw all this
1. Find the httpd.conf file (usually you will find it in a folder called conf, config or something along those lines)
2. Inside the httpd.conf file uncomment the line LoadModule rewrite_module modules/mod_rewrite.so (remove the pound '#' sign from in front of the line)
Also find the line ClearModuleList is uncommented then find and make sure that the line AddModule mod_rewrite.c is not commented out.
And still you have more query then go to this LINK
Also
If you set up your virtual host the default way, i.e.
<VirtualHost *:80>
DocumentRoot "D:/Users/user/www/yourwebsite.dev/public"
ServerName .local
# This should be omitted in the production environment
SetEnv APPLICATION_ENV development
<Directory "D:/Users/user/www/yourwebsite.dev/public">
Options Indexes MultiViews FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
You may access the public dir, by:
http://yourwebsite.dev/
and files in public dir by:
http://yourwebsite.dev/filename.ext
It is all about DocumentRoot.
i hope this will sure help you.

How to rewrite a domain to a subfolder

I have one local server called server1 with a subdirectory sub (server1/sub/).
Now i have a dns entry which redirects server2 to server1.
I want to configure my apacher server in a way that when I open server2 in a browser I get the content from server1/sub/.
The url should not change to server1/sub/.
Is this possible with mod_rewrite?
EDIT:
I added
127.0.0.1 localhost
127.0.0.1 wiki2
127.0.0.1 wiki3
to the hosts file and
VirtualHost 127.0.0.1>
ServerName wiki2
ServerAlias 127.0.0.1
DocumentRoot c:/xampp/htdocs/wiki_angua
<Directory c:/xampp/htdocs/wiki_angua >
Allow From All
</Directory>
</VirtualHost>
<VirtualHost 127.0.0.1>
ServerName wiki3
ServerAlias 127.0.0.1
DocumentRoot c:/xampp/htdocs/weatherwax
<Directory c:/xampp/htdocs/weatherwax >
Allow From All
</Directory>
</VirtualHost>
to httpd.conf and restarted apache.
Whether I open wiki2 or wiki3 I land in ./wiki_angua.
Is there anything I forgot?
If you have a DNS entry for server2 then the Host HTTP request header will be correctly set, and all you need then is a virtual host, without the need to use mod_rewrite.
For example:
<VirtualHost *:80>
ServerName server2
DocumentRoot /path/to/server1/sub
<Directory /path/to/server1/sub>
Allow From All
</Directory>
# ... etc
</VirtualHost>
edit:
In the case you still want to use mod_rewrite you can do something like:
RewriteCond %{HTTP_HOST} ^server2$
RewriteRule ^(.+) /path/to/server1/sub/$1
This must be located in the global server configuration, and not in an existing virtual host.

How to create multiple virtual hosts with apache2 and zend

I have created zend application in /var/www/zendapp , but i have also installed mediawiki app
in /var/www/mediawiki
Now i want to access mediawiki app with http://mediawiki.local
and http://zendapp.local.
How can i do that?
I had couple of unsuccessful atempts. So far i edited /etc/hosts and added these two lines:
127.0.0.1 zendapp.local
127.0.0.1 mediawiki.local
I also created two files in /etc/apache2/sites-available/ :
zendapp
mediawiki
mediawiki :
<VirtualHost *:80>
ServerAdmin webmaster#localhost
ServerName mediawiki.local
DocumentRoot /var/www/mediawiki
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/mediawiki>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
zendapp :
ServerName zendapp.local
SetEnv APPLICATION_ENV "development"
DocumentRoot /var/www/zendapp/public
<Directory /var/www/zendapp/public>
Options Indexes FollowSymLinks Includes
AllowOverride All
Order allow,deny
Allow from all
</Directory>
But now it semes that only zendapp.local works, and if I go to :
http://mediawiki.local
it redirects me to http://zendapp.local/mediawiki/index.php/Main_Page
Do this: Separate virtualhost blocks:
Listen 80
NameVirtualHost *:80
<VirtualHost *:80>
ServerName mediawiki.local
DocumentRoot /var/www/mediawiki
#all other settings
.
.
.
</VirtualHost>
<VirtualHost *:80>
ServerName zendapp.local
DocumentRoot /var/www/zendapp/public
#all other settings
.
.
.
</VirtualHost>
Check out this blog, his answer worked!
http://justanswersnobullshit.wordpress.com/
I tried this out myself, after being frustrated by online video tutorials on how to setup multiple virtual hosts
And you do not accidentally forgot to include this site? That is, in the 'sites-enabled' directory should be by appropriate reference. Usually you should run the following commands:
sudo a2ensite host_name
sudo service apache2 reload
As a second variant, I can suppose, that 'DocumentRoot' should be ended by a slash:
DocumentRoot /var/www/zendapp/public/