2014-05-05 16:16:01 (574 KB/s) - 已保存 “httpd-2.4.7.tar.gz” [6747087/6747087])
[root@cache-2 ~]# wget --2014-05-05 16:15:48-- 正在解析主机 archive.apache.org... 192.87.106.229, 140.211.11.131, 2001:610:1:80bc:192:87:106:229 正在连接 archive.apache.org|192.87.106.229|:80... 已连接。 已发出 HTTP 请求,正在等待回应... 200 OK 长度:6747087 (6.4M) [application/x-gzip] 正在保存至: “httpd-2.4.7.tar.gz” 1% [=> .............................................................. 2014-05-05 16:16:01 (574 KB/s) - 已保存 “httpd-2.4.7.tar.gz” [6747087/6747087])
开始安装:
tar -xvf httpd-2.4.7.tar.gz
cd httpd-2.4.7
./configure --prefix=/usr/local/apache2
make && make install
[root@cache-2 ~]# tar -xvf httpd-2.4.7.tar.gz
[root@cache-2 ~]# cd httpd-2.4.7
[root@cache-2 httpd-2.4.7]# ./configure --prefix=/usr/local/apache2
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.
Google之后,发现可能是gcc版本太低了,可能是apache版本太高,换低点的2.2.23版本吧。
wget http://archive.apache.org/dist/httpd/httpd-2.2.23.tar.gz
tar -xvf httpd-2.2.23.tar.gz
cd httpd-2.2.23
./configure --prefix=/usr/local/apache2
make && make install
[root@cache-2 ~]# tar -xvf httpd-2.4.7.tar.gz [root@cache-2 ~]# cd httpd-2.4.7 [root@cache-2 httpd-2.4.7]# ./configure --prefix=/usr/local/apache2 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. Google之后,发现可能是gcc版本太低了,可能是apache版本太高,换低点的2.2.23版本吧。 wget tar -xvf httpd-2.2.23.tar.gz cd httpd-2.2.23 ./configure --prefix=/usr/local/apache2 make && make install(2) 安装php版本
wget
tar -xvf php-5.4.26.tar.gz
cd php-5.4.26
./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs
有报错信息:
Configuring extensions
checking size of long... (cached) 8
checking size of int... (cached) 4
checking for int32_t... yes
checking for uint32_t... yes
checking for sys/types.h... (cached) yes
checking for inttypes.h... (cached) yes
checking for stdint.h... (cached) yes
checking for string.h... (cached) yes
checking for stdlib.h... (cached) yes
checking for strtoll... yes
checking for atoll... yes
checking for strftime... (cached) yes
checking which regex library to use... php
checking whether to enable LIBXML support... yes
checking libxml2 install dir... no
checking for xml2-config path...
configure: error: xml2-config not found. Please check your libxml2 installation.
需要重新安装lib包
yum install libxml2 –y
yum install libxml2-devel –y
之后继续make,成功了:
Make && make install
[activating module `php5' in /usr/local/apache2/conf/httpd.conf]
Installing PHP CLI binary: /usr/local/php/bin/
Installing PHP CLI man page: /usr/local/php/php/man/man1/
Installing PHP CGI binary: /usr/local/php/bin/
Installing PHP CGI man page: /usr/local/php/php/man/man1/
Installing build environment: /usr/local/php/lib/php/build/
Installing header files: /usr/local/php/include/php/
Installing helper programs: /usr/local/php/bin/
program: phpize
program: php-config
Installing man pages: /usr/local/php/php/man/man1/
page: phpize.1
page: php-config.1
Installing PEAR environment: /usr/local/php/lib/php/
[PEAR] Archive_Tar - installed: 1.3.11
[PEAR] Console_Getopt - installed: 1.3.1
warning: pear/PEAR requires package "pear/Structures_Graph" (recommended version 1.0.4)
warning: pear/PEAR requires package "pear/XML_Util" (recommended version 1.2.1)
[PEAR] PEAR - installed: 1.9.4
Wrote PEAR system config file at: /usr/local/php/etc/pear.conf
You may want to add: /usr/local/php/lib/php to your php.ini include_path
[PEAR] Structures_Graph- installed: 1.0.4
[PEAR] XML_Util - installed: 1.2.1
/root/php/php-5.4.26/build/shtool install -c ext/phar/phar.phar /usr/local/php/bin
ln -s -f /usr/local/php/bin/phar.phar /usr/local/php/bin/phar
Installing PDO headers: /usr/local/php/include/php/ext/pdo/
(3) 配置apache
Apache的配置文件在 /usr/local/apache2/conf/httpd.conf ,vim打开
将
User daemon
Group daemon
修改成:
User nagios
Group nagios
将
<IfModule dir_module>
DirectoryIndex index.html
</IfModule>
修改成:
<IfModule dir_module>
DirectoryIndex index.html index.php
AddType application/x-httpd-php .php
</IfModule>
为了安全起见:nagios的web监控页面需要经过授权才能访问,这需要增加验证配置,即在httpd.conf 文件最后添加如下信息:
#setting for nagios
ScriptAlias /nagios/cgi-bin "/usr/local/nagios/sbin"
<Directory "/usr/local/nagios/sbin">
AuthType Basic
Options ExecCGI
AllowOverride None
Order allow,deny
Allow from all
AuthName "Nagios Access"
AuthUserFile /usr/local/nagios/etc/htpasswd //用于此目录访问身份验证的文件
Require valid-user
</Directory>
Alias /nagios "/usr/local/nagios/share"
<Directory "/usr/local/nagios/share">
AuthType Basic
Options None
AllowOverride None
Order allow,deny
Allow from all
AuthName "nagios Access"
AuthUserFile /usr/local/nagios/etc/htpasswd
Require valid-user
</Directory>
(4) 创建apache目录验证文件
在上面的配置中,指定了目录验证文件htpasswd,下面要创建这个文件:
/usr/local/apache2/bin/htpasswd -c /usr/local/nagios/etc/htpasswd david
[root@cache-2 php-5.4.26]# /usr/local/apache2/bin/htpasswd -c /usr/local/nagios/etc/htpasswd david
New password:
Re-type new password:
Adding password for user david
查看认证文件的内容:
[root@cache-2 php-5.4.26]# cat /usr/local/nagios/etc/htpasswd
david:$apr1$Pf9XIJjd$m5hR2vw70MlqwrChgN7zc/
[root@cache-2 php-5.4.26]#
启动apache服务:
/usr/local/apache2/bin/apachectl start
[root@cache-2 php-5.4.26]# /usr/local/apache2/bin/apachectl start
httpd: Could not reliably determine the server's fully qualified domain name, using 10.254.3.41 for ServerName
(98)Address already in use: make_sock: could not bind to address [::]:80
(98)Address already in use: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs
修改ServerName以及Port
vi /usr/local/apache2/conf/httpd.conf
ServerName 改成 10.xx.3.x1
Listen 80 改成 Listen 81
:81/nagios/,可以打开了,如下所示: