Linux中Apache安装与配置(CentOS

您所在的位置:网站首页 centos6安装apache Linux中Apache安装与配置(CentOS

Linux中Apache安装与配置(CentOS

2023-08-30 05:06| 来源: 网络整理| 查看: 265

 

1 Apache简介

    Apache是世界使用排名第一的Web服务器软件。它可以运行在几乎所有广泛使用的计算机平台上,由于其跨平台和安全性被广泛使用,是最流行的Web服务器端软件。同时Apache音译为阿帕奇,是北美印第安人的一个部落,叫阿帕奇族,在美国的西南部。也是一个基金会的名称、一种武装直升机等等。

 

 

 

 

2 Apache下载

    1)下载apr         http://apr.apache.org/       2)下载apr-util         http://apr.apache.org/       3) 下载pcre         http://www.pcre.org/     4)下载httpd

 

 

 

 

        http://httpd.apache.org/

 

     5)  本次安装用到的所有软件下载地址(安装环境为CentOS-6.5)

       http://download.csdn.net/detail/clevercode/8653727

            

3 Apache安装

确保先进行了安装linux必备常用库(Linux中必备常用支持库的安装:http://blog.csdn.net/clevercode/article/details/45438401)

 

3.1 配置防火墙80端口

    #修改防火墙配置:      # vi + /etc/sysconfig/iptables     #添加配置项      -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT     #重启防火墙      # service iptables restart     

3.2 安装apr

    1) 解压     # cd /usr/local/src/apache     # tar zxvf  apr-1.5.1.tar.gz     # cd apr-1.5.1     2) 配置     # ./configure --prefix=/usr/local/apr     3) 编译     # make     4)安装     # make install     

3.3 安装apr-util

    1)解压     # cd /usr/local/src/apache     # tar zxvf apr-util-1.5.3.tar.gz     # cd apr-util-1.5.3     2)配置     # ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/bin/apr-1-config     3) 编译     # make     4) 安装     # make install     

3.4 正则表达式库安装

    1)解压pcre-8.12.tar.gz     # cd /usr/local/src/apache      # tar zxvf pcre-8.12.tar.gz     2)进入解压后的目录     # cd pcre-8.12      3)配置     #  ./configure     4) 编译     #  make     5) 安装     #  make install     

3.5 安装apache

    1)解压     # cd /usr/local/src/apache     # tar -zvxf httpd-2.4.tar.gz     # cd httpd-2.4.9     2)编译     # mkdir -p /usr/local/apache2     # ./configure --prefix=/usr/local/apache2 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-ssl --enable-ssl --enable-module=so --enable-rewrite --enable-cgid --enable-cgi     3)编译     # make     4)安装     #  make install     

4 Apache配置 4.1 配置ServerName

    # vi /usr/local/apache2/conf/httpd.conf     找到:#ServerName www.example.com:80     修改为:ServerName localhost:80     

4.2 配置DirectoryIndex

    # vi /usr/local/apache2/conf/httpd.conf     找到:DirectoryIndex index.html     修改为:DirectoryIndex index.html index.php     

4.3 配置不显示目录结构

    # vi /usr/local/apache2/conf/httpd.conf     找到:Options Indexes FollowSymLinks     修改为:Options FollowSymLinks     

4.4 开启apache支持伪静态

    # vi /usr/local/apache2/conf/httpd.conf     找到AllowOverride None      修改为:AllowOverride All   #开启apache支持伪静态,有三处都做修改     LoadModule rewrite_module modules/mod_rewrite.so   #取消前面的注释,开启apache支持伪静态     

4.5 添加apache服务系统环境变量

    vi /etc/profile  #添加apache服务系统环境变量     在最后添加下面这一行     export PATH=$PATH:/usr/local/apache2/bin     

4.6 把apache加入到系统启动

    # cp /usr/local/apache2/bin/apachectl /etc/rc.d/init.d/httpd     vi /etc/init.d/httpd       在#!/bin/sh下面添加以下两行     #chkconfig:2345 10 90     #description:Activates/Deactivates Apache Web Server     

4.7 更改目录所有者与权限

    chown  daemon.daemon  -R /usr/local/apache2/htdocs  #更改目录所有者     chmod   700 /usr/local/apache2/htdocs  -R #更改apache网站目录权限     

4.8 设置开机启动

    # chkconfig httpd on     

4.9 启动停止重启

    1)启动     # service httpd start     2)停止     # service httpd stop     3)重启     # service httpd restart     4)查看端口状态     # netstat -an | grep 80

 

 

技术交流

CleverCode是一名架构师,技术交流,咨询问题,请加CleverCode创建的qq群(架构师俱乐部):517133582。加群和腾讯,阿里,百度,新浪等公司的架构师交流。【架构师俱乐部】宗旨:帮助你成长为架构师!

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3