LINUX - Apache httpd 配置
Configuring Apache HTTPD
Apache HTTPD 简介
Apache HTTPD is one of the most used web servers on the Internet. A web server is a daemon that speaks the http(s) protocol, a text-based protocol for sending and receiving objects over a network connection. The http protocol is sent over the wire in clear text, using port 80/TCP by default (though other ports can be used). There is also a TLS/SSL encrypted version of the protocol called https that uses port 443/TCP by default.
Installing
yum -y install httpd httpd-manual
Configuring
Configuration file and root directory:
/etc/httpd/conf/httpd.conf
- default configuration/var/www/html
- default directory for all requests
Network security
firewalld
has two predefined services for httpd
firewall-cmd --permanent --add-service=http --add-service=https
firewall-cmd --reload
- to check SELinux allowed port sets
semanage port -l | grep '^http_'
- Add a SELinux rule to allow use an alternate document root
semanage fcontext -a -t httpd_sys_content_t '/new/location(/.*)?'
- Create a test page
Create the /var/www/html/index.html
file and any content.
Start and enable
systemctl start httpd.service
systemctl enable httpd.service
Testing
Open a web browse access the following 2 urls:
- http://localhost
- http://localhost/manual