Results 1 to 7 of 7

Thread: n00b apache2 alias question

  1. #1
    Join Date
    Mar 2005
    Location
    Austin
    Beans
    339
    Distro
    Ubuntu 7.04 Feisty Fawn

    n00b apache2 alias question

    Hi

    I was wondering if someone could help me setup an alias on apache to a folder on my home directory.

    The foler is at /home/idn/projects/portal/www

    So when I go to http://localhost/portal it goes to the directory above. I will neeed to execture php scripts in this directory.

    I have googled round but havent really found a clear howto so if soeone could post step by step instructions i would very much appreciate it

    Thanks!

  2. #2
    Join Date
    Feb 2005
    Location
    ${HOME}
    Beans
    Hidden!

    Re: n00b apache2 alias question

    I'm assuming you already have PHP installed here?

    Edit /etc/apache2/apache2.conf (orI think it's /etc/apache/httpd.conf if you're using Apache 1). Add this line:
    Code:
    Alias /portal /home/idn/projects/portal/www
    Now restart Apache:
    Code:
    sudo /etc/init.d/apache2 restart
    Or /etc/init.d/apache restart if you use Apache 1. Now, most important step. Open a web browser and go to http://hostname/portal (replace hostname with the hostname of your box, or localhost in your case it seems) and enjoy your pages.
    Joel Goguen

  3. #3
    Join Date
    Aug 2005
    Beans
    169

    Re: n00b apache2 alias question

    or go to /var/www/ and set up a symbolic link to /home/idn/projects/portal/www.
    Code:
    ln -s /home/idn/projects/portal/www

  4. #4
    Join Date
    Feb 2005
    Location
    ${HOME}
    Beans
    Hidden!

    Re: n00b apache2 alias question

    But that creates the structure /var/www/www, meaning he would go to http://localhost/www instead of http://localhost/portal like he said he wanted.
    Joel Goguen

  5. #5
    Join Date
    Mar 2005
    Location
    Austin
    Beans
    339
    Distro
    Ubuntu 7.04 Feisty Fawn

    Re: n00b apache2 alias question

    Quote Originally Posted by jgoguen
    I'm assuming you already have PHP installed here?

    Edit /etc/apache2/apache2.conf (orI think it's /etc/apache/httpd.conf if you're using Apache 1). Add this line:
    Code:
    Alias /portal /home/idn/projects/portal/www
    Now restart Apache:
    Code:
    sudo /etc/init.d/apache2 restart
    Or /etc/init.d/apache restart if you use Apache 1. Now, most important step. Open a web browser and go to http://hostname/portal (replace hostname with the hostname of your box, or localhost in your case it seems) and enjoy your pages.
    Thanks this works great!

  6. #6
    Join Date
    Jun 2007
    Beans
    1

    Re: n00b apache2 alias question

    but why do if i added one slash in alias directive such as..

    Code:
    Alias /portal/ /home/idn/projects/portal/www
    it become unusable?

    if we access files on portal apache return file not found.
    any clue? (however in default /doc/ is alias with two slash, and it worked flawlessly)

  7. #7
    Join Date
    Nov 2006
    Location
    Vienna
    Beans
    36
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: n00b apache2 alias question

    Straight from the Apache 2 docs:

    The Alias directive allows documents to be stored in the local filesystem other than under the DocumentRoot. URLs with a (%-decoded) path beginning with url-path will be mapped to local files beginning with directory-path. The url-path is case-sensitive, even on case-insensitive file systems.
    Example:

    Alias /image /ftp/pub/image

    A request for http://myserver/image/foo.gif would cause the server to return the file /ftp/pub/image/foo.gif. Only complete path segments are matched, so the above alias would not match a request for http://myserver/imagefoo.gif. For more complex matching using regular expressions, see the AliasMatch directive.

    Note that if you include a trailing / on the url-path then the server will require a trailing / in order to expand the alias. That is, if you use Alias /icons/ /usr/local/apache/icons/ then the url /icons will not be aliased.
    _why: When you don't create things, you become defined by your tastes rather than ability. Your tastes only narrow and exclude people. So create.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •