简体   繁体   中英

apache2 more then one website per domain

I got a viritual machine at azure and are trying make it possible to have more then one website on it. But i cant figure out how. I always just get sent to the /var/www/rajohan.no/www index.html. When i type rajohan.no i want the /var/www/rajohan.no/www index.html to show. When i type rajohan.no/test/ i want the /var/www/test.no/www to show. This is my conf files

rajohan.no.conf

<Virtual *:80>
   ServerName rajohan.no
   ServerAdmin mail@rajohan.no
   DocumentRoot /var/www/rajohan.no/www
   ErrorLog ${APACHE_LOG_DIR}/error.log
   CustomLog ${APACHE_LOG_DIR}access.log combined
</VirtualHost>


test.no.conf

<Virtual *:80>
   ServerName rajohan.no/test/
   ServerAdmin test@test.no
   DocumentRoot /var/www/test.no/www
   ErrorLog ${APACHE_LOG_DIR}/error.log
   CustomLog ${APACHE_LOG_DIR}access.log combined
</VirtualHost>
test.no.conf

<Virtual *:80>
   ServerName rajohan.no/test/
   ServerAdmin test@test.no

We can't set servername to rajohan.no/test/ . We can set multiple domain names to achieve your goal, conf like this:

example.com.conf
<VirtualHost *:80>
    ServerAdmin admin@example.com
    ServerName example.com
    ServerAlias www.example.com
    DocumentRoot /var/www/example.com/public_html
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

test.com.conf
<VirtualHost *:80>
    ServerAdmin admin@test.com
    ServerName test.com
    ServerAlias www.test.com
    DocumentRoot /var/www/test.com/public_html
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

If you just want to use one domain name to access two files, maybe you can move that file /var/www/test.no/www to /var/www/rajohan.no/www .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM