简体   繁体   中英

Apache VirtualHosts on AWS EC2 not working

I'm trying to set up a VirtualHost on my AWS EC2 Linux server. However, it continues to direct the request to the default page.

I've installed apache and when I create an index file in /var/www/html/ it displays as expected.

However, when I add a *.conf virtual host it just reverts the default page.

I've created my /etc/httpd/conf.d/{myvhost.conf} file:

<VirtualHost *:80>
    DocumentRoot "/home/username/www/public"
    ServerName ec2-13-55-0-7.ap-southeast-2.compute.amazonaws.com

</VirtualHost>

The document root has been created at /home/username/www/public and I've added a custom index.html file, perms set to 755.

IncludeOptional conf.d/*.conf is uncommented in /etc/httpd/conf/httpd.conf

Restarted apache.

But default page is displayed and not my /home/username/www/public .
Why?

First it would be nice if you added some Directory directives to your root folder:

<Directory "/home/username/www/public/">
  allow from all
  Options +Indexes
</Directory>

Or ( source ):

<LocationMatch "^/+$">
    Options Indexes
</LocationMatch>

Second, you can debug what Apache understand of the configuration :

# Check for syntax error
apachectl -t
# List VirtualHost
apachectl -S

# both checks:
apachectl -t -D DUMP_VHOSTS

Of course, check the log files .

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