日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪(fǎng)問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 运维知识 > linux >内容正文

linux

Linux系统安装Apache 2.4.6

發(fā)布時(shí)間:2023/12/13 linux 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Linux系统安装Apache 2.4.6 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

http://www.cnblogs.com/kerrycode/p/3261101.html

Apache簡(jiǎn)介

?

??????? Apache HTTP Server(簡(jiǎn)稱(chēng)Apache)是Apache軟件基金會(huì)的一個(gè)開(kāi)放源碼的網(wǎng)頁(yè)服務(wù)器,可以在大多數(shù)計(jì)算機(jī)操作系統(tǒng)中運(yùn)行,由于其多平臺(tái)和安全性被廣泛使用,是最流行的Web服務(wù)器端軟件之一。它快速、可靠并且可通過(guò)簡(jiǎn)單的API擴(kuò)展,將Perl/Python等解釋器編譯到服務(wù)器中。關(guān)于更多Apache的介紹,可以參考百科“http://baike.baidu.com/view/28283.htm或官網(wǎng)http://www.apache.org/?或?http://httpd.apache.org/的介紹

?

Apache軟件下載

??Apache的相關(guān)軟件包下載地址http://apr.apache.org/projects.html

1.?? Apache HTTP Server

????截止目前為止,Apache HTTP Server 目前最新的版本是 Apache httpd 2.4.6 Released, 下載地址:http://httpd.apache.org/download.cgi#apache24

2.?? APR and APR-Util包

??? 截止目前為止,APR and APR-Util的最新版本如下,下載地址:http://apr.apache.org/download.cgi

  • APR 1.4.8, released June 21, 2013
  • APR-util 1.5.2, released April 4, 2013
  • APR-iconv 1.2.1, released November 26, 2007

3.?? PCRE包

???截止目前為止,PCRE最新的包為8.33,下載地址如下

  • https://sourceforge.net/projects/pcre/files/pcre/

?

? 可以下載了相關(guān)安裝包,上傳到/root/kerry這個(gè)臨時(shí)目錄。也可以直接通過(guò)wget下載

Apache安裝要求

下面是官方文檔的要求,必須安裝APR、APR-Util、PCRE,gcc-c++等包,文檔URL地址http://httpd.apache.org/docs/2.4/install.html

?

Requirements

The following requirements exist for building Apache httpd:

APR and APR-Util

Make sure you have APR and APR-Util already installed on your system. If you don't, or prefer to not use the system-provided versions, download the latest versions of both APR and APR-Util from?Apache APR, unpack them into ./srclib/apr and ./srclib/apr-util (be sure the directory names do not have version numbers; for example, the APR distribution must be under ./srclib/apr/) and use ./configure's --with-included-apr option. On some platforms, you may have to install the corresponding -dev packages to allow httpd to build against your installed copy of APR and APR-Util.

Perl-Compatible Regular Expressions Library (PCRE)

This library is required but not longer bundled with httpd. Download the source code from?http://www.pcre.org, or install a Port or Package. If your build system can't find the pcre-config script installed by the PCRE build, point to it using the --with-pcre parameter. On some platforms, you may have to install the corresponding -dev package to allow httpd to build against your installed copy of PCRE.

Disk Space

Make sure you have at least 50 MB of temporary free disk space available. After installation the server occupies approximately 10 MB of disk space. The actual disk space requirements will vary considerably based on your chosen configuration options, any third-party modules, and, of course, the size of the web site or sites that you have on the server.

ANSI-C Compiler and Build System

Make sure you have an ANSI-C compiler installed. The?GNU C compiler (GCC)?from the?Free Software Foundation (FSF)is recommended. If you don't have GCC then at least make sure your vendor's compiler is ANSI compliant. In addition, your PATH must contain basic build tools such as make.

Accurate time keeping

Elements of the HTTP protocol are expressed as the time of day. So, it's time to investigate setting some time synchronization facility on your system. Usually thentpdate or xntpd programs are used for this purpose which are based on the Network Time Protocol (NTP). See the?NTP homepage?for more details about NTP software and public time servers.

Perl 5?[OPTIONAL]

For some of the support scripts like?apxs?or?dbmmanage?(which are written in Perl) the Perl 5 interpreter is required (versions 5.003 or newer are sufficient). If you have multiple Perl interpreters (for example, a systemwide install of Perl 4, and your own install of Perl 5), you are advised to use the --with-perl option (see below) to make sure the correct one is used by?configure. If no Perl 5 interpreter is found by the?configure?script, you will not be able to use the affected support scripts. Of course, you will still be able to build and use Apache httpd.

?

Apache安裝過(guò)程

?

Step 1:安裝包gccgcc-c++

[root@getlnx05 pcre-8.33]# yum list gcc-c++

Loaded plugins: product-id, security, subscription-manager

Updating Red Hat repositories.

Available Packages

gcc-c++.x86_64?????????????????????????????????????????????????????????????? 4.1.2-51.el5??????????????????????????????????????????????????????????????? rhel-debuginfo

[root@getlnx05 pcre-8.33]# yum list gcc

Loaded plugins: product-id, security, subscription-manager

Updating Red Hat repositories.

Installed Packages

gcc.x86_64??????????????????????????????????????????????????????????????????? 4.1.2-51.el5??????????????????????????????????????????????????????????????????? installed

[root@getlnx05 pcre-8.33]# rpm -q gcc

gcc-4.1.2-51.el5

從上面可見(jiàn)gcc包已經(jīng)安裝,缺少gcc-c++包,那么接下來(lái)安裝包gcc-c++,如果此處不安裝該包,后面安裝過(guò)程中會(huì)報(bào)錯(cuò)

[root@getlnx05 pcre-8.33]#yum install? gcc-c++

?

Step 2:安裝包APRAPR-Util

[root@getlnx05 kerry]# ls apr*

apr-1.4.8.tar.gz? apr-util-1.5.2.tar.gz

[root@getlnx05 kerry]#

[root@getlnx05 kerry]# tar -zxf apr-1.4.8.tar.gz

[root@getlnx05 kerry]# cd apr-1.4.8

[root@getlnx05 apr-1.4.8]# ls

新建目錄/usr/local/apr,用作安裝目錄:

[root@getlnx05 apr-1.4.8]# mkdir /usr/local/apr

[root@getlnx05 apr-1.4.8]# ./configure --prefix=/usr/local/apr

[root@getlnx05 apr-1.4.8]# make

[root@getlnx05 apr-1.4.8]# make install

安裝完成后,可以驗(yàn)證一下

[ root@getlnx05 apr]# ls -lrt

total 32

drwxr-xr-x 3 root root 4096 Aug 15 06:57 include

drwxr-xr-x 3 root root 4096 Aug 15 06:57 lib

drwxr-xr-x 2 root root 4096 Aug 15 06:57 build-1

drwxr-xr-x 2 root root 4096 Aug 15 06:57 bin

[root@getlnx05 kerry]# mkdir /usr/local/apr-util

[root@getlnx05 kerry]# tar -zxf apr-util-1.5.2.tar.gz

[root@getlnx05 kerry]# cd apr-util-1.5.2

[root@getlnx05 apr-util-1.5.2]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/bin/apr-1-config

[root@getlnx05 apr-util-1.5.2]# make

[root@getlnx05 apr-util-1.5.2]# make install

?

Step 3:安裝包PRCE

[root@getlnx05 kerry]# unzip pcre-8.33.zip

[root@getlnx05 kerry]# cd pcre-8.33

[root@getlnx05 kerry]#mkdir /usr/local/pcre

[root@getlnx05 pcre-8.33]# ./configure --prefix= /usr/local/pcre--with-apr=/usr/local/apr/bin/apr-1-config

[root@getlnx05 pcre-8.33]# make

[root@getlnx05 pcre-8.33]# make install

?

Step 4:安裝Apache Http Server

[root@getlnx05 kerry]# tar zxvf httpd-2.4.6.tar.gz

[root@getlnx05? kerry]#cd httpd-2.4.6

[root@getlnx05 httpd-2.4.6]# ./configure --prefix=/usr/local/apache --with-pcre=/usr/local/pcre --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util

[root@getlnx05 httpd-2.4.6]#make

[root@getlnx05 httpd-2.4.6]#make install

Step 5:啟動(dòng)Apache服務(wù)

[root@getlnx05 httpd-2.4.6]#? /usr/local/apache/bin/apachectl start

用瀏覽器訪(fǎng)問(wèn)http://localhost時(shí)提示It works!

?

?

Apache安裝問(wèn)題錦集

?

問(wèn)題1:缺少包gcc-c++導(dǎo)致安裝包apr-util不通過(guò)

?

[root@getlnx05 kerry]# unzip pcre-8.33.zip

[root@getlnx05 kerry]# cd pcre-8.33

[root@getlnx05 pcre-8.33]# ./configure --prefix=/usr/local/apr-util -with-apr=/usr/local/apr/bin/apr-1-config

一般出現(xiàn)這個(gè)錯(cuò)誤是因?yàn)闆](méi)有安裝包gcc-c++,可以通過(guò)如下命令檢查,

[root@getlnx05 pcre-8.33]# yum list gcc-c++

Loaded plugins: product-id, security, subscription-manager

Updating Red Hat repositories.

Available Packages

gcc-c++.x86_64?????????????????????????????????????????????????????????????? 4.1.2-51.el5??????????????????????????????????????????????????????????????? rhel-debuginfo

[root@getlnx05 pcre-8.33]# yum list gcc

Loaded plugins: product-id, security, subscription-manager

Updating Red Hat repositories.

Installed Packages

gcc.x86_64??????????????????????????????????????????????????????????????????? 4.1.2-51.el5??????????????????????????????????????????????????????????????????? installed

[root@getlnx05 pcre-8.33]# rpm -q gcc

gcc-4.1.2-51.el5

[root@getlnx05 pcre-8.33]# rpm -q gcc-c++

?

問(wèn)題2:checking for APR-util... configure: error: the --with-apr-util parameter is incorrect

[root@getlnx05 httpd-2.4.6]#? ./configure --prefix=/usr/local/apache? --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util

checking for chosen layout... Apache

checking for working mkdir -p... yes

checking for grep that handles long lines and -e... /bin/grep

checking for egrep... /bin/grep -E

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

configure:

configure: Configuring Apache Portable Runtime library...

configure:

checking for 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:

checking for APR-util... configure: error: the --with-apr-util parameter is incorrect. It must specify an install prefix, a build directory, or an apu-config file.

[root@getlnx05 httpd-2.4.6]#

一般是由于APR-util沒(méi)有安裝成功,可以通過(guò)驗(yàn)證該目錄是否為空來(lái)判斷,因?yàn)槟阌袝r(shí)候執(zhí)行了make,忘了執(zhí)行make isntall命令有可能導(dǎo)致這個(gè)錯(cuò)誤。

[root@getlnx05 apr]# cd /usr/local/apr-util

[root@getlnx05 apr-util]# ls

?

問(wèn)題3:沒(méi)有指定PCRE參數(shù)

[root@getlnx05 httpd-2.4.6]#? ./configure --prefix=/usr/local/apache? --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util

checking for chosen layout... Apache

checking for working mkdir -p... yes

checking for grep that handles long lines and -e... /bin/grep

checking for egrep... /bin/grep -E

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

configure:

configure: Configuring Apache Portable Runtime library...

configure:

checking for 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:

checking for APR-util... yes

checking for gcc... gcc

checking whether the C compiler works... yes

checking for C compiler default output file name... a.out

checking for suffix of executables...

checking whether we are cross compiling... no

checking for suffix of object files... o

checking whether we are using the GNU C compiler... yes

checking whether gcc accepts -g... yes

checking for gcc option to accept ISO C89... none needed

checking how to run the C preprocessor... gcc -E

checking for gcc option to accept ISO C99... -std=gnu99

checking for pcre-config... false

configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/

[root@getlnx05 httpd-2.4.6]#

?

問(wèn)題4:安裝前忘了先安裝APR相關(guān)包

[root@getlnx05 httpd-2.4.6]#? ./configure --prefix=/usr/local/appache/

checking for chosen layout... Apache

checking for working mkdir -p... yes

checking for grep that handles long lines and -e... /bin/grep

checking for egrep... /bin/grep -E

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

configure:

configure: Configuring Apache Portable Runtime library...

configure:

checking for APR... no

configure: error: APR not found.? Please read the documentation.

[root@getlnx05 httpd-2.4.6]#

?

問(wèn)題5:啟動(dòng)服務(wù)時(shí)報(bào)錯(cuò)

[root@getlnx05 httpd-2.4.6]#? /usr/local/apache/bin/apachectl start

AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using getlnx05.gfg1.esquel.com. Set the 'ServerName' directive globally to suppress this message

這個(gè)時(shí)候需要編輯httpd.conf配置文件,添加SeraverName的具體IP地址。如下所示

[root@getlnx05 conf]# cd /usr/local/apache/conf/

[root@getlnx05 conf]# ls

extra? httpd.conf? magic? mime.types? original

[root@getlnx05 conf]# vi httpd.conf

ServerAdmin you@example.com

#

# ServerName gives the name and port that the server uses to identify itself.

# This can often be determined automatically, but we recommend you specify

# it explicitly to prevent problems during startup.

#

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

#

#ServerName www.example.com:80

ServerName 192.168.9.122:80

#

# Deny access to the entirety of your server's filesystem. You must

# explicitly permit access to web content directories in other

# <Directory> blocks below.

#

"httpd.conf" 502L, 18179C written

[root@getlnx05 conf]# /usr/local/apache/bin/apachectl restart

httpd not running, trying to start

[root@getlnx05 conf]# /usr/local/apache/bin/apachectl start

httpd (pid 7797) already running

如果從其它電腦連接訪(fǎng)問(wèn)Apache時(shí),輸入url地址:http://192.168.9.122頁(yè)面沒(méi)有顯示正常,而上面配置也OK,那么你必須關(guān)閉防火墻,有時(shí)候甚至需要重啟電腦才能OK,重啟Apache服務(wù)都無(wú)效。

[root@getlnx05 conf]# chkconfig iptables off

[root@getlnx05 conf]# chkconfig iptables off

[root@getlnx05 conf]# /usr/local/apache/bin/apachectl restart

[root@getlnx05 conf]# /usr/local/apache/bin/apachectl restart

[root@getlnx05 conf]#

轉(zhuǎn)載于:https://www.cnblogs.com/hyl8218/p/7543404.html

總結(jié)

以上是生活随笔為你收集整理的Linux系统安装Apache 2.4.6的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。