I've a problem with my domain. Recently I've purchased mydomain.com and I've configured DNS, by the control panel of my registrar, in record A the "*" and "www" point to my server ip. (It's a home server with Win 7 Pro). The nameservers are default of my domain registrar. Now, I use AMMPS, and I've manually configured virtual host in httpd.conf & httpd-vhosts.conf, and the situation is this:
In httpd.conf:
<VirtualHost 127.0.0.1:80>
<Directory "C:/Program Files (x86)/Ampps/www/">
Options FollowSymLinks Indexes
AllowOverride All
Order deny,allow
allow from All
</Directory>
ServerName localhost
ServerAlias localhost 127.0.0.1
ScriptAlias /cgi-bin/ "C:/Program Files (x86)/Ampps/www/cgi-bin/"
DocumentRoot "C:/Program Files (x86)/Ampps/www/"
ErrorLog "C:/Program Files (x86)/Ampps/apache/logs/error.err"
CustomLog "C:/Program Files (x86)/Ampps/apache/logs/access.log" combined
</VirtualHost>
In httpd-vhosts.conf:
#DO NOT EDIT, CREATED BY AMPPS
#### mydomain.com VirtualHost ####
<VirtualHost *:80>
<Directory "C:/Program Files (x86)/Ampps/www/mydomain.com">
Options FollowSymLinks Indexes
AllowOverride All
Order deny,allow
allow from All
</Directory>
ServerName mydomain.com
ServerAlias www.mydomain.com
DocumentRoot "C:/Program Files (x86)/Ampps/www/mydomain.com"
ErrorLog "C:/Program Files (x86)/Ampps/apache/logs/mydomain.com_error.err"
CustomLog "C:/Program Files (x86)/Ampps/apache/logs/mydomain.com_access.log" combined
</VirtualHost>
####################################
Now it seems right because when i type in the browser "localhost" it shows the folder www of AMPPS, and when I type www.mydomain.com it shows content of www/mydomain.com
But, If I type in the browser mydomain.com without prefix www., it shows the courtesy page of my domain registrar.
How I can fix this?
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 view logs directory on ui for Apache Web server.
So i am trying to establish a new virtual host in httpd-vhosts.conf file and trying to give the document root to the logs folder.
<VirtualHost *:8083>
ServerAdmin tecmint#example.com
DocumentRoot C:/Program Files/Apache Software Foundation/Apache2.2/logs
ServerName localhost
ErrorLog logs/example.com-error_log
CustomLog logs/example.com-access_log common
</VirtualHost>
Also i have given NameVirtualHost *:8083 and in httpd.conf i have Listen 8083.
After restarting the server when i hit localhost:8083 it gives 404.
Can u please help me i figuring it out.
Thanks
Try with following VirtualHost configuration :
<VirtualHost *:8083>
ServerAdmin tecmint#example.com
DocumentRoot "C:/Program Files/Apache Software Foundation/Apache2.2/logs/"
ServerName localhost:8083
<Directory />
Require all granted
Options +Indexes
</Directory>
ErrorLog logs/example.com-error_log
CustomLog logs/example.com-access_log common
</VirtualHost>
Make sure you have added directory block for your docroot and you have at least read permission on it.
<Directory "C:/Program Files/Apache Software Foundation/Apache2.2/logs/">
Require all granted
Options +Indexes
</Directory>
everybody.
I have a Cent OS 6.6 server with Apache + mod_php site (site1.local). I need to configure second site (site2.local) with php_cgi. So, I created a user, gave him permissions on www-folder, configured site1 as mod_php, created a phpinfo.php. Also, I installed php-cgi,and try to configure virtual hosts, works only first site, on the second site is error:
the requested url /cgi-bin/phpinfo.php was not found onthis server.
That's my configs:
cat /etc/httpd/conf/httpd.conf
<VirtualHost *:80>
ServerAdmin webmaster#site1.local
DocumentRoot /var/www/wwwmaster/site1.local
ServerName site1.local
ServerAlias www.site1.local
ErrorLog logs/site1.local-error_log
CustomLog logs/site1.local-access_log common
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster#site2.local
DocumentRoot /var/www/wwwmaster/site2.local
ServerName site2.local
ServerAlias www.site2.local
ScriptAlias /cgi_bin/ /usr/bin/php-cgi/
Action php-cgi /cgi-bin
AddHandler php-cgi php
<Directory /usr/bin/php-cgi>
Allow from all
</Directory>
<Directory "/var/www/wwwmaster/site2.local/">
<FilesMatch "\.php">
SetHandler php-cgi
</FilesMatch>
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order Deny,Allow
Allow from all
</Directory>
ErrorLog logs/site2.local-error_log
CustomLog logs/site2.local-access_log common
</VirtualHost>
What I've done wrong and how can I fix that?
You only have to uncomment the line that says NameVirtualServer *:80 in your apache config file.
If you want virtual server for more than one port, simply put as many NameVirtualServer *:[port number] in the apache config file as you need.
I activated the userdir mod with apache2 and configure my domain to get the content of the www folder in my home.
I create a Virtualhost for the main domain which works good.
But now i would like to automatically add a subdomain for each folder in my /home/user/www/
Here is the virtualhost i code, but it redirect all the subdomains to the /home/user/www/
<VirtualHost *:80>
ServerAdmin webmaster#localhost
ServerName mysite.com
ServerAlias *.mysite.com
DocumentRoot /home/user/www/
UseCanonicalName Off
VirtualDocumentRoot /home/user/www/%1
<Directory /home/user/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog /var/log/apache2/error.mysite.log
LogLevel warn
CustomLog /var/log/apache2.mysite.log combined
</VirtualHost>`
Try changing:
VirtualDocumentRoot /home/user/www/%1
to:
VirtualDocumentRoot /home/user/www/%0
You can read more about this feature at mod_vhost_alias.
My hosts file. (Win 7 ultimate)
127.0.0.1 localhost
127.0.0.1 efmm.local
My httpd-vhosts.conf (XAMPP 1.7.3)
NameVirtualHost 127.0.0.1:80
<VirtualHost 127.0.0.1:80>
DocumentRoot "C:\xampp\htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost efmm.local>
DocumentRoot "C:\xampp\htdocs\EFMM"
ServerName efmm.local
ErrorLog "logs/efmm.localhost-error.log"
CustomLog "logs/efmm.localhost-access.log" combined
<Directory "C:\xampp\htdocs\EFMM">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Problem
When I go to efmm.local , the browser redirects to localhost/EFMM.
I also tried <VirtualHost 127.0.0.1:80> instead of <VirtualHost efmm.local>, same result.
Here's how I do it on XP (don't expect it to make any difference in 7)
First, add the virtual host's domain to your HOST (as you did)
I don't put the virtual host webroot under the main htdocs directory. I create a specific webroot next to it, which gives me the following tree:
C:\XAMPP\htdocs
C:\XAMPP\htdocs-seconddomain
C:\XAMPP\htdocs-thirddomain
etc..
So in your case, I would create c:\XAMPP\htdocs-efmm alongside C:\XAMPP\htdocs
Then:
Edit XAMPP's httpd.conf, add and define any Apache options for the new document root, i.e.:
<Directory "C:/XAMPP/htdocs-efmm">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
[any extra apache module instructions you may require]
Order allow,deny
Allow from all
</Directory>
Edit XAMPP's httpd-vhosts.conf, adding the virtual host:
<VirtualHost *:80>
ServerName efmm.local
ServerAlias www.efmm.local
DocumentRoot "C:/XAMPP/htdocs-efmm"
ErrorLog "C:/XAMPP/htdocs-efmm/error.log"
DirectoryIndex index.php index.html index.htm
</VirtualHost>
Restart XAMPP. You may browse your new virtual host now.