龙空技术网

LAMP架构应用实战之Apache服务介绍与安装

知一能量 372

前言:

此时我们对“apache路径访问”都比较关注,看官们都想要分析一些“apache路径访问”的相关内容。那么小编也在网络上收集了一些对于“apache路径访问””的相关文章,希望大家能喜欢,同学们一起来学习一下吧!

一:Apache是什么

Apache是Apache基金会开发的一个高性能、功能强大、安全可靠、灵活的开放源码的WEB服务软件

二:Apache的特点与应用场景

1、特点

功能强大、配置简单、速度快、应用广泛、性能稳定可靠,同时还可以做代理服务器或负载均衡

2、应用场景

运行静态页面、图片(据说处理静态小文件能力不如nginx)结合PHP引擎运行PHP等程序,LAMP组合结合tomcat、resin运行jsp、java等程序作代理、负载均衡,rewrite规则过滤等三:Apache的安装

一般系统默认自带安装的Apache版本相对较低,安装之前先查看下是否自带Apache服务

1、检查系统是否安装Apache服务

[root@Centos~]# rpm -qa httpd*

httpd-2.2.15-54.el6.centos.x86_64

httpd-tools-2.2.15-54.el6.centos.x86_64

2、如果没有自带Apache服务软件,可以不需要进行下面的卸载

[root@Centos~]# rpm -e --nodeps httpd-2.2.15-54.el6.centos.x86_64

warning:/etc/httpd/conf/httpd.conf saved as /etc/httpd/conf/httpd.conf.rpmsave

[root@Centos~]# rpm -e --nodeps httpd-tools-2.2.15-54.el6.centos.x86_64

3、卸载完成后检查下卸载是否成功

[root@Centos ~]# rpm -qa|grep httpd

4、创建用于存放下载的软件工具目录

[root@Centos ~]# mkdir -p /Downloads/tools

[root@Centos ~]# cd /Downloads/tools

[root@Centos tools]# ls

5、进入官方网站下载apache软件到当前目录

[root@Centos tools]# wget

--2016-09-11 23:44:41--

Resolving mirrors.tuna.tsinghua.edu.cn... 166.111.206.63, 2402:f000:1:416:166:111:206:63

Connecting to mirrors.tuna.tsinghua.edu.cn|166.111.206.63|:443... connected.

HTTP request sent, awaiting response... 200 OK

Length: 8406575 (8.0M) [application/octet-stream]

Saving to: "httpd-2.4.23.tar.gz"

100%[=============================>] 8,406,575 1.19M/s in 6.9s

2016-09-11 23:44:49 (1.17 MB/s) - "httpd-2.4.23.tar.gz" saved [8406575/8406575]

6、查看下载的文件并解压

[root@Centos tools]# ls

httpd-2.4.23.tar.gz

[root@Centos tools]# tar zxvf httpd-2.4.23.tar.gz

.................................................................................................具体解压过程此处省略

切换到软件目录下,查看具体内容

[root@Centos tools]# cd httpd-2.4.23

[root@Centos httpd-2.4.23]# ls -ll

total 2000

-rw-r--r--.1 yumw games 13496 Apr 16 2015 ABOUT_APACHE

-rw-r--r--.1 yumw games 24689 Jun 30 01:30 acinclude.m4

-rw-r--r--.1 yumw games 65340 Jun 14 23:15 Apache-apr2.dsw

-rw-r--r--.1 yumw games 79911 Jun 14 23:15 Apache.dsw

-rw-r--r--.1 yumw games 9907 Dec 18 2009 apache_probes.d

-rw-r--r--.1 yumw games 2512 Dec 22 2008 ap.d

drwxr-xr-x.6 yumw games 4096 Sep 12 00:01 build

-rw-r--r--.1 yumw games 2644 Aug 24 2007 BuildAll.dsp

-rw-r--r--.1 yumw games 2748 Sep 28 2015 BuildBin.dsp

-rwxr-xr-x. 1 yumw games 6800 Sep 19 2012 buildconf

-rw-r--r--.1 yumw games 214576 Jun 30 22:42 CHANGES

-rw-r--r--.1 yumw games 43781 Jun 14 16:51 CMakeLists.txt

-rw-r--r--.1 yumw games 12567 Apr 17 2012 config.layout

-rwxr-xr-x. 1 yumw games 1097227 Jul 1 01:15 configure

-rw-r--r--.1 yumw games 28491 Sep 6 2015 configure.in

drwxr-xr-x.9 yumw games 4096 Sep 12 00:01 docs

-rw-r--r--.1 yumw games 403 Nov 22 2004 emacs-style

-rw-r--r--.1 yumw games 2218 Mar 23 11:53 httpd.dep

-rw-r--r--.1 yumw games 4124 Jun 12 2008 httpd.dsp

-rw-r--r--.1 yumw games 8994 Mar 23 11:53 httpd.mak

-rw-r--r--.1 yumw games 17678 Jul 1 01:15 httpd.spec

drwxr-xr-x.2 yumw games 4096 Sep 12 00:01 include

-rw-r--r--.1 yumw games 3782 May 18 01:59 INSTALL

-rw-r--r--.1 yumw games 2909 Nov 15 2011 InstallBin.dsp

-rw-r--r--.1 yumw games 4097 Nov 16 2013 LAYOUT

-rw-r--r--.1 yumw games 79070 Mar 23 11:53 libhttpd.dep

-rw-r--r--.1 yumw games 20737 Oct 3 2013 libhttpd.dsp

-rw-r--r--.1 yumw games 37816 Mar 23 11:53 libhttpd.mak

-rw-r--r--.1 yumw games 25853 Oct 2 2013 LICENSE

-rw-r--r--.1 yumw games 10452 Mar 20 23:51 Makefile.in

-rw-r--r--.1 yumw games 49943 Jun 14 23:15 Makefile.win

drwxr-xr-x.27 yumw games 4096 Sep 12 00:01 modules

-rw-r--r--.1 yumw games 550 Jan 2 2016 NOTICE

-rw-r--r--.1 yumw games 13884 Mar 20 23:51 NWGNUmakefile

drwxr-xr-x.7 yumw games 4096 Sep 12 00:01 os

-rw-r--r--.1 yumw games 4642 Jan 24 2014 README

-rw-r--r--. 1 yumw games 13317 Mar 23 11:45 README.cmake

-rw-r--r--.1 yumw games 4418 Aug 28 2014 README.platforms

-rw-r--r--.1 yumw games 10184 Oct 31 2010 ROADMAP

drwxr-xr-x.3 yumw games 4096 Sep 12 00:01 server

drwxr-xr-x.2 yumw games 4096 Sep 12 00:01 srclib

drwxr-xr-x.4 yumw games 4096 Sep 12 00:01 support

drwxr-xr-x.2 yumw games 4096 Sep 12 00:01 test

-rw-r--r--.1 yumw games 8183 Mar 1 2007 VERSIONING

查看apache介绍

[root@Centos httpd-2.4.23]# cat README

Apache HTTP Server

What is it?

-----------

The Apache HTTP Server is a powerful and flexible HTTP/1.1 compliant

web server. Originally designed as a replacement for the NCSA HTTP

Server, it has grown to be the most popular web server on the

Internet. As a project of the Apache Software Foundation, the

developers aim to collaboratively develop and maintain a robust,

commercial-grade, standards-based server with freely available

source code.

The Latest Version

------------------ 后面的内容此处省略

介绍如何安装apache服务

[root@Centos httpd-2.4.23]# cat INSTALL

APACHE INSTALLATION OVERVIEW

Quick Start - Unix

------------------

For complete installation documentation, see [ht]docs/manual/install.html or

$ ./configure --prefix=PREFIX

$ make

$ make install

$ PREFIX/bin/apachectl start

更多内容可自行查看文档介绍

7、编译安装

[root@Centoshttpd-2.4.23]# ./configure \

>--prefix=/application/apache2.4.23 \

>--enable-deflate \

>--enable-expires \

>--enable-headers \

>--enable-modules=most \

>--enable-so \

>--with-mpm=worker \

>--enable-rewrite

参数说明如下:

>--prefix=/application/apache2.4.23 \

表示指定安装路径为/application/apache2.4.23 \,如果不指定,默认为/usr/local/apache2

>--enable-deflate \

提供对内容的压缩传输编码支持,提高传输速度,提升访问体验,生产环境中这是重要调优参数之一

> --enable-expires\

激活允许通过配置文件控制 HTTP的"Expires:"和"Cache-Control:"头内容,即对网站的图片等内容,提供在客户端浏览器缓存的设置,也是生产环境重要调优参数之一

>--enable-headers \

提供允许对HTTP请求头的控制

>--enable-modules=most \

编译安装模块 most表示包含大部分模块到httpd

>--enable-so \

激活apache服务的DSO(动态共享对象)支持,即可在以后以DSO的方式编译安装共享模块

>--with-mpm=worker \

选择apache mpm的模式为worker模式,此模式原理是更多的使用线程来处理请求,可以处理更多并发请求,也是apache调优的一个重要参数

>--enable-rewrite

提供基于URL规则的重写功能,根据已知URL地址,转换其它要访问的URL地址

checkingfor chosen layout... Apache

checkingfor working mkdir -p... yes

checkingfor grep that handles long lines and -e... /bin/grep

checkingfor egrep... /bin/grep -E

checkingbuild system type... x86_64-unknown-linux-gnu

checkinghost system type... x86_64-unknown-linux-gnu

checkingtarget system type... x86_64-unknown-linux-gnu

configure:

configure:Configuring Apache Portable Runtime library...

configure:

checkingfor APR... no

configure: error: APR not found. Please read thedocumentation.

出现错误提示:configure: error: APR not found

解决方法如下

下载APR并进行安装

[root@Centos tools]# wget

--2016-09-12 00:56:22--

Resolving mirrors.tuna.tsinghua.edu.cn... 166.111.206.63, 2402:f000:1:416:166:111:206:63

Connecting to mirrors.tuna.tsinghua.edu.cn|166.111.206.63|:443... connected.

HTTP request sent, awaiting response... 200 OK

Length: 1031613 (1007K) [application/octet-stream]

Saving to: "apr-1.5.2.tar.gz"

100%[=========================================================>] 1,031,613 1.70M/s in 0.6s

2016-09-12 00:56:28 (1.70 MB/s) - "apr-1.5.2.tar.gz" saved [1031613/1031613]

[root@Centos tools]# ls

apr-1.5.2.tar.gz httpd-2.4.23 httpd-2.4.23.tar.gz

[root@Centos tools]# tar zxvf apr-1.5.2.tar.gz

[root@Centos apr-1.5.2]# ./configure

--prefix=/usr/local/apr

checking build system type... x86_64-unknown-linux-gnu

checking host system type... x86_64-unknown-linux-gnu

checking target system type... x86_64-unknown-linux-gnu

Configuring APR library

Platform: x86_64-unknown-linux-gnu

checking for working mkdir -p... yes

APR Version: 1.5.2

checking for chosen layout... apr

checking for gcc... no

checking for cc... no

checking for cl.exe... no

configure: error: in `/Downloads/tools/apr-1.5.2':

configure: error: no acceptable C compiler found in $PATH

See `config.log' for more details

解决方案安装GCC套件

[root@Centos ~]# yum install gcc -y

Loaded plugins: fastestmirror, refresh-packagekit, security

Loading mirror speeds from cached hostfile

* base: mirrors.163.com

* extras: mirrors.163.com

* updates: mirrors.163.com

base |3.7kB 00:00

extras | 3.4 kB 00:00

updates | 3.4 kB 00:00

Setting up Install Process

Resolving Dependencies

-->Running transaction check

--->Package gcc.x86_64 0:4.4.7-17.el6 will be installed

-->Processing Dependency: libgomp = 4.4.7-17.el6 for package: gcc-4.4.7-17.el6.x86_64

-->Processing Dependency: cpp = 4.4.7-17.el6 for package: gcc-4.4.7-17.el6.x86_64

-->Processing Dependency: libgcc >= 4.4.7-17.el6 for package: gcc-4.4.7-17.el6.x86_64

-->Processing Dependency: cloog-ppl >= 0.15 for package: gcc-4.4.7-17.el6.x86_64

-->Running transaction check

--->Package cloog-ppl.x86_64 0:0.15.7-1.2.el6 will be installed

-->Processing Dependency: libppl_c.so.2()(64bit) for package: cloog-ppl-0.15.7-1.2.el6.x86_64

-->Processing Dependency: libppl.so.7()(64bit) for package: cloog-ppl-0.15.7-1.2.el6.x86_64

--->Package cpp.x86_64 0:4.4.7-17.el6 will be installed

-->Processing Dependency: libmpfr.so.1()(64bit) for package: cpp-4.4.7-17.el6.x86_64

--->Package libgcc.x86_64 0:4.4.7-4.el6 will be updated

--->Package libgcc.x86_64 0:4.4.7-17.el6 will be an update

--->Package libgomp.x86_64 0:4.4.7-4.el6 will be updated

--->Package libgomp.x86_64 0:4.4.7-17.el6 will be an update

-->Running transaction check

--->Package mpfr.x86_64 0:2.4.1-6.el6 will be installed

--->Package ppl.x86_64 0:0.10.2-11.el6 will be installed

-->Finished Dependency Resolution

Dependencies Resolved

===========================================================

Package Arch Version Repository Size

===========================================================

Installing:

gcc x86_64 4.4.7-17.el6 base 10 M

Installing for dependencies:

cloog-ppl x86_64 0.15.7-1.2.el6 base 93 k

cpp x86_64 4.4.7-17.el6 base 3.7 M

mpfr x86_64 2.4.1-6.el6 base 157 k

ppl x86_64 0.10.2-11.el6 base 1.3 M

Updating for dependencies:

libgcc x86_64 4.4.7-17.el6 base 103 k

libgomp x86_64 4.4.7-17.el6 base 134 k

Transaction Summary

===========================================================

Install 5 Package(s)

Upgrade 2 Package(s)

Total

download size: 16 M

Downloading Packages:

(1/7):cloog-ppl-0.15.7-1.2.el6.x86_64.rpm | 93kB 00:00

(2/7):cpp-4.4.7-17.el6.x86_64.rpm | 3.7 MB 00:02

(3/7):gcc-4.4.7-17.el6.x86_64.rpm | 10 MB 00:08

(4/7):libgcc-4.4.7-17.el6.x86_64.rpm |103 kB 00:00

(5/7):libgomp-4.4.7-17.el6.x86_64.rpm |134 kB 00:00

(6/7):mpfr-2.4.1-6.el6.x86_64.rpm | 157 kB 00:00

(7/7):ppl-0.10.2-11.el6.x86_64.rpm | 1.3 MB 00:00

--------------------------------------------------------------------------------------------------------------------------------------

Total 1.2 MB/s | 16 MB 00:13

Running rpm_check_debug

Running Transaction Test

Transaction Test Succeeded

Running Transaction

Warning: RPMDB altered outside of yum.

** Found 1pre-existing rpmdb problem(s), 'yum check' output follows:

gnome-user-share-2.28.2-3.el6.x86_64 has missing requires of httpd >= ('0', '2.2.0', None)

Updating : libgcc-4.4.7-17.el6.x86_64 1/9

Installing : ppl-0.10.2-11.el6.x86_64 2/9

Installing : cloog-ppl-0.15.7-1.2.el6.x86_64 3/9

Updating : libgomp-4.4.7-17.el6.x86_64 4/9

Installing : mpfr-2.4.1-6.el6.x86_64 5/9

Installing : cpp-4.4.7-17.el6.x86_64 6/9

Installing : gcc-4.4.7-17.el6.x86_64 7/9

Cleanup : libgomp-4.4.7-4.el6.x86_64 8/9

Cleanup : libgcc-4.4.7-4.el6.x86_64 9/9

Verifying : libgcc-4.4.7-17.el6.x86_64 1/9

Verifying : ppl-0.10.2-11.el6.x86_64 2/9

Verifying : mpfr-2.4.1-6.el6.x86_64 3/9

Verifying : gcc-4.4.7-17.el6.x86_64 4/9

Verifying : libgomp-4.4.7-17.el6.x86_64 5/9

Verifying : cpp-4.4.7-17.el6.x86_64 6/9

Verifying : cloog-ppl-0.15.7-1.2.el6.x86_64 7/9

Verifying : libgomp-4.4.7-4.el6.x86_64 8/9

Verifying : libgcc-4.4.7-4.el6.x86_64 9/9

Installed:

gcc.x86_64 0:4.4.7-17.el6

Dependency Installed:

cloog-ppl.x86_64 0:0.15.7-1.2.el6 cpp.x86_64 0:4.4.7-17.el6

mpfr.x86_64 0:2.4.1-6.el6 ppl.x86_64 0:0.10.2-11.el6

Dependency Updated:

libgcc.x86_64 0:4.4.7-17.el6 libgomp.x86_64 0:4.4.7-17.el6

Complete!

再次切换到APR目录下执行安装

[root@Centos ~]# cd /Downloads/tools/apr-1.5.2

[root@Centos apr-1.5.2]# ./configrue --prefix=/var/local/apr

[root@Centos apr-1.5.2]# make && make install

检查下是否安装成功

[root@Centos apr-1.5.2]# rpm -qa|grep apr

apr-1.3.9-5.el6_2.x86_64

apr-util-1.3.9-3.el6_0.1.x86_64

apr-util-ldap-1.3.9-3.el6_0.1.x86_64

下载apr-util软件

[root@Centostools]# wget

--2016-09-1201:40:11--

Resolvingmirrors.tuna.tsinghua.edu.cn... 166.111.206.63, 2402:f000:1:416:166:111:206:63

Connectingto mirrors.tuna.tsinghua.edu.cn|166.111.206.63|:443... connected.

HTTPrequest sent, awaiting response... 200 OK

Length:874044 (854K) [application/octet-stream]

Saving to:"apr-util-1.5.4.tar.gz"

100%[====================================================================================================================================>]874,044 904K/s in 0.9s

2016-09-1201:40:12 (904 KB/s) - "apr-util-1.5.4.tar.gz" saved [874044/874044]

[root@Centosapr-util-1.5.4]# ./configure --prefix=/usr/local/web/apr-util–with-apr=/usr/local/apr

[root@Centosapr-util-1.5.4]#make && make install

............................................................................................................................过程省略

重新切换到apache目录下执行前面的编译安装apache

[root@Centoshttpd-2.4.23]# ./configure

--prefix=/application/apache2.4.23\

--enable-deflate\

--enable-expires\

--enable-headers\

--enable-modules=most\

--enable-so\

--with-mpm=worker\

--enable-rewrite\

--with-apr=/usr/local/apr\

--with-apr-util=/usr/local/web/apr-util

checkingfor chosen layout... Apache

checkingfor working mkdir -p... yes

checkingfor grep that handles long lines and -e... /bin/grep

checkingfor egrep... /bin/grep -E

checkingbuild system type... x86_64-unknown-linux-gnu

checkinghost system type... x86_64-unknown-linux-gnu

checkingtarget system type... x86_64-unknown-linux-gnu

configure:

configure:Configuring Apache Portable Runtime library...

configure:

checkingfor APR... yes

setting CC to "gcc"

setting CPP to "gcc -E"

setting CFLAGS to " -g -O2-pthread"

setting CPPFLAGS to " -DLINUX-D_REENTRANT -D_GNU_SOURCE"

setting LDFLAGS to " "

configure:

configure:Configuring Apache Portable Runtime Utility library...

configure:

checkingfor APR-util... yes

checkingfor gcc... gcc

checkingwhether the C compiler works... yes

checkingfor C compiler default output file name... a.out

checkingfor suffix of executables...

checkingwhether we are cross compiling... no

checking forsuffix of object files... o

checkingwhether we are using the GNU C compiler... yes

checkingwhether gcc accepts -g... yes

checkingfor gcc option to accept ISO C89... none needed

checkinghow to run the C preprocessor... gcc -E

checkingfor gcc option to accept ISO C99... -std=gnu99

checkingfor pcre-config... false

configure: error: pcre-config for libpcre not found. PCRE isrequired and available from

根据提示解决方法如下

下载pcre软件交并安装

[root@Centostools]# wget

--2016-09-1203:18:42--

=> "pcre-8.38.tar.gz"

Resolving... 131.111.8.115

Connectingto ... connected.

Logging inas anonymous ... Logged in!

==> SYST... done. ==> PWD ... done.

==> TYPEI ... done. ==> CWD (1)/pub/software/programming/pcre ... done.

==> SIZEpcre-8.38.tar.gz ... 2053336

==> PASV... done. ==> RETR pcre-8.38.tar.gz... done.

Length:2053336 (2.0M) (unauthoritative)

100%[============================================================================================================================>]2,053,336 544K/s in 3.7s

2016-09-1203:18:54 (544 KB/s) - "pcre-8.38.tar.gz" saved [2053336]

[root@Centostools]# ls -ll

total 12096

drwxr-xr-x.28 1000 1000 4096 Sep 12 01:29 apr-1.5.2

-rw-r--r--. 1 root root 1031613 Apr 29 2015apr-1.5.2.tar.gz

drwxr-xr-x.20 1000 1000 4096 Sep 12 01:44 apr-util-1.5.4

-rw-r--r--. 1 root root 874044 Sep 20 2014apr-util-1.5.4.tar.gz

drwxr-xr-x.11 yumw games 4096 Sep 12 03:04httpd-2.4.23

-rw-r--r--. 1 root root 8406575 Jul 5 03:50httpd-2.4.23.tar.gz

-rw-r--r--. 1 root root 2053336 Sep 12 03:18 pcre-8.38.tar.gz

解压并进行编译安装

[root@Centostools]# tar zxf pcre-8.38.tar.gz

[root@Centostools]# cd pcre-8.38

[root@Centospcre-8.38]# ./configure --prefix=/usr/local/pcre

[root@Centospcre-8.38]# make && make install

............................................................................................................................过程省略

重新切换到apache目录下执行前面的编译安装apache

[root@Centoshttpd-2.4.23]# ./configure

--prefix=/application/apache2.4.23\

--enable-deflate\

--enable-expires\

--enable-headers\

--enable-modules=most\

--enable-so\

--with-mpm=worker\

--enable-rewrite\

--with-apr=/usr/local/apr\

--with-apr-util=/usr/local/web/apr-util

--with-pcre=/usr/local/pcre/bin/pcre-config

............................................................................................................................过程省略

[root@Centoshttpd-2.4.23]#make && make install

............................................................................................................................过程省略

过程省略,注意查看是否有错误提示,否则到最后也无法安装成功

[root@Centoshttpd-2.4.23]# ln -s /application/apache2.4.23 /application/apache

便于后续使用,生产环境中常用这种配置

安装时指定版本号路径方便查看安装版本与后续升级,如果后续升级,只需将前面的软链接删除,重新创建一个新软链接即可

[root@Centoshttpd-2.4.23]# ls -l /application/

total 4

lrwxrwxrwx. 1 root root 25 Sep 12 03:44 apache -> /application/apache2.4.23

drwxr-xr-x.14 root root 4096 Sep 12 03:30 apache2.4.23

启动服务

[root@Centoshttpd-2.4.23]# cd ..

[root@Centostools]# /application/apache/bin/apachectl start

AH00557:httpd: apr_sockaddr_info_get() failed for Centos

AH00558:httpd: Could not reliably determine the server's fully qualified domain name,using 127.0.0.1. Set the 'ServerName' directive globally to suppress thismessage

httpd (pid34190) already running

服务启动成功,但由于没有DNS出现这种提示,解决方法如下(测试环境,实际生产环境中不存在这提示信息)

[root@Centos~]# vi/application/apache/conf/httpd.conf

#

# This isthe main Apache HTTP server configuration file. It contains the

#configuration directives that give the server its instructions.

# See<URL:; for detailed information.

............................................................................中间内容省略

# If yourhost doesn't have a registered DNS name, enter its IP address here.

ServerName ;localhost:80(192.168.1.2:80)

查看端口

[root@Centostools]# lsof -i tcp:80

COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME

httpd 34190 root 4u IPv6 46376 0t0 TCP *:http (LISTEN)

httpd 34191 daemon 4u IPv6 46376 0t0 TCP *:http (LISTEN)

httpd 34192 daemon 4u IPv6 46376 0t0 TCP *:http (LISTEN)

httpd 34193 daemon 4u IPv6 46376 0t0 TCP *:http (LISTEN)

查看进程

[root@Centostools]# ps -ef |grep httpd

root 34190 1 0 03:57 ? 00:00:00/application/apache2.4.23/bin/httpd -k start

daemon 34191 34190 0 03:57 ? 00:00:00/application/apache2.4.23/bin/httpd -k start

daemon 34192 34190 0 03:57 ? 00:00:00/application/apache2.4.23/bin/httpd -k start

daemon 34193 34190 0 03:57 ? 00:00:00/application/apache2.4.23/bin/httpd -k start

root 34320 1866 0 04:06 pts/0 00:00:00 grep httpd

关闭防火墙

[root@Centostools]# /etc/init.d/iptables stop

iptables:Setting chains to policy ACCEPT: filter [ OK ]

iptables:Flushing firewall rules: [ OK ]

iptables:Unloading modules: [ OK ]

[root@Centostools]# /etc/init.d/iptables status

iptables:Firewall is not running.

如果是生产环境,可以添加规则允许80端口即可

[root@Centostools]#iptables -I INPUT -p tcp --dport 80 -jACCEPT

[root@Centostools]# vi /etc/selinux/config

# This filecontrols the state of SELinux on the system.

# SELINUX=can take one of these three values:

# enforcing - SELinux security policy isenforced.

# permissive - SELinux prints warningsinstead of enforcing.

# disabled - No SELinux policy is loaded.

SELINUX=disalbed

#SELINUXTYPE= can take one of these two values:

# targeted - Targeted processes areprotected,

# mls - Multi Level Security protection.

SELINUXTYPE=targeted

打开IE浏览器直接输入 打开出现 it works 表示安装成功

[root@Centos~]# cd /application/apache/conf/

[root@Centosconf]# ls

extra httpd.conf index.html magic mime.types original

[root@Centosconf]# cat index.html

<html><body><h1>Itworks!</h1></body></html>

浏览器出现的内容就是读取这个文件的内容

至此,Apache服务安装配置完成,可以正常提供 http服务了

教程完毕,谢谢支持

标签: #apache路径访问