服务器如何编译安装Apache2.2.29
发布时间:2017-06-27 09:32:36
编译安装Apache2.2.29
1)下载apache
http://httpd.apache.org/
2)源码安装的步骤
1、解压软件源码包,并进入解压后的目录
2、./configure 预编译,也叫配置操作,源码安装的第一步,主要的作用是对即将安装的软件进行配置,比如安装路径、开启或关闭哪些功能。
3、make 编译操作,生成makefile文件,正式安装时以此为依据进行安装。
4、make install 正式安装。
3)正式安装apache
# tar zxvf httpd-2.2.29.tar.gz
# cd httpd-2.2.29
# yum install make gcc automake autoconf libtool -y
# ./configure --prefix=/usr/local/apache --enable-shared=max --enable-module=most --enable-so
config.status: creating support/phf_abuse_log.cgi
config.status: creating support/split-logfile
config.status: creating build/rules.mk
config.status: creating build/pkg/pkginfo
config.status: creating build/config_vars.sh
config.status: creating include/ap_config_auto.h
config.status: executing default commands
————预编译没有报错,成功。
# make
pd-2.2.29/srclib/apr/libapr-1.la -lrt -lcrypt -lpthread
make[1]: Leaving directory `/root/httpd-2.2.29'
————make无报错,成功。
# make install
mkdir /usr/local/apache/man
mkdir /usr/local/apache/man/man1
mkdir /usr/local/apache/man/man8
mkdir /usr/local/apache/manual
make[1]: Leaving directory `/root/httpd-2.2.29'
————安装成功
# /usr/local/apache/bin/apachectl start
httpd: apr_sockaddr_info_get() failed for VM_198_236_centos
httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
————启动apache,打开测试页面查看是否正常
————该提示对启动服务没影响,将该台服务器的主机名加到 /etc/hosts 中即可解决。
# hostname
VM_198_236_centos
# vi /etc/hosts
127.0.0.1 TENCENT64.site TENCENT64 VM_198_236_centos
# /usr/local/apache/bin/apachectl stop
# /usr/local/apache/bin/apachectl start
————启动apache无报错,测试页面正常,apache安装成功。
接下来进行源码安装PHP,请参考下面教程:
http://bbs.qcloud.com/forum.php?mod=viewthread&tid=4346&extra=page%3D1
Apache+PHP整合
# cp /usr/local/apache/conf/httpd.conf /usr/local/apache/conf/httpd.conf.backup
# vi /usr/local/apache/conf/httpd.conf
配置文件最后添加如下 :
<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>
<FilesMatch "\.ph(p[2-6]?|tml)$">
SetHandler application/x-httpd-php
</FilesMatch>
<FilesMatch "\.phps$">
SetHandler application/x-httpd-php-source
</FilesMatch>
# /usr/local/apache/bin/apachectl stop
# /usr/local/apache/bin/apachectl start
# vi /usr/local/apache/htdocs/test.php
<?php
phpinfo();
?>
浏览器测试页面:测试成功
Apache启动、停止、重启的方法
# /usr/local/apache/bin/apachectl start 启动
# /usr/local/apache/bin/apachectl stop 停止
# /usr/local/apache/bin/apachectl -k restart 重启动
# tail –f /usr/local/apache/logs/error_log 查看默认的错误日志
1)下载apache
http://httpd.apache.org/
2)源码安装的步骤
1、解压软件源码包,并进入解压后的目录
2、./configure 预编译,也叫配置操作,源码安装的第一步,主要的作用是对即将安装的软件进行配置,比如安装路径、开启或关闭哪些功能。
3、make 编译操作,生成makefile文件,正式安装时以此为依据进行安装。
4、make install 正式安装。
3)正式安装apache
# tar zxvf httpd-2.2.29.tar.gz
# cd httpd-2.2.29
# yum install make gcc automake autoconf libtool -y
# ./configure --prefix=/usr/local/apache --enable-shared=max --enable-module=most --enable-so
config.status: creating support/phf_abuse_log.cgi
config.status: creating support/split-logfile
config.status: creating build/rules.mk
config.status: creating build/pkg/pkginfo
config.status: creating build/config_vars.sh
config.status: creating include/ap_config_auto.h
config.status: executing default commands
————预编译没有报错,成功。
# make
pd-2.2.29/srclib/apr/libapr-1.la -lrt -lcrypt -lpthread
make[1]: Leaving directory `/root/httpd-2.2.29'
————make无报错,成功。
# make install
mkdir /usr/local/apache/man
mkdir /usr/local/apache/man/man1
mkdir /usr/local/apache/man/man8
mkdir /usr/local/apache/manual
make[1]: Leaving directory `/root/httpd-2.2.29'
————安装成功
# /usr/local/apache/bin/apachectl start
httpd: apr_sockaddr_info_get() failed for VM_198_236_centos
httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
————启动apache,打开测试页面查看是否正常
————该提示对启动服务没影响,将该台服务器的主机名加到 /etc/hosts 中即可解决。
# hostname
VM_198_236_centos
# vi /etc/hosts
127.0.0.1 TENCENT64.site TENCENT64 VM_198_236_centos
# /usr/local/apache/bin/apachectl stop
# /usr/local/apache/bin/apachectl start
————启动apache无报错,测试页面正常,apache安装成功。
接下来进行源码安装PHP,请参考下面教程:
http://bbs.qcloud.com/forum.php?mod=viewthread&tid=4346&extra=page%3D1
Apache+PHP整合
# cp /usr/local/apache/conf/httpd.conf /usr/local/apache/conf/httpd.conf.backup
# vi /usr/local/apache/conf/httpd.conf
配置文件最后添加如下 :
<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>
<FilesMatch "\.ph(p[2-6]?|tml)$">
SetHandler application/x-httpd-php
</FilesMatch>
<FilesMatch "\.phps$">
SetHandler application/x-httpd-php-source
</FilesMatch>
# /usr/local/apache/bin/apachectl stop
# /usr/local/apache/bin/apachectl start
# vi /usr/local/apache/htdocs/test.php
<?php
phpinfo();
?>
浏览器测试页面:测试成功
Apache启动、停止、重启的方法
# /usr/local/apache/bin/apachectl start 启动
# /usr/local/apache/bin/apachectl stop 停止
# /usr/local/apache/bin/apachectl -k restart 重启动
# tail –f /usr/local/apache/logs/error_log 查看默认的错误日志