Add new port to apache in centos

Lim Sing
May 6, 2021

1. vi /etc/httpd/conf/httpd.conf
add
Listen 8080
2. touch xx.conf file in /etc/httpd/conf.d
3. edit this file xx.conf
4. systemctl restart httpd
5. if failed, change to port 8080, then repeat 1

<VirtualHost *:8080>
ServerName xx.com
DocumentRoot /var/www/html/xx/public

<Directory /var/www/html/xx>
AllowOverride All
</Directory>
</VirtualHost>

— — — — — — — — — if failed — — — — — — — — —
1. yum install policycoreutils
2. Add Selinux rules for port 8080.

semanage port -a -t http_port_t -p tcp 8080
semanage port -m -t http_port_t -p tcp 8080

--

--