快捷搜索:  汽车  科技

apache源码安装教程:Apache的基本配置及安装

apache源码安装教程:Apache的基本配置及安装[root@httpd /]# setenforce 0[root@httpd /]# systemctl stop firewalld.service4.在客户机永www.自己姓名.com访问实验步骤:关闭防火墙和selinux

实验目的:

1.编译安装httpd

2.优化路径

3.创建一个以自己姓名命名的目录,并在在其中创建一个index.html网页,并将此目录做为网页目录

4.在客户机永www.自己姓名.com访问

实验步骤:

关闭防火墙和selinux

[root@httpd /]# systemctl stop firewalld.service

[root@httpd /]# setenforce 0

[root@httpd /]# systemctl disable firewalld.service

检测是否安装httpd

[root@httpd /]# rpm -e httpd --nodeps

错误:未安装软件包 httpd

挂着系统光盘进行安装httpd依赖包

[root@localhost ~]# mount /dev/cdrom /mnt

rpm -ivh /mnt/Packages/apr-1.4.8-3.el7.x86_64.rpm

rpm -ivh /mnt/Packages/apr-devel-1.4.8-3.el7.x86_64.rpm

rpm -ivh /mnt/Packages/cyrus-sasl-devel-2.1.26-20.el7_2.x86_64.rpm

rpm -ivh /mnt/Packages/expat-devel-2.1.0-8.el7.x86_64.rpm

rpm -ivh /mnt/Packages/libdb-devel-5.3.21-19.el7.x86_64.rpm

rpm -ivh /mnt/Packages/openldap-devel-2.4.40-13.el7.x86_64.rpm

rpm -ivh /mnt/Packages/apr-util-devel-1.5.2-6.el7.x86_64.rpm

rpm -ivh /mnt/Packages/apr-util-1.5.2-6.el7.x86_64.rpm

rpm -ivh /mnt/Packages/pcre-devel-8.32-15.el7_2.1.x86_64.rpm

rpm -ivh /mnt/Packages/pcre-8.32-15.el7_2.1.x86_64.rpm

上传httpd的压缩包,开始源码编译安装!!!

apache源码安装教程:Apache的基本配置及安装(1)

[root@httpd /]# tar zxf httpd-2.4.25.tar.gz -C /usr/src/

[root@httpd /]# cd /usr/src/httpd-2.4.25/

配置:根据服务器的实际应用需要,灵活配置

./configure --prefix=/usr/local/httpd --enable-so --enable-rewrite --enable-charset-list --enable-cgi

编译和安装

[root@httpd httpd-2.4.25]# make && make install

优化执行路径

[root@httpd httpd-2.4.25]# ln -s /usr/local/httpd/bin/* /usr/local/bin

[root@httpd httpd-2.4.25]# httpd -v 查看程序版本

Server version: Apache/2.4.25 (Unix)

Server built: Aug 4 2020 17:05:56

添加系统服务

[root@httpd httpd-2.4.25]# cp /usr/local/httpd/bin/apachectl /etc/init.d/httpd

[root@httpd httpd-2.4.25]# cd /etc/init.d/

[root@httpd init.d]# vim httpd

在第二行插入:

#chkconfig: 35 85 21

[root@httpd init.d]# chkconfig --add httpd

[root@httpd init.d]# systemctl start httpd

[root@httpd init.d]# netstat -anput | grep httpd

tcp6 0 0 :::80 :::* LISTEN 62581/httpd

配置httpd服务,查找servername设置一个网站名称

199 ServerName www.web.com:80

检测语句是否正确

[root@httpd init.d]# apachectl -t

Syntax OK

部署网页文档

[root@httpd init.d]# echo "web" >> /usr/local/httpd/htdocs/index.html

[root@httpd init.d]# cat /usr/local/httpd/htdocs/index.html

<html><body><h1>It works!</h1></body></html>

Web

在客户机进行访问测试

apache源码安装教程:Apache的基本配置及安装(2)

查看web站点的访问情况

[root@localhost ~]# tail /usr/local/httpd/logs/access_log

127.0.0.1 - - [04/Aug/2020:17:45:13 0800] "GET / HTTP/1.1" 200 45

127.0.0.1 - - [04/Aug/2020:17:45:13 0800] "GET /favicon.ico HTTP/1.1" 404 209

127.0.0.1 - - [04/Aug/2020:17:45:13 0800] "GET /favicon.ico HTTP/1.1" 404 209

猜您喜欢: