Add Virtual Host for Localhost Ampps

前端 未结 3 1535
时光取名叫无心
时光取名叫无心 2021-01-27 12:49
  
    DocumentRoot \"C:/Program Files (x86)/Ampps/www\"
    ServerName localhost


  
    DocumentRo         


        
相关标签:
3条回答
  • 2021-01-27 12:52

    Have you tried with <VirtualHOst proj.local:80>? You should be able to find more examples here: http://httpd.apache.org/docs/2.2/vhosts/examples.html

    0 讨论(0)
  • 2021-01-27 13:01
    <VirtualHost 127.0.0.1:80>
    DocumentRoot "C:\xampp\htdocs"
    ServerName xampp.local
    ServerAlias www.xampp.local
    </VirtualHost>
    

    after adding it at the end of your httpd-vhosts.conf file restart your xampp and also add following lines to your hosts file available at C:\Windows\System32\Drivers\etc\hosts

    127.0.0.1      xampp.local
    
    0 讨论(0)
  • 2021-01-27 13:09

    As you said you are using AMPPS, I suppose you are adding this instructions to the folder:

    AMPPS/apache/conf/extra/httpd-vhosts.conf
    

    With that in mind I'll show an example of configuration.

    <VirtualHost project.local:80>
        <Directory "/Users/you/yourproject">
            Options FollowSymLinks Indexes
            AllowOverride All
            Order deny,allow
            allow from All
        </Directory>
        ServerName project.local
        ServerAlias project.local 127.0.0.1
        ScriptAlias /cgi-bin/ "/Users/you/yourproject/cgi-bin/"
        DocumentRoot "/Users/you/yourproject"
        ErrorLog "/Applications/AMPPS/apache/logs/project.error_log"
        CustomLog "/Applications/AMPPS/apache/logs/project.access.log" combined
    </VirtualHost>
    

    All right. After doing that, you will have to add to your hosts file. In Mac they are located in:

    /etc/hosts
    

    If you are using a Windows environment you will find the hosts file in:

    c:\windows\system32\drivers\etc\hosts
    

    Attention: You may have to type your password again or allow the program you're using to edit the file to use administrator privileges.

    Then you'll add your local IP and the hostname to it. Just like this:

    127.0.0.1      project.local
    

    If you don't add the URL to the hosts file that won't work.

    0 讨论(0)
提交回复
热议问题