Apache httpd服务——安装

时间:2021-08-14 15:48:36

Apache httpd服务——安装

yum安装

安装:

yum -y install httpd

配置文件:

/etc/httpd/conf/httpd.conf

 和 

/etc/httpd/conf.d/*.conf 

下所有以.conf结尾的文件

服务控制:

systemctl start|restart|stop|reload httpd

站点网页文档根目录:

/var/www/html

模块文件路径:

/usr/lib64/httpd/modules

主程序文件:

/usr/sbin/httpd

主进程文件:

/run/httpd/httpd.pid

日志文件目录:

/var/log/httpd

离线帮助文档包:

yum -y install httpd-manual

重启服务后在浏览器中输入 http://IP/manual/ 即可使用

编译安装

系统环境:CentOS6.9

arp版本:1.6 # wget http://mirror.bit.edu.cn/apache//apr/apr-1.6.3.tar.gz

arp-util版本:1.6 # wget http://mirror.bit.edu.cn/apache//apr/apr-util-1.6.1.tar.gz

httpd版本:2.4 # wget http://mirrors.shu.edu.cn/apache//httpd/httpd-2.4.33.tar.gz

​ 1)安装需要的包

~]# yum -y groupinstall "Development tools"
~]# yum -y install openssl-devel expat-devel pcre-devel

​ 2)配置编译安装

~]# tar xf apr-1.6.3.tar.gz
~]# tar xf apr-util-1.6.1.tar.gz
~]# tar xf httpd-2.4.33.tar.gz
~]# cp -a apr-util-1.6.1 httpd-2.4.33/srclib/apr-util
~]# cp -a apr-1.6.3 httpd-2.4.33/srclib/apr
~]# cd httpd-2.4.33
httpd-2.4.33]# ./configure --prefix=/data/httpd24 \
 --enable-so \
 --enable-ssl \
 --enable-cgi \
 --enable-rewrite \
 --with-zlib \
 --with-pcre  \
 --with-included-apr \
 --enable-modules=most \
 --enable-mpms-shared=all \
 --with-mpm=prefork
httpd-2.4.33]# make -j 4 && make install

​ 3)配置环境变量

~]# echo 'export PATH=/data/httpd24/bin:$PATH' > /etc/profile.d/httpd.sh
~]# echo 'MANPATH /data/httpd24/man' >> /etc/man.config
~]# source /etc/profile.d/httpd.sh
~]# source /etc/man.config

4)启动服务并测试

~]# apachectl start