Linux-编译安装http-实验
准备工作
1、关闭防火墙和SELinux
2、基础安装的系统,安装以下命令
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
3、下载httpd2.4,虚拟机下载可能会很慢,本机下载好上传的虚拟机中
[root@centos8/data]$wget https://dlcdn.apache.org/httpd/httpd-2.4.53.tar.bz2
4、查看下载或上传好的安装包,解压
[root@centos8/data]$ls httpd-2.4.53.tar.bz2 [root@centos8/data]$tar xf httpd-2.4.53.tar.bz2 [root@centos8/data]$ls httpd-2.4.53 httpd-2.4.53.tar.bz2
5、进入httpd-2.4.53目录查看
[root@centos8/data]$cd httpd-2.4.53/ [root@centos8/data/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
6、编译安装
1)建立安装目录
[root@centos8~]$midir /usr/local/apache2
2)安装
[root@centos8/data/httpd-2.4.53]$./configure --prefix=/usr/local/apache2/ --sysconfdir=/etc/httpd --enable-ssl #指定安装路径,配置文件路径 [root@centos8/data/httpd-2.4.53]$echo $? #检测生成编译文件是否成功 0 [root@centos8/data/httpd-2.4.53]$make [root@centos8/data/httpd-2.4.53]$echo $? 0 [root@centos8/data/httpd-2.4.53]$make install [root@centos8/data/httpd-2.4.53]$echo $? 0
7、配置环境
[root@centos8/data/httpd-2.4.53]$echo 'PATH=/usr/local/apache2/bin:$PATH' > /etc/profile.d/httpd.sh [root@centos8/data/httpd-2.4.53]$. /etc/profile.d/httpd.sh [root@centos8/data/httpd-2.4.53]$apachectl start AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using fe80::250:56ff:fe33:298d. Set the 'ServerName' directive globally to suppress this message [root@centos8/data/httpd-2.4.53]$
8、指定用apache用户运行
[root@centos8~]$clear [root@centos8~]$useradd -r -s /sbin/nologin -d /var/www -c Apache -u 48 apache [root@centos8~]$vim /etc/httpd/httpd.conf
[root@centos8~]$apachectl restart #配置生效和验证 AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using fe80::250:56ff:fe33:298d. Set the 'ServerName' directive globally to suppress this message [root@centos8~]$ps aux | tail -6 root 26483 0.0 0.0 0 0 ? I 14:02 0:00 [kworker/1:0-ata_sff] apache 26487 0.0 0.3 1321352 7728 ? Sl 14:02 0:00 /usr/local/apache2//bin/httpd -k start apache 26488 0.0 0.3 1321352 7728 ? Sl 14:02 0:00 /usr/local/apache2//bin/httpd -k start apache 26489 0.0 0.5 1321352 11808 ? Sl 14:02 0:00 /usr/local/apache2//bin/httpd -k start root 26575 0.0 0.1 58740 3828 pts/0 R+ 14:03 0:00 ps aux root 26576 0.0 0.0 7348 888 pts/0 S+ 14:03 0:00 tail -6
9浏览器访问