Linux下安装apache

1.1  安装Apache服务器

步骤1:    apache安装文件复制到/usr/local

cp httpd-2.2.6.tar.gz /usr/local

步骤2:    解压httpd-2.2.6.tar.gz

cd /usr/local

tar xvfz httpd-2.2.6.tar.gz

步骤3:     

cd httpd-2.2.6

./configure  --prefix=/usr/local/apache --enable-module=so

步骤4:     

make

步骤5:     

make install

步骤6:    测试是否安装成功

/usr/local/apache/bin/apachectl configtest

步骤7:    启动apache服务,访问本地80端口中,查看端口是否正常

/usr/local/apache/bin/apachectl start

步骤8:    关闭服务

/usr/local/apache/bin/apachectl stop

1.2  测试apache服务器

步骤1:    apache服务器默认的Root目录中创建一个名为test.html的文件,内容为:

<html>

    <body>

        <h1>hello,我是apache测试语句</h1>

    <body>

</html>

步骤2:    修改test.html文件权限

chmod 744 /usr/local/apache/htdocs/test.html

【注意】

    如果没有这句,访问测试页面的时候将浏览器将提示You don’t have permission to access /test.html on the server.

步骤3:    重启动apache服务器,并在浏览器里面访问测试页面

/usr/local/apache/bin/apachectl restart

【注意】

    重启apache服务器后,通过浏览器访问测试页面,中文可能会出现乱码,这是与apache服务器的字符集有关系,请参考httpd设置章节。

1.3  配置apache服务器

1.3.1  apache自启动配置

步骤1:    apachectl复制到/etc/rc.d/init.d/httpd

cd /usr/local/apache/bin

cp apachectl /etc/rc.d/init.d/httpd

步骤2:    修改/etc/rc.d/init.d/httpd文件

vi /etc/rc.d/init.d/httpd

在第三行添加以下内容

#chkconfig:345 85 15

#description: Start and stops the Apache HTTP Server.

步骤3:    修改httpd权限

chmod +x /etc/rc.d/init.d/httpd

步骤4:    httpd加入到service列表中

chkconfig - -add httpd

【注意】

    如果执行该命令时出现“httpd服务不支持chkconfig”,请检查/etc/rc.d/init.d/httpd文件内的第三行的chkconfig和第四行的description拼写是否错误。

步骤5:    查看httpd是否加入service

chkconfig - -list

1.3.2  httpd配置

1. 修改乱码

步骤1:    httpd.conf中将Include conf/extra/httpd-autoindex这个模块的注释去掉

@vi /usr/local/apache/conf/httpd.conf

步骤2:    httpd-autoindex.conf中加入IndexOptions Charset=UTF-8

@vi /usr/local/apache/conf/extra/httpd-autoindex.conf

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值