littleworth
littleworth

Reputation: 5169

How to change the apache httpd port for serving files

Currently, I have the following IP address with this port:

http://292.168.14.23/
http://292.168.14.23:80/

The above addresses behave identically and have been used for serving the local UCSC Genome Browser.

What I want to do now is to set a new IP address, say http://292.168.14.23:8080/ -- namely using 8080 as a port instead of the default 80 -- that I can use to serve basic files in Apache. So when I do this:

http://292.168.14.23:8080/my_spec_dir/myfile.txt

I can navigate and download the files from the browser. How can I do that?

Following this instruction, I tried changing this file /etc/httpd/conf/httpd.conf with these lines:

Listen 8080
ServerName 292.168.14.23:8080

Although this address work: http://292.168.14.23:8080, I still cannot get access to the file: http://292.168.14.23:8080/my_spec_dir/myfile.txt

Note that my_spec_dir is stored under /web/html, and it is configured in httpd.conf this way:

#
# Relax access to content within /var/www.
#
<Directory "/web/html">
    AllowOverride All
    # Allow open access:
    Require all granted
    Header set Access-Control-Allow-Origin "*"
</Directory>

Upvotes: 1

Views: 1177

Answers (2)

Edwin Dijas Chiwona
Edwin Dijas Chiwona

Reputation: 620

If you want to change global document root

Listen 8080
ServerName 292.168.14.23
DocumentRoot "/web/html/my_spec_dir"

Or if you want a virtualhost.

Listen 8080
<VirtualHost 292.168.14.23:8080 >
    DocumentRoot "/web/html/my_spec_dir"
    ServerName 292.168.14.23

    # Other directives here
</VirtualHost>

Upvotes: 2

user9601558
user9601558

Reputation:

Are you sure you have added configuration override through htaccess files?

<Directory /path/to/public/website/>
   AllowOverride All <--
   ...
</Directory>

How to Set AllowOverride all

Htaccess manual: https://httpd.apache.org/docs/current/howto/htaccess.html

Upvotes: 2

Related Questions