text Apache的虚拟主机

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了text Apache的虚拟主机相关的知识,希望对你有一定的参考价值。

1. Allow the usage of custom virtual hosts. Open the httpd.conf

  sudo gedit /opt/lampp/etc/httpd.conf
 
2. Uncomment the line bellow

  # Virtual hosts
  Include etc/extra/httpd-vhosts.conf
  
3. Create a custom domain in the hosts file of your system

  sudo gedit /etc/hosts
  
  127.0.0.1	localhost
  127.0.0.5	myawesomeproject
  .....
  
4. Create your first virtual host

  sudo gedit /opt/lampp/etc/extra/httpd-vhosts.conf

  <VirtualHost 127.0.0.5:80>
    DocumentRoot "/opt/lampp/htdocs/my-first-project"
    DirectoryIndex index.php

    <Directory "/opt/lampp/htdocs/my-first-project">
    Options All
    AllowOverride All
    Require all granted
    </Directory>
  </VirtualHost>
  
 5. Test your virtual host
 
   To test it, in the folder /opt/lampp/htdocs/my-first-project, create a simple PHP file (index.php) 
   that will contain the following PHP code:

    <?php
    echo "Hello world!";
    ?>
    
 6. Restart 
 
    sudo /opt/lampp/lampp restart
    
 7. Check it out!
 
    http://myawesomeproject/ 

以上是关于text Apache的虚拟主机的主要内容,如果未能解决你的问题,请参考以下文章

text 创建apache2虚拟主机的脚本#bash #linux #apache #wsl #host #vhost

text 如何在Ubuntu 14.04上设置Apache虚拟主机

Apache配置基于域名的虚拟主机

Weblogic+apache多虚拟主机

apache怎么配置localhost的虚拟主机

Apache(Apache的虚拟主机)