Apache2 Alias not working in Ubuntu?
Asked Answered
B

4

5

I've just setup apache/php/mysql in Ubuntu 12.04, and I've created an Alias for my virtual directory, here's my /etc/apache2/sites-enabled/000-default file:

Alias /demo/ "/home/czetsuya/projects/eclipse/eclipse-php/demo-portfolio"
<Directory "/home/czetsuya/projects/eclipse/eclipse-php/demo-portfolio">
    DirectoryIndex index.php
    Options Indexes MultiViews FollowSymLinks
    AllowOverride All
    Order deny,allow
    Deny from all
    Allow from all
</Directory>

Note that I've already applied chown and chmod to: /home/czetsuya/projects/eclipse/eclipse-php/demo-portfolio

chown www-data:www-data /home/czetsuya/projects/eclipse/eclipse-php/demo-portfolio -R
chmow 777 /home/czetsuya/projects/eclipse/eclipse-php/demo-portfolio -R

But when I access: _http://localhost/demo, I got a 404 Not found error. Looking at /var/log/apache2/error.log I found that it's still pointing at /var/www/demo:

File does not exist: /var/www/demo

Any idea why Alias is ignored?

Note that I already restart and reload apache2. And rewrite is also enabled.

Thanks,
czetsuya

Banns answered 2/11, 2012 at 4:20 Comment(0)
D
10

Your problem can most likely be solved by the mod_alias manual;

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, as it lacks that trailing /.

Try changing /demo/ to /demo in your alias, and it should work better.

Disabuse answered 2/11, 2012 at 4:25 Comment(0)
P
11

All aliases in Apache 2.4 have to be configured in the /etc/apache2/mods-enabled/alias.conf file.

They are ignored in the virtual host files.

Puerperium answered 13/8, 2018 at 19:28 Comment(1)
Virtual host files likely support this on their setup. Most often the issue is related to what was discussed here: https://mcmap.net/q/1865961/-apache2-alias-not-working-in-ubuntuFavourable
D
10

Your problem can most likely be solved by the mod_alias manual;

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, as it lacks that trailing /.

Try changing /demo/ to /demo in your alias, and it should work better.

Disabuse answered 2/11, 2012 at 4:25 Comment(0)
I
1

Step 1: Installing Apache on Ubuntu 22.04
Apache2 is an open-source popular, powerful, reliable, and highly extensible web/HTTP server software used by numerous websites on the internet.

To install the Apache2 package, use the default package manager as follows:

 $ sudo apt install apache2  <br><br>

enter image description here

The configuration files for Apache2 are located in /etc/apache2 directory and the main configuration file is strong text/etc//etc/apache2/apache2.conf. And the default document root for storing your web files is /var/www/html/.



2. On Ubuntu unlike on other major Linux distributions, systemd services are automatically started and enabled to start at system boot, when a package (intended to run as a service) installation is complete.

You can confirm that the Apache2 service is up and enabled on boot using the following systemctl commands.

 $ sudo systemctl status apache2 <br>
 $ sudo systemctl is-enabled apache2

enter image description here

3. Next, you need to test the correct operation of the Apache2 server installation. Open a web browser and use the following address to navigate.

http://YOUR_SERVER_IP
Irrawaddy answered 1/6, 2023 at 4:45 Comment(0)
N
-1

guy take care about exact syntax of these SLASHES it can not be at the end of directory name and also not at the end of alias name, this cost me unbelivable time to find this error, very good work people from apache !!! proper way : Alias "/docs" "/var/web" wrong way: Alias "/docs/" "/var/web/"

Nucleolated answered 10/1, 2017 at 9:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.