0

I have an app that's accessible via 1.2.3.4/myapp. The app is installed in /var/www/myapp. I've set up a subdomain(apps.mydomain.com) that points to 1.2.3.4. I want the server to point to var/www/myapp if I type apps.mydomain.com/myapp, how do I do that? I have experience creating virtual hosts(lots of them) locally but I'm lost because it's now in production and it's a little different. Here's my virtual host config:

<VirtualHost *:80>
        ServerAdmin webmaster@localhost
        ServerName apps.mydomain.com/myapp

        DocumentRoot /var/www/myapp/public
        <Directory />
                Options FollowSymLinks
                AllowOverride All
        </Directory>
        <Directory /var/www/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all
        </Directory>

        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <Directory "/usr/lib/cgi-bin">
                AllowOverride All
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                Order allow,deny
                Allow from all
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn

        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Any idea why I still see the files instead of pointing me to the document root?

Just in case someone might ask, the app is based on Laravel 4 framework. It's really bad right now because anyone can access the files from the browser.

1
  • Really...this question has nothing to do with EC2. We like to keep tags "clean", and as stated in the edit comment, this issue you're having has nothing to do with the fact that you're running on EC2. It's a generic linux/apache problem.
    – EEAA
    Jul 1, 2013 at 1:56

2 Answers 2

0

Try this one.

ServerAdmin webmaster@localhost ServerName apps.mydomain.com

    DocumentRoot /var/www
    <Directory /var/www/>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride All
            Order allow,deny
            allow from all
    </Directory>
    Alias /myapp "/var/www/myapp/public/"
    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    <Directory "/usr/lib/cgi-bin">
            AllowOverride All
            Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
            Order allow,deny
            Allow from all
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog ${APACHE_LOG_DIR}/access.log combined

And if you don't want others to access apps.mydomain.com, add a index.php in /var/www with a redirect to apps.mydomain.com/myapp.

<?php
    header("Location: /myapp");
?>

I think it will work as per your need.

0

I think that adding this to the virtualhost of apps.mydomain.com should work:

Alias /myapp "/var/www/myapp/public/"

This should point apps.mydomain.com/myapp to that folder

And if that works you can remove existing virtual host of apps.mydomain.com/myapp

But i'm not a server admin, I can be wrong. Just wait it out :)

1
  • It didn't work. Thanks a lot anyway man :-)
    – anlogg
    Jun 29, 2013 at 15:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .