http服务的部署

准备工作

关闭防火墙

systemctl disable --now firewalld

基础服务安装

yum install  gcc make autoconf gcc-c++ glibc glibc-devel pcre pcre-devel openssl openssl-devel systemd-devel zlib-devel  vim lrzsz tree tmux lsof tcpdump wget net-tools iotop bc bzip2 zip unzip nfs-utils man-pages apr-devel apr-util-devel gcc pcre-devel openssl-devel 

下载 httpd 2.4

wget https://dlcdn.apache.org/httpd/httpd-2.4.53.tar.bz2

解压缩

[20:28:47 root@localhost[ data]#tar xvf httpd-2.4.53.tar.bz2 -C /usr/local/src
[20:31:04 root@localhost[ data]#cd /usr/local/src
[20:31:08 root@localhost[ src]#ls
httpd-2.4.53

进入httpd-2.4.53查看目录

[root@localhost httpd2.4]# cd httpd-2.4.53
[root@localhost httpd-2.4.53]# ls
ABOUT_APACHE     BuildBin.dsp     docs         InstallBin.dsp  modules           ROADMAP
acinclude.m4     buildconf        emacs-style  LAYOUT          NOTICE            server
Apache-apr2.dsw  CHANGES          httpd.dep    libhttpd.dep    NWGNUmakefile     srclib
Apache.dsw       changes-entries  httpd.dsp    libhttpd.dsp    os                support
apache_probes.d  CMakeLists.txt   httpd.mak    libhttpd.mak    README            test
ap.d             config.layout    httpd.spec   LICENSE         README.CHANGES    VERSIONING
build            configure        include      Makefile.in     README.cmake
BuildAll.dsp     configure.in     INSTALL      Makefile.win    README.platforms

编译安装

安装

[20:45:26 root@localhost[ httpd-2.4.53]#./configure --prefix=/apps/httpd --sysconfdir=/etc/httpd --enable-ssl #指定安装路径,以及配置文件路径
[21:12:44 root@localhost[ httpd-2.4.53]#echo $?
0
[21:14:29 root@localhost[ httpd-2.4.53]#make
gcc: error: /usr/lib/rpm/redhat/redhat-hardened-ld: No such file or directory
make[4]: *** [/usr/local/src/httpd-2.4.53/modules/aaa/modules.mk:2:mod_authn_file.la] 错误 1
make[4]: 离开目录“/usr/local/src/httpd-2.4.53/modules/aaa”
make[3]: *** [/usr/local/src/httpd-2.4.53/build/rules.mk:117:shared-build-recursive] 错误 1
[22:00:33 root@localhost httpd-2.4.53]#yum provides /usr/lib/rpm/redhat/redhat-hardened-ld
上次元数据过期检查:0:16:25 前,执行于 2022年05月30日 星期一 21时48分23秒。
redhat-rpm-config-125-1.el8.noarch : Red Hat specific rpm configuration files
仓库        :AppStream
匹配来源:
文件名    :/usr/lib/rpm/redhat/redhat-hardened-ld
[22::29 root@localhost[ httpd-2.4.53]#make
[22:07:47 root@localhost httpd-2.4.53]#echo $?
0
[22::29 root@localhost[ httpd-2.4.53]#make install
[22:08:50 root@localhost httpd-2.4.53]#echo $?
0

配置环境

[22:12:18 root@localhost ~]#echo 'PATH=/apps/httpd/bin:$PATH' > /etc/profile.d/httpd.sh
[22:14:12 root@localhost ~]#. /etc/profile.d/httpd.sh 

指定用apache用户运行

[22:14:34 root@localhost ~]#useradd -r -s /sbin/nologin -d /var/www -c Apache -u 48 apache
[22:19:06 root@localhost ~]#vim /etc/httpd/httpd.conf
user apache
group apache
#ServerName www.example.com:80 需要去点#号
[22:19:06 root@localhost ~]#apachectl restart           #配置生效和验证

posted @ 2022-06-20 10:37  醉酒画忧愁  阅读(121)  评论(0编辑  收藏  举报