源码安装Apache服务

1.Yum install –y gcc*                            安装gcc环境

   Yum install –y openssl*                         安装openssl软件包

 

2.下载httpd源码包;

   Tar –xzvf httpd-2.2.9.tar.gz –C /usr/src        解压源码包到/usr/src目录中<源码包放置目录>

 

3.Mkdir –p /usr/local/apache2

 

4../configure  –prefix=/usr/local/apache2  –enable-so            配置编译选项

       –enable-rewrite  –enable-ssl  –with-ssl=/usr/lib  

       –enable-suexec  –with-suexec-caller=daemon

       –with-suexec-docroot=/usr/local/apache2

 

5.Make                                                                           编译服务器程序

 

6.Make install                                                                                 安装服务器程序

 

7./usr/local/apache2/bin/apachectl  start                                         启动httpd服务

 

8./usr/local/apache2/bin/apachectl  -t                                                    语法检测

 

更改httpd启动方式

1.将http脚本复制到/etc/rc.d/init.d这个目录下:

cp -a apachectl /etc/rc.d/init.d/httpd

 

2.vi httpd

#chkconfig: 345 70 70

#description: apache

 

3.添加httpd到启动项:

chkconfig –add httpd

 

4.查看是否有httpd服务:

chkconfig –list httpd

 

源码安装后Apache服务器的根目录:

/usr/local/apache2/

 

日志文件:

/usr/local/apache2/logs/

 

Httpd主配置文件

/usr/local/apache2/conf/httpd.conf

 

Hhttp服务器网页根目录

/usr/local/apache2/htdocs/

 

创建虚拟WEB主机

Cd /usr/local/apache2/htdocs/                                               创建虚拟目录benetcom

Mkdir benetcom

Cd benetcom

Cp /usr/local/apache2/htdocs/index.html ./                                   创建测试网页

Vi index.html                                                                      

 

Cd /usr/local/apache2/conf/                                                  增加虚拟主机配置

Vi httpd.conf

:r extra/httpd-vhosts.conf

80>

#    ServerAdmin webmaster@dummy-host.example.com

     DocumentRoot/usr/local/apache2/docs/benetcom

ServerName www.benet.com

#    ServerAlias www.dummy-host.example.com

ErrorLog “logs/benet.com-error_log”

CustomLog “logs/benet.com-access_log” common

 

RPM安装后的Apache配置文件具体位置

/etc/httpd/                                                                Apache服务程序根目录

/etc/httpd/conf/httpd.conf                                         主配置文件

/var/www/html                                                          网页文档默认根目录

/var/log/httpd/error_log                                            错误日志文件

/var/log/httpd/access_log                                           访问日志文件

发表评论

邮箱地址不会被公开。 必填项已用*标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据