手工编译安装实验
文章目录
手工编译安装实验查看命令,ls -l解压tar压缩包命令,tar -zxvf后续一次解压其余两个软件包进入/opt目录并进行查看然后回到/opt目录,查看一下安装依赖环境配置./configure编译makemake install进入conf目录再搜索一下server,将198行的#号去除开启apachectl查看80接口再次查看htdocs 网页目录,修改首页index配置打开IP网页地址![在这里插入图片描述](https://img-blog.csdnimg.cn/20200703231351242.png)
因为使用的是xshell软件,可以直接将Windows中的软件包,通过拖拽到xshell中进行使用
查看命令,ls -l
可以 查看到软件包
[root@localhost ~]# ls -l
总用量 9988
-rw-------. 1 root root 1257 7月 2 18:43 anaconda-ks.cfg
-rw-r--r--. 1 root root 982243 7月 2 19:12 apr-1.4.6.tar.gz
-rw-r--r--. 1 root root 774770 7月 2 19:12 apr-util-1.4.1.tar.gz
-rw-r--r--. 1 root root 8460433 7月 2 19:12 httpd-2.4.25.tar.gz
解压tar压缩包命令,tar -zxvf
我这边将压缩包解压到/opt目录中,在命令末尾需要加上-C /opt
[root@localhost ~]# tar -zxvf httpd-2.4.25.tar.gz -C /opt
后续一次解压其余两个软件包
tar -zxvf apr-1.4.6.tar.gz -C /opt
tar -zxvf apr-util-1.4.1.tar.gz -C /opt
进入/opt目录并进行查看
[root@localhost ~]# cd /opt
[root@localhost opt]# ll
总用量 12
drwxr-sr-x. 25 5000 10001 4096 2月 8 2012 apr-1.4.6
drwxr-xr-x. 19 501 games 4096 12月 8 2011 apr-util-1.4.1
drwxr-xr-x. 11 501 games 4096 12月 17 2016 httpd-2.4.25
然后
我们将apr-1.4.6和apr-util-1.4.1两个包,添加到httpd-2.4.25中
[root@localhost opt]# mv apr-1.4.6/ httpd-2.4.25/srclib/apr
[root@localhost opt]# mv apr-util-1.4.1/ httpd-2.4.25/srclib/apr-util
进入httpd-2.4.25/srclib目录中查看一下,可以看到两个包已经放入httpd-2.4.25中
[root@localhost opt]# cd httpd-2.4.25/srclib
[root@localhost srclib]# ll
total 12
drwxr-sr-x. 25 5000 10001 4096 Feb 7 2012 apr
drwxr-xr-x. 19 501 games 4096 Dec 7 2011 apr-util
-rw-r--r--. 1 501 games 121 Feb 11 2005 Makefile.in
回到/opt目录,查看一下
[root@localhost srclib]# cd /opt
[root@localhost opt]# ll
total 4
drwxr-xr-x. 11 501 games 4096 Dec 16 2016 httpd-2.4.25
drwxr-xr-x. 2 root root 6 Oct 30 2018 rh
安装依赖环境
[root@localhost opt]# yum install gcc gcc-c++ pcre pcre-devel zlib-devel -y
安装完成后,进入httpd-2.4.25目录查看一下
[root@localhost httpd-2.4.25]# cd httpd-2.4.25
[root@localhost httpd-2.4.25]# ls
ABOUT_APACHE BuildAll.dsp configure.in include LICENSE README test
acinclude.m4 BuildBin.dsp docs INSTALL Makefile.in README.cmake VERSIONING
Apache-apr2.dsw buildconf emacs-style InstallBin.dsp Makefile.win README.platforms
Apache.dsw CHANGES httpd.dep LAYOUT modules ROADMAP
apache_probes.d CMakeLists.txt httpd.dsp libhttpd.dep NOTICE server
ap.d config.layout httpd.mak libhttpd.dsp NWGNUmakefile srclib
build configure httpd.spec libhttpd.mak os support
这边注意,如果Linux系统安装的是图形界面,是不用进行gcc的环境安装的,若执行环境安装命令,会一直报错(亲身试验)
配置./configure
./configure --prefix=/usr/local/httpd --enable-deflate --enable-so --enable-reweite --enable-charset-lite --enable-cgi
编译make
[root@localhost httpd-2.4.25]# make
。。。
make[4]: 进入目录“/opt/httpd-2.4.25/modules/dav/fs”
make[4]: 对“local-shared-build”无需做任何事。
make[4]: 离开目录“/opt/httpd-2.4.25/modules/dav/fs”
make[3]: 离开目录“/opt/httpd-2.4.25/modules/dav/fs”
make[3]: 进入目录“/opt/httpd-2.4.25/modules/mappers”
Building shared: mod_vhost_alias.la mod_negotiation.la mod_dir.la mod_actions.la mod_speling.la mod_userdir.la mod_alias.la mod_rewrite.la
make[4]: 进入目录“/opt/httpd-2.4.25/modules/mappers”
make[4]: 对“local-shared-build”无需做任何事。
make[4]: 离开目录“/opt/httpd-2.4.25/modules/mappers”
make[3]: 离开目录“/opt/httpd-2.4.25/modules/mappers”
make[2]: 离开目录“/opt/httpd-2.4.25/modules”
make[2]: 进入目录“/opt/httpd-2.4.25/support”
make[2]: 离开目录“/opt/httpd-2.4.25/support”
make install
[root@localhost httpd-2.4.25]# make install
。。。
mkdir /usr/local/httpd/cgi-bin
Installing header files
Installing build system files
Installing man pages and online manual
mkdir /usr/local/httpd/man
mkdir /usr/local/httpd/man/man1
mkdir /usr/local/httpd/man/man8
mkdir /usr/local/httpd/manual
make[1]: 离开目录“/opt/httpd-2.4.25”
配置httpd的conf属性
进入conf目录
[root@localhost httpd-2.4.25]# cd /usr/local
[root@localhost local]# ls
bin etc games httpd include lib lib64 libexec sbin share src
[root@localhost local]# cd httpd
[root@localhost httpd]# cd conf
[root@localhost conf]# vim httpd.conf
-bash: vim: 未找到命令
[root@localhost conf]# vi httpd.conf
修改配置文件,这边原来51行是有#号的,将#去除,在52行添加#号(若是有#键,则代表是注释行,不发挥功能,若要发挥功能,则要取消注释#键)
46 # directive.
47 #
48 # Change this to Listen on specific IP addresses as shown below to
49 # prevent Apache from glomming onto all bound IP addresses.
50 #
51 Listen 192.168.50.23:80 ###注意这边要改成自己的IP地址###
52 #Listen 80
53
54 #
55 # Dynamic Shared Object (DSO) Support
再搜索一下server,将198行的#号去除
194 # it explicitly to prevent problems during startup.
195 #
196 # If your host doesn't have a registered DNS name, enter its IP address here.
197 #
198 ServerName www.example.com:80
199
200 #
201 # Deny access to the entirety of your server's filesystem. You must
开启apachectl
[root@localhost conf]# cd ..
[root@localhost httpd]# cd bin/
[root@localhost bin]# ./apachectl start
查看80接口
[root@localhost bin]# netstat -ntap |grep 80
-bash: netstat: 未找到命令
这边命令无法使用,要安装yum -y install net-tools
[root@localhost bin]# yum -y install net-tools
。。。
Running transaction
正在安装 : net-tools-2.0-0.25.20131004git.el7.x86_64 1/1
验证中 : net-tools-2.0-0.25.20131004git.el7.x86_64 1/1
已安装:
net-tools.x86_64 0:2.0-0.25.20131004git.el7
完毕!
再次查看
[root@localhost bin]# netstat -ntap |grep 80
tcp 0 0 192.168.50.23:80 0.0.0.0:* LISTEN 46647/httpd
tcp 0 0 192.168.50.23:39308 59.111.0.251:80 TIME_WAIT -
htdocs 网页目录,修改首页index配置
[root@localhost bin]# systemctl stop firewalld.service
[root@localhost bin]# setenforce 0
[root@localhost bin]# cd ..
[root@localhost httpd]# ls
bin build cgi-bin conf error htdocs icons include lib logs man manual modules
[root@localhost httpd]# cd htdocs/
[root@localhost htdocs]# ls
index.html
[root@localhost htdocs]# vi index.html
<html><body><h1>Hello Word</h1></body></html>
~
打开IP网页地址
实验完成