Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to configure apache

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces the method of configuring apache, the article is very detailed, has a certain reference value, interested friends must read it!

The installation and configuration of the Apache Web server must be performed as root. The configuration of the firewall also needs to be performed as root. Viewing the results of the installation configuration using a browser should be done as a non-root user.

The main configuration file for Apache is / etc/httpd/conf/httpd.conf. It contains many configurations that do not need to be changed in the basic installation. In fact, you only need to make some changes to this file to get a simple Web site up and running. The file is very large, so I won't confuse this article with a lot of unnecessary stuff, but only show instructions that need to be changed.

First, take a moment to familiarize yourself with the httpd.conf file. One of the reasons I like Red Hat is that its configuration file annotations are very detailed. The httpd.conf file is no exception because it is well annotated. 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 on which Apache listens for page requests. Now, you just need to make the site accessible locally, so use the localhost address. When you are done, the line should look like this: (LCTT note: the IP address of localhost is 127.0.0.1 and 80 is the port)

Listen 127.0.0.1:80

By setting this configuration item to the IP address of localhost, Apache will only listen for connections from the local host. If you want the Web server to listen for connections from remote hosts, you can use the external IP address of the host.

The DocumentRoot configuration item specifies the location of the HTML file that makes up the page of the Web site. This configuration item does not need to be changed because it already points to a standard location. The bank should look like this:

DocumentRoot "/ var/www/html"

The Apache installation package creates the / var/www directory. If you want to change the location where Web site files are stored, use this configuration item to do so. For example, you might want to use a different name for the www directory to more clearly identify the Web site. This can go like this:

DocumentRoot "/ var/mywebsite/html"

These are the only Apache configuration items that need to be modified to create a simple Web site. For this little exercise, only a few changes have been made to the httpd.conf file (the Listen configuration item). Other configuration items need not be configured for a simple Web server for the time being.

Another thing that needs to change is to open port 80 in our firewall. I use iptables [2] as my firewall, so I change the / etc/sysconfig/iptables file to add that the HTTP protocol is allowed. The whole 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]-An INPUT-m state-- state RELATED ESTABLISHED-j ACCEPT-An INPUT-p icmp- j ACCEPT-An INPUT-I lo-j ACCEPT-An INPUT-p tcp-m state-- state NEW-m tcp-- dport 22-j ACCEPT-An INPUT-p tcp-m state-- state NEW-m tcp-- dport 80-j ACCEPT-An INPUT-j REJECT-- reject-with icmp-host-prohibited-A FORWARD-j REJECT-- reject-with icmp-host-prohibitedCOMMIT is all the contents of the method for configuring apache Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report