Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question
    
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 '13 at 1:56
add comment

2 Answers

up vote 0 down vote accepted

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.

share|improve this answer
add comment

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 :)

share|improve this answer
    
It didn't work. Thanks a lot anyway man :-) –  Rade Jun 29 '13 at 15:58
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.