CentOS6.5 install the Apache service, centos6.5apache

Source: Internet
Author: User

CentOS6.5 install the Apache service, centos6.5apache

I. Description

CentOS can be used to install the Apache service either by using yum or by downloading the source code from the official website.


Ii. Use yum to install the Apache service

Step 1: Enter the following statement in the command line to install the tool using the yum online update method:

[Tong @ tong/] $ sudo yum install httpd-y

Note: The default installation path of the configuration file is/etc/httpd/conf/httpd. conf.

Step 2: configure the firewall and add a line in red below to enable port 80 for customers to browse.

[Tong @ tong/] $ sudo vi/etc/sysconfig/iptables
-A input-m state -- state NEW-m tcp-p tcp -- dport 22-j ACCEPT
# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
* Filter
: Input accept [0: 0]
: Forward accept [0: 0]
: Output accept [0: 0]
-A input-m state -- state ESTABLISHED, RELATED-j ACCEPT
-A input-p icmp-j ACCEPT
-A input-I lo-j ACCEPT
-A input-m state -- state NEW-m tcp-p tcp -- dport 22-j ACCEPT
-A input-m state -- state NEW-m tcp-p tcp -- dport 80-j ACCEPT
-A input-j REJECT -- reject-with icmp-host-prohibited
-A forward-j REJECT -- reject-with icmp-host-prohibited

Step 3: restart the firewall after the firewall is configured.

[Tong @ tong/] $ sudo service iptables restart
Iptables: Setting chains to policy ACCEPT: filter [OK]
Iptables: Flushing firewall rules: [OK]
Iptables: Unloading modules: [OK]
Iptables: Applying firewall rules: [OK]

Step 4. After Apache configuration is complete, you can start the service

[Tong @ tong/] $ sudo service httpd start
Starting httpd: apr_sockaddr_info_get () failed for tong
Httpd: cocould not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
[OK]

Note: although it can be started here, an error is reported because the ServerName parameter is not added to the configuration file of the Apache server. Therefore, we need to configure this parameter in the configuration file.

Step 5: Check our hostname host name and add the host name to the ServerName parameter in the Apache configuration file.

[Tong @ tong/] $ hostname
Tong
[Tong @ tong/] $ cat/etc/sysconfig/network
NETWORKING = yes
HOSTNAME = tong

If the above hostname is tong, edit the Apache configuration file

[Tong @ tong conf] $ sudo vi/etc/httpd/conf/httpd. conf

Add one row: ServerName tong: 80

Step 5: restart the Apache service and no error is reported.

[Tong @ tong conf] $ sudo service httpd restart
Stopping httpd: [OK]
Starting httpd: [OK]

Step 6: test the sample webpage

Enter http: // local IP address in the local browser. My IP address is 192.168.200.5, And I enter http: // 192.168.200.5 in the browser.

Result:



3. Use source code to install the Apache service

Step 1: Download the source code file

[Tong @ tong tongSoftware] $ sudo wget http://mirror.bit.edu.cn/apache//httpd/httpd-2.4.12.tar.gz

Step 2. Unzip and install

[Tong @ tong tongSoftware] $ sudo tar xzvf httpd-2.4.12.tar.gz

Enter the decompressed directory and enter the following command:

[Tong @ tong httpd-2.2.29] $ sudo./configure

Configure: error: in '/usr/local/tongSoftware/httpd-2.2.29/srclib/apr ':
Configure: error: no acceptable C compiler found in $ PATH
See 'config. log' for more details
Configure failed for srclib/apr

If the system prompts that the gcc compiler is not installed, install the compiler.

[Tong @ tong httpd-2.2.29] $ sudo yum install gcc

After the installation is successful, recompile the source file:

[Tong @ tong httpd-2.2.29] $ sudo./configure // check whether the installation platform supports Installation

[Tong @ tong httpd-2.2.29] $ sudomake // compile Based on the Installation Platform

[Tong @ tong httpd-2.2.29] $ sudomake install // install software

Configure the firewall according to the method previously installed with yum to start the Apache service.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.