I am trying to create virtual host with xampp but it seems my apache configuration can't read host I created.
Every single time when I'm going to moodle36.dev/moodle/install.php in my browser it's reading xampp/htdocs/moodle instead of moodle from vhosts
That's my htttpd-vhosts.conf
NameVirtualHost *80
...
<VirtualHost *:80>
DocumentRoot "C:/xampp/vhosts/moodle36.devel"
ServerName moodle36.dev
ServerAlias www.moodle36.dev
<Directory "C:/xampp/vhosts/moodle36.devel">
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
That's httpd.conf
<Directory />
AllowOverride all
Allow from all
</Directory>
DocumentRoot "C:/xampp/htdocs"
<Directory />
Options FollowSymLinks
AllowOverride All
Allow from all
</Directory>
<Directory "C:/xampp/htdocs">
...
</Directory/>
I uncomented
Include conf/extra/httpd-vhosts.conf
and System32/drivers/etc/hosts
127.0.0.1 moodle36.dev
I'm completly stuck and i would apreciatte any kind of help.
It might be because .dev is an existing top level domain.
Try .localhost or something that isn't in this list:
https://www.icann.org/resources/pages/tlds-2012-02-25-en
Related
I am trying to run site my.com locally on XAMPP's apache server. Here my configurations in httpd-vhosts.conf file in the path ...\XAMPP\apache\conf\extra:
<VirtualHost *:80>
DocumentRoot "D:/IDEs/XAMPP/htdocs"
ServerName localhost
<Directory "D:/IDEs/XAMPP/htdocs">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "D:/IDEs/Websites/my.com"
ServerName my.com
<Directory "D:/IDEs/Websites/my.com">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
Also, I remembered to add two lines in the hosts file, with is located in C:\Windows\System32\drivers\etc:
127.0.0.1 localhost
127.0.0.1 my.com
However, when I enter via link 'my.com' with enabled apache server, I've got only page with folder directories, which are in htdocs XAMPP's folder.
I have checked a lot of videos and stackoverflow questions, but nothing helped.
I would be pleased if you could help me with solving this issue.
first you should arrange directories on httpd.conf
example:
<Directory "C:/SERVER~1/web/site1">
Options Indexes FollowSymLinks MultiViews ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
<Directory "C:/SERVER~1/web/site2">
Options Indexes FollowSymLinks MultiViews ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
and then arrange vhosts.conf like this
example :
NameVirtualHost *:80
<VirtualHost *:80>
ServerName www.site1.com
DocumentRoot "C:/SERVER~1/web/site1"
</VirtualHost>
<VirtualHost *:80>
ServerName site1.com
DocumentRoot "C:/SERVER~1/web/site1"
</VirtualHost>
<VirtualHost *:80>
ServerName www.site2.com
DocumentRoot "C:/SERVER~1/web/site2"
</VirtualHost>
<VirtualHost *:80>
ServerName site2.com
DocumentRoot "C:/SERVER~1/web/site2"
</VirtualHost>
After five days-night of reading, searching, trying, I finnally fould the solution and done it in some steps:
First of all, forget about every file, and concentrate on the httpd-ssl.conf which is located in D:\IDEs\XAMPP\apache\conf\extra.
Second:
find the line "SSL Virtual Host Context" which has been commented. And below, find the line <VirtualHost _default_:443>.or simmilar. Then change it to <VirtualHost *:443>.
Third, change document root to the path of xampp's htdocs, for example, "D:/XAMPP/htdocs". Also, change ServerName from www.example.com:443 or similar, to localhost.
Here we done.
And Finally, after line </VirtualHost>, insert code
<VirtualHost *:443>
DocumentRoot "D:/IDEs/Websites/my.com"
ServerName my.com
<Directory "D:/IDEs/Websites/my.com">
Require all granted
</Directory>
</VirtualHost>
Change Document Root and Directory paths to your website location. And Servername to your server name.
RESTART APACHE
it works for me.
I also understood than some website uses SSL on localhost while the others not.
SO if you have exception like Apache/2.4.37 (Win32) OpenSSL/1.0.2p PHP/7.0.33 Server at my.com Port 443 you shold add your virtualhost configs into httpd-ssl.conf file.
If you got like ... Port 80 add yourl virtualhost configs into httpd-vhosts.conf
I am trying to set up two virtual hosts for one IP address say xxx.yy.xxx.yyy
I have my files on /var/www/html/folder1 and /var/www/html/folder2
I am adding VH like :
DocumentRoot /var/www/html/folder1
ServerName xxx.yy.xxx.yyy/folder1
AllowOverride All
DocumentRoot /var/www/html/folder12
ServerName xxx.yy.xxx.yyy/folder2
AllowOverride All
As I am new on CentOS7 Apache, can't figure out how to solve it.
I do not know if I can be helpful but I locally configure so apace to have multiple domains
<VirtualHost q4y.aurecchia.dev:80>
DocumentRoot "C:\xampp\htdocs\QuestManager\AurQuest4You\public"
ServerAdmin q4y.aurecchia.dev
<Directory "C:\xampp\htdocs\QuestManager\AurQuest4You">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
<VirtualHost csm.aurecchia.loc:80>
DocumentRoot "C:\xampp\htdocs\CSM TEST\Aur_CSM\public"
ServerAdmin csm.aurecchia.loc
<Directory "C:\xampp\htdocs\CSM TEST\Aur_CSM">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
I want to change my port number 80 to some other number of my Apache server . how it possible in ubuntu
Change your virtal host on any OS, ubuntu path is something like /etc/apache2/apache2 config or something.
#Virtual host for YOURSITE
<VirtualHost *:4343>
ServerAdmin john.doe#jd.com
ServerName webpage.dev #same as in your /etc/hosts file
DocumentRoot /var/www/yoursite
DirectoryIndex index.html
<Directory /var/www/yoursite>
Options FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog /var/log/httpd/yoursite_error.log
#CustomLog /var/log/apache2/customLog.log #for ubuntu
</VirtualHost>
Hope this will help you, you should read about apache coinfiguration...
Here's a great link https://www.digitalocean.com/community/tutorials/how-to-configure-the-apache-web-server-on-an-ubuntu-or-debian-vps
You can create a virtual host configuration file in /etc/apache2/sites-available
Example :--
<VirtualHost *:8080>
ServerAdmin webmaster#localhost
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
. . .
and you have to change Listen port on /etc/apache2/ports.conf
EX:--
Listen 8080
I have two subdomains on my VPS, i have registered the two subdomains in my DNS pointing to the same IP address.
the version installed is Server version: Apache/2.4.7 for Ubuntu 12.04.
I've enabled the sites with the a2ensite command and i have enable the module vhost_alias. restart and reloaded many times
stable.mydomain.com
<VirtualHost *:80>
ServerName stable.mydomain.com
DocumentRoot /var/www/stable/web
<Directory /var/www/stable/web>
Options Indexes FollowSymLinks Includes
AllowOverride All
order allow,deny
Allow from all
</Directory>
</VirtualHost>
beta.mydomain.com
<VirtualHost *:80>
ServerName beta.mydomain.com
DocumentRoot /var/www/beta/web
<Directory /var/www/beta/web>
Options Indexes FollowSymLinks Includes
AllowOverride All
order allow,deny
Allow from all
</Directory>
</VirtualHost>
my trouble is pointing my browser to any url always i get the same content and to add more confusion when i execute service apache2 reload in the two subdomains i get the content from beta.mydomain.com and when execute service apache2 restart in the two subdomains i get the content of stable.mydomain.com.
I have spent about 5 hours trying to fix this
update
event i try with the VirtualDocumentRoot
<Virtualhost *:80>
VirtualDocumentRoot "/var/www/%1/web"
ServerName stable.mydomain.com
ServerAlias *.mydomain.com
UseCanonicalName Off
<Directory "/var/www/*">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</Virtualhost>
with the same behavior explained before this update
Have you uncommented this line before defining the virtual hosts?
NameVirtualHost *:80
Noob Here.. I have the following folder structure on my Ubuntu Machine
/var/www/
/folder1
/folder2
Now i want to redirect my url xyz.com to folder1 & xyz.com/blog to folder2. I am using the following Vhost Config file
For xyz.com to folder1
<VirtualHost *:80>
ServerAdmin webmaster#localhost
ServerName xyz.com
ServerAlias www.xyz.com
DocumentRoot /var/www/folder1
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
.......
</VirtualHost >
And for xyz.com/blog to folder2
<VirtualHost *:80>
ServerAdmin webmaster#localhost
ServerName xyz.com/blog
ServerAlias www.xyz.com/blog
DocumentRoot /var/www/folder2
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
.......
</VirtualHost >
When i enter xyz.com in url, it serves me index file from folder1(As expected & correct) but when i enter xyz.com/blog it shows 404:Not found Error
Not Found
The requested URL /blog/ was not found on this server.
Apache/2.2.22 (Ubuntu) Server at socialcosmo.com Port 80
I have spent hours on this and still unable to figure out the problem :(
Any help would be greatly appreciated
There's no such thing as a host (domain name) with a path in it. xyz.com/blog is not a valid ServerName.
Delete the second virtual host and add an alias directive to your first one.
Alias /blog /var/www/folder2