https服務器的配置(一)編譯安裝apache2.4 (httpd)

關於https的配置無非是在apache的配置中開啓mod_ssl所以在編譯安裝的時候我們把這個給裝上去就行了

本章我們先安裝httpd


一、首先我們裝上編譯安裝的工具包

 

[root@CentOS6 ~]# yum -y install gccgcc-c++

 

[root@CentOS6 ~]# yum -y install make

 

 

apache官網下載httpd最新的版本是httpd-2.4.10

 

安裝時我們可以去參考文檔http://httpd.apache.org/docs/2.4/

官網給的安裝很簡單

Overview for the impatient

Download$ lynx http://httpd.apache.org/download.cgi
Extract$ gzip -d httpd-NN.tar.gz
$ tar xvf httpd-NN.tar
$ cd httpd-NN
Configure$ ./configure --prefix=PREFIX
Compile$ make
Install$ make install
Customize$ vi PREFIX/conf/httpd.conf
TestPREFIX/bin/apachectl -k start


NN mustbe replaced with the current version number, and PREFIX must be replaced with the filesystempath under which the server should be installed. If PREFIX is not specified, it defaults to /usr/local/apache2.

Eachsection of the compilation and installation process is described in more detailbelow, beginning with the requirements for compiling and installing Apachehttpd.

這是官網的原話

所以往下看

Requirements

The followingrequirements exist for building Apache httpd:

APR and APR-Util

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

Perl-CompatibleRegular Expressions Library (PCRE)

This library isrequired 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-configscript 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 toallow httpd to build against your installed copy of PCRE.

Disk Space

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

ANSI-C Compilerand Build System

Make sure youhave 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 makesure your vendor's compiler is ANSI compliant. In addition, your PATH mustcontain basic build tools such as make.

Accurate timekeeping

Elements of theHTTP protocol are expressed as the time of day. So, it's time to investigatesetting some time synchronization facility on your system. Usually thentpdate or xntpd programsare used for this purpose which are based on the Network Time Protocol (NTP).See the NTPhomepage for more details about NTP software and public timeservers.

Perl 5 [OPTIONAL]

For some of thesupport scripts like apxs or dbmmanage (which are written in Perl) thePerl 5 interpreter is required (versions 5.003 or newer are sufficient). If youhave 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 bythe configure script, you will not be able touse the affected support scripts. Of course, you will still be able to buildand use Apache httpd.

 

因此我們一步步來,

Make sure you have APR and APR-Util already installed onyour system

 

二、我們安裝apr apr-util

去官網下載這兩個包放到/usr/local/src下面

 

安裝apr

[root@CentOS6 src]#tar -xvf apr-1.5.1.tar.gz

 

 

[root@CentOS6 src]#cd apr-1.5.1

[[email protected]]# ./configure --prefix=/usr/local/apr

[[email protected]]# make

[[email protected]]# make install

 

三、同理apr-util也是這樣安裝

[root@CentOS6 src]#tar -xvf apr-util-1.5.4.tar.bz2

[root@CentOS6 src]#cd apr-util-1.5.4

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

 

四、Perl-Compatible Regular Expressions Library (PCRE)

 

This library is required but not longer bundled withhttpd

這個庫必須安裝因爲他不再和httpd捆綁安裝了

[root@CentOS6 src]#yum-y install pcre-devel

五、Disk Space

Make sure you have at least 50 MB of temporary free diskspace available.

 

確保你至少有50M可用空間

 

六、ANSI-C Compiler and Build System

安裝基本的庫上面已經安裝過了

 

七、Accurate time keeping

保證系統時間正確

八、Perl5 [OPTIONAL]

Per5可選,我們暫時不安裝

 

九、安裝apache

 

次過程我們會遇到configure: WARNING:OpenSSL version is too old

因此

[root@CentOS6 src]# yum install openssl-devel

[root@CentOS6 src]#tar xvf httpd-2.4.10.tar.gz

[root@CentOS6 src]#cd httpd-2.4.10

 

[root@CentOS6 httpd-2.4.10]./configure--prefix=/usr/local/apache --sysconfdir=/etc/httpd --enable-so --enable-rewrite--enable-ssl  --enable-cgi --enable-cgid--enable-modules=most --enable-mods-shared=most --enable-mpms-shared=all--with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util

 

好了htppd安裝完成

 

啓動的話,可以

[root@CentOS6 httpd-2.4.10] cd /usr/local/apache/bin

 

AH00557: httpd:apr_sockaddr_info_get() failed for CentOS6.4.hby.com

AH00558: httpd:Could not reliably determine the server's fully qualified domain name, using127.0.0.1. Set the 'ServerName' directive globally

[root@CentOS6 httpd-2.4.10]vim /etc/httpd/httpd.conf

 

修改ServerName

ServerName192.168.66.100我改成了我的IP

 

爲了方便在網上找一個httpd的啓動腳本這個我就不在寫了

十、增加環境變量

[[email protected]]# vim /etc/profile.d/httpd.sh

exportPATH=$PATH:/usr/local/apache/bin

 

十一、關閉防火牆和selinux

訪問下你的地址可以看到

 

It works

 

 


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章