Linux下Apache服务器的安装与配置


title: Linux下Apache服务器的安装与配置
date: 2019-04-07 20:39:17
categories:

  • Linux
    tags:
  • Apache

安装

linux中,Apache服务器叫做httpd

准备

首先下载httpdhttpd的依赖软件。

没有gcc/gcc-c++的话,先安装gcc/gcc-c++

[root@localhost /]# yum install gcc-c++

基于centos,其余系统相应变化。

先确定服务器是否联网,若安装过程出现错误,可能是缺某些依赖包,谷歌百度下,会有结果的。

安装

解压
tar -zxf apr-1.6.5.tar.gz
tar -zxf apr-util-1.6.1.tar.gz
tar -zxf pcre-8.38.tar.gz
tar -zxf httpd-2.4.37.tar.gz

默认解压到当前目录

安装

直接复制粘贴,修改成刚刚解压的相应目录。

  • apr的安装
cd apr-1.6.5

./configure --prefix=/home/apr-1.6.5

make

make install
  • apr-util的安装
cd ../apr-util-1.6.1

./configure --prefix=/home/apr-util --with-apr=/home/apr-1.6.5/bin/apr-1-config

make

make install
  • pcre的安装
cd ../pcre-8.38

./configure --prefix=/home/pcre-8.38 --with-apr=/home/apr-1.6.5/bin/apr-1-config

make

make install
  • httpd的安装
cd ../httpd-2.4.18

./configure --prefix=/home/httpd-2.4.37 --with-pcre=/home/pcre-8.38 --with-apr=/home/apr-1.6.5 --with-apr-util=/home/apr-util-1.6.1

make

make install
检查

安装成功。

配置

想要将httpd作为文件服务器,需要更改一些配置。

  • 进入httpdconf文件夹。
/home/httpd-2.4.37/conf
  • 打开httpd.conf配置文件。
vi httpd.conf
  • 更改端口号
  • 更改主机号
  • 更改文件目录
  • 启动

    [root@hmaster bin]# ./apachectl start
    [root@hmaster bin]# ./apachectl stop
    [root@hmaster bin]# ./apachectl restart
    
  • 检查

出现此页面,则安装成功。

问题

遇到的问题:

  • 启动时遇到的问题

    httpd: Could not open configuration file /xxx/conf/httpd.conf: No such file or directory
    

    解决办法:

    ./apachectl -f /xxx/httpd/conf/httpd.conf -k start
    

    httpd.conf配置文件启动。

  • 2
    点赞
  • 34
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值