Apache virtual host without domain name

后端 未结 3 615
青春惊慌失措
青春惊慌失措 2021-02-01 06:43

I have a VPS with apache2 installed and I would like to access some PHP projects without a domain name just with the IP address. For example:

http://162.243.93.2         


        
3条回答
  •  北海茫月
    2021-02-01 07:36

    " http://162.243.93.216/info.php then /var/www/html/info.php is opened "
    

    I am assuming this already works (If not, uncomment the ServerAlias line shown in the conf below)

    You now want to map

    http://162.243.93.216/projecta/ to /var/www/projecta
    http://162.243.93.216/projectb/ to /var/www/projectb

    For this you need to use the Apache Alias directive.

    Update your 000-default.conf file to:

    
        # ServerAlias 162.243.93.216
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html
    
        Alias /projecta /var/www/projecta
        Alias /projectb /var/www/projectb
    
        
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all
         
    
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
    
    

提交回复
热议问题