良许Linux教程网 干货合集 Linux中安装 Apache服务器

Linux中安装 Apache服务器

pache HTTP Server(简称Apache)是Apache软件基金会的一个开放源码的网页服务器,是世界使用排名第一的Web服务器软件。它可以运行在几乎所有广泛使用的计算机平台上,由于其跨平台和安全性被广泛使用,是最流行的Web服务器端软件之一。

服务器安装Linux中安装 Apache服务器安装Linux中安装 Apache


软件准备:

apr-1.5.2.tar.gz httpd-2.4.25.tar.gz mod_ftp-0.9.6-beta.tar.gz
apr-iconv-1.2.1.tar.gz pcre-8.40.tar.gz
apr-util-1.5.4.tar.gz mod_fcgid-2.3.9.tar.gz

解压软件:

tar -zxf apr-1.5.2.tar.gz
tar -zxf httpd-2.4.25.tar.gz
tar -zxf pcre-8.40.tar.gz
tar -zxf apr-util-1.5.4.tar.gz
tar -zxf mod_ftp-0.9.6-beta.tar.gz
tar -zxf apr-iconv-1.2.1.tar.gz
tar -zxf mod_fcgid-2.3.9.tar.gz

查看:ls

[root@smqq Apache]# ls
apr-1.5.2 apr-util-1.5.4.tar.gz mod_fcgid-2.3.9.tar.gz
apr-1.5.2.tar.gz httpd-2.4.25 mod_ftp-0.9.6
apr-iconv-1.2.1 httpd-2.4.25.tar.gz mod_ftp-0.9.6-beta.tar.gz
apr-iconv-1.2.1.tar.gz install pcre-8.40
apr-util-1.5.4 mod_fcgid-2.3.9 pcre-8.40.tar.gz
[root@smqq Apache]#

安装

apr:

[root@smqq Apache]# cd apr-1.5.2
[root@smqq apr-1.5.2]#./configure --prefix=/home/Apache/install/apr
[root@smqq apr-1.5.2]#make
[root@smqq apr-1.5.2]#make install

apr-util:

[root@smqq Apache]# cd apr-util-1.5.4
[root@smqq apr-util-1.5.4]#./configure --prefix=/home/Apache/install/apr-util -with-apr=/home/Apache/install/apr/bin/apr-1-config
[root@smqq apr-util-1.5.4]#make
[root@smqq apr-util-1.5.4]#make install

pcre-8.40:

[root@smqq Apache]# cd pcre-8.40
[root@smqq pcre-8.40]#./configure --prefix=/home/Apache/install/pcre
[root@smqq pcre-8.40]#make
[root@smqq pcre-8.40]#make install

下面是apache 的安装了 可能会出现各种的错误,我们一步步来

httpd-2.4.25 :

[root@smqq Apache]# cd httpd-2.4.25
[root@smqq httpd-2.4.25]# ./configure --prefix=/home/Apache/install/httpd-2.4.25
checking for chosen layout... Apache
checking for working mkdir -p... yes
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
configure:
configure: Configuring Apache Portable Runtime library...
configure:
checking for APR... no
configure: error: APR not found. Please read the documentation.
[root@smqq httpd-2.4.25]#

这里提示说apr 没有找到,我们之前安装过了,为什么?

找下原因:

原来需要添加 with 命令

[root@smqq httpd-2.4.25]# ./configure --prefix=/home/Apache/install/httpd-2.4.25 --with-apr=/home/Apache/install/apr --with-apr-util=/home/Apache/install/apr-util --with-pcre=/home/Apache/install/pcre
[root@smqq httpd-2.4.25]#make

[root@smqq httpd-2.4.25]#make install

至此安装的步骤已经完成了,下面启动启动测试

•启动Apache:/home/Apache/install/httpd-2.4.25/bin/apachectl start

•停止Apache:/home/Apache/install/httpd-2.4.25/bin/apachectl stop

•重启Apache:/home/Apache/install/httpd-2.4.25/bin/apachectl restart

启动:

[root@smqq httpd-2.4.25]# /home/Apache/install/httpd-2.4.25/bin/apachectl start
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName' directive globally to suppress this message
[root@smqq httpd-2.4.25]#

他让设置一个服务的名称,我们找到httpd.conf配置一下servername

[root@smqq conf]# vim /home/Apache/install/httpd-2.4.25/conf/httpd.conf
[root@smqq conf]#

找到注释的地方 Servername 修改成你的ip,或者127.0.0.1,或者localhost

ServerName 172.16.3.86:80

再次启动:

[root@smqq conf]# /home/Apache/install/httpd-2.4.25/bin/apachectl start
httpd (pid 57862) already running
[root@smqq conf]#

测试一下浏览器打开:

http://172.16.3.86/ 服务器安装Linux中安装 Apache服务器安装Linux中安装 Apache

映射静态文件

到这里服务器搭建成功了,但是我们需要的是一个能够访问静态文件的服务器,所以还需要将本地文件映射到apache服务器上。

接下来一步步进行映射配置:

找到一个配置,参照这个配置我们从新设置下conf文件

服务器安装Linux中安装 Apache服务器安装Linux中安装 Apache


先停掉服务

[root@smqq conf]# /home/Apache/install/httpd-2.4.25/bin/apachectl stop
[root@smqq conf]# vim /home/Apache/install/httpd-2.4.25/conf/httpd.conf
服务器安装Linux中安装 Apache服务器安装Linux中安装 Apache

[root@smqq conf]# /home/Apache/install/httpd-2.4.25/bin/apachectl start
服务器安装Linux中安装 Apache服务器安装Linux中安装 Apache

以上就是良许教程网为各位朋友分享的Linu系统相关内容。想要了解更多Linux相关知识记得关注公众号“良许Linux”,或扫描下方二维码进行关注,更多干货等着你 !

137e00002230ad9f26e78-265x300
本文由 良许Linux教程网 发布,可自由转载、引用,但需署名作者且注明文章出处。如转载至微信公众号,请在文末添加作者公众号二维码。
良许

作者: 良许

良许,世界500强企业Linux开发工程师,公众号【良许Linux】的作者,全网拥有超30W粉丝。个人标签:创业者,CSDN学院讲师,副业达人,流量玩家,摄影爱好者。
上一篇
下一篇

发表评论

联系我们

联系我们

公众号:良许Linux

在线咨询: QQ交谈

邮箱: yychuyu@163.com

关注微信
微信扫一扫关注我们

微信扫一扫关注我们

关注微博
返回顶部