How to publish another directory (/opt/xxx) while maintaining the document root

Asked 2 years ago, Updated 2 years ago, 55 views


while maintaining sites previously published in /var/www/html I would also like to publish a new /opt/xxx directory.

I looked it up and found that I could do it with Alias from httpd.conf.
Alias seemed to change every root directory.

I want to keep the root directory
Could you please let me know if there is a good way?

apache

2022-09-30 16:21

2 Answers

If you publish it as a subdirectory, I think it's easy to create symbolic links quickly.

Example: (Procedure to publish a directory other than the document root in Redmine)

$cd/var/www/html
$ sudorn-s/var/lib/redmine/public redmine

→ Browser accessible in the form localhost/redmine

As a reminder, the original directory you want to publish should be accessible to your web server's process (account).


2022-09-30 16:21

There may be situations where you cannot operate the file system, so
Here's how to configure only httpd.conf.

There was an example close to this
https://serverfault.com/questions/295975/add-a-directory-to-the-apache-web-root

 Alias/opt-xxx/opt/xxx
<Directory/opt/xxx>
     Order allow, deny
     Allow from all
</Directory>

By writing like this,
http://hoge.com/opt-xxx/file1.jpg
->/opt/xxx/file1.jpg
You will have access similar to .


2022-09-30 16:21

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.