Apache changes the default port

Time:2020-11-29

Apache changes the default port

1. Modify configuration file

(1) Modify / etc / apache2/ ports.conf take

NameVirtualHost *:80
Listen 80
#Change to the port you need
NameVirtualHost *:9000
Listen 9000

(2) Some need to modify default and httpd.conf configuration file

#Find configuration file
sudo find / -name default
sudo find / -name httpd.conf

(3) Restart Apache

sudo /etc/init.d/apache2 restart
Port modification completed. The port of Apache has been changed to 9000.

2. To modify the default site directory:

/etc/apache2/sites-available/default
#Change / var / www to your path / var / www / HTML/

3. To modify the default home page document:

/etc/apache2/mods-available/dir.conf
#Replace index. * with XXX*

4. Finally

However, depending on the version of Apache 2, the location of the files is different.

Check which file directoryindex is in apache2: grep – IR directoryindex / etc / apache2

#My Ubuntu 15.04 looks like this
[email protected]:/etc/apache2/sites-enabled#  grep -iR DirectoryIndex /etc/apache2
/etc/apache2/mods-enabled/dir.conf:DirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.htm
/etc/apache2/mods-available/dir.conf:DirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.htm

Apache changes the default port