skip to Main Content

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


  1. Chosen as BEST ANSWER

    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: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 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


  2. 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>
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search