zoukankan      html  css  js  c++  java
  • linux 安装 apache

           1.  系统基本信息

                CentOS  6.4   内存2G  硬盘 200G   cpu 4核  (cat /proc/cpuinfo |grep 'processor'|wc -l  查看cpu核数命令)

          2. apache版本

                 httpd-2.2.17.tar.gz

          3. 检查系统是否安装了apache

                  rpm -qa | grep httpd  (如果有则需要先卸载掉)

          4. 安装apache

             tar -zxvf  httpd-2.2.17.tar.gz

             cd httpd-2.2.17

              ./configure --prefix=/usr/local/apache --enable-so --enable-modules=so --enable-rewrite --enable-deflate

              

               参数说明:
              --prefix=/usr/local/httpd //apache安装目录
              --enable-so //支持so模块
              --enable-module=so //打开so模块,so模块是用来提dso支持的apache核心模块
              --enable-rewrite //支持伪静态
              --enable-ssl //支持ssl
              --enable-deflate //支持网页压缩

              其他参数:
              --enable-cache //支持缓存
              --enable-file-cache //支持文件缓存
              --enable-mem-cache //支持内存缓存
              --enable-disk-cache //支持磁盘缓存
              --enable-mods-shared=all //动态加载所有模块
              --enable-static-support //支持静态连接(默认为动态连接)
              --enable-static-htpasswd //使用静态连接编译 htpasswd - 管理用于基本认证的用户文件
              --enable-static-htdigest //使用静态连接编译 htdigest - 管理用于摘要认证的用户文件
              --enable-static-rotatelogs //使用静态连接编译 rotatelogs - 滚动 apache 日志的管道日志程序
              --enable-static-logresolve //使用静态连接编译 logresolve - 解析apache日志中的ip地址为主机名
              --enable-static-htdbm //使用静态连接编译 htdbm - 操作 dbm 密码数据库
              --enable-static-ab //使用静态连接编译 ab - apache http 服务器性能测试工具
              --enable-static-checkgid //使用静态连接编译 checkgid
              --enable-mod_cgi //禁止用一个外部 CGI 守护进程执行CGI脚本
              --enable-expires=shared //支持缓存
              --disable-cgid //禁止用一个外部 cgi 守护进程执行cgi脚本
              --disable-cgi //禁止编译cgi版本的php
              --disable-userdir //禁止用户从自己的主目录中提供页面
              --with-mpm=worker //让apache以worker方式运行
              --enable-authn-dbm=shared //对动态数据库进行操作,rewrite时需要

              

                make

               make install

                cp /usr/local/apache/bin/apachectl /etc/init.d/httpd
                vi /etc/init.d/httpd 在第二行加入以下两行内容

                # chkconfig: 2345 10 90

                # description: Activates/Deactivates Apache Web Server

                /sbin/chkconfig --add httpd
               /sbin/chkconfig --level 2345 httpd on

               groupadd www

               useradd -g www -s /sbin/nologin www

               chown -R www:www /usr/local/apache

               

           5. 关闭selinux

               A 不需要重启Linux:
                setenforce 0
               B 需要重启Linux:
               vi /etc/selinux/config 将SELINUX=enforcing 改成SELINUX=disable 

            6. 修改apache的配置文件 httpd.conf

                1.  将  AllowOverride None  改成  AllowOverride all

               2.  修改错误日志的配置

               ErrorLog "| /usr/local/apache/bin/rotatelogs /var/log/apache_log/%Y_%m_%d_error_log 86400 480"

               3.  修改访问日志的配置

               CustomLog "| /usr/local/apache/bin/rotatelogs /var/log/apache_log/%Y_%m_%d_access_log 86400 480" combined

               4.禁止列目录

               Options FollowSymLinks

               5 修改运行的用户和用户组

                User www
                Group www

               6. 在 最后一行添加

                ServerName 127.0.0.1  (实际服务器的ip)
                NameVirtualHost 127.0.0.1

                7. 增加别的目录访问

               Alias /www"/var/www"
               <Directory "/var/www">
                Options FollowSymLinks
                AllowOverride All
                Order allow,deny
                Allow from all
               </Directory>

               8.域名配置

                    <VirtualHost *:80>
                        DocumentRoot /var/www/project
                        ServerName www.domain.com
                        LogFormat "%h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-Agent}i""
                        TransferLog "| /usr/local/apache/bin/rotatelogs /var/log/apache_log/project/%Y_%m_%d_access_log 86400 480" //单独为域名配置访问日志

                        ErrorLog "| /usr/local/apache/bin/rotatelogs /var/log/apache_log/project/%Y_%m_%d_error_log 86400 480"//单独为域名配置错误日志

                    </VirtualHost>

            7.关闭防火墙 

               chkconfig iptables off

               service iptables stop

            8. 重启服务器

               shutdown -r now

            9. 访问

             http://www.domain.com

             如果访问正常 就OK  如果访问不正常 可以根据实际情况进行调整

           

  • 相关阅读:
    TCP源码—连接建立
    TCP系列02—连接管理—1、三次握手与四次挥手
    TCP系列01—概述及协议头格式
    ubuntu软件管理apt与dpkg
    318. Maximum Product of Word Lengths
    317. Shortest Distance from All Buildings
    316. Remove Duplicate Letters
    315. Count of Smaller Numbers After Self
    314. Binary Tree Vertical Order Traversal
    313. Super Ugly Number
  • 原文地址:https://www.cnblogs.com/jackspider/p/3670079.html
Copyright © 2011-2022 走看看