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 ...XAMPPapacheconfextra
:
<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:WindowsSystem32driversetc
:
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.
2
Answers
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 inD:IDEsXAMPPapacheconfextra
.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 codeChange
Document Root
andDirectory
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 intohttpd-ssl.conf
file. If you got like... Port 80
add yourl virtualhost configs intohttpd-vhosts.conf
first you should arrange directories on httpd.conf
example:
and then arrange vhosts.conf like this
example :