The main configuration file of Apache is /etc/httpd/conf/httpd.conf. It contains many configurations that do not need to be changed in a basic installation. (Recommended learning: Apache Server)
In fact, just make a few changes to this file to get a simple website up and running. The file is quite large, so instead of cluttering this post with a lot of unnecessary stuff, I'll only show those instructions that need to be changed.
First, take some time to familiarize yourself with the httpd.conf file. One of the reasons I like Red Hat is that its configuration file comments are very detailed. The httpd.conf file is no exception as it is well commented. You can use these comments to understand the configuration of the file.
The first thing to modify is the Listen configuration item, which defines the IP address and port where Apache will listen for page requests. Now, you just need to make this website accessible from local, so use the localhost address. When completed, the line should look like this: (LCTT Annotation: The IP address of localhost is 127.0.0.1, 80 is the port)
Listen 127.0.0.1:80
The DocumentRoot configuration item specifies the location of the HTML files that make up the website pages. This configuration item does not need to be changed because it already points to the standard location. The line should look like this:
DocumentRoot "/var/www/html"
This could look like this:
DocumentRoot "/var/mywebsite/html"
The entire file looks like this:
# sample configuration for iptables service # you can edit this manually or use system-config-firewall # please do not ask us to add additional ports/services to this default configuration *filter :INPUT ACCEPT [0:0] :FORWARD ACCEPT [0:0] :OUTPUT ACCEPT [0:0] -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT -A INPUT -p icmp -j ACCEPT -A INPUT -i lo -j ACCEPT -A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT -A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT -A INPUT -j REJECT --reject-with icmp-host-prohibited -A FORWARD -j REJECT --reject-with icmp-host-prohibited COMMIT
[root@testvm1 ~]# cd /etc/sysconfig/ ; iptables-restore iptables
The above is the detailed content of How to configure apache server. For more information, please follow other related articles on the PHP Chinese website!