美文网首页
Linux(centos6+)安装(Apache2.4+mysq

Linux(centos6+)安装(Apache2.4+mysq

作者: 何方夜猫 | 来源:发表于2018-05-30 10:15 被阅读0次

    本教程基于centos6.5 环境

    版本:Apache2.43 +apr-1.6.3 + apr-util-1.6.1

    一,所有资源官网

    1 Apache下载https://httpd.apache.org/download.cgi

    2 apr和apr-util下载https://apr.apache.org/

    3 正则工具 pcre: http://www.pcre.org/

    二,安装

    2.1 装库

    # yum install -y gcc gdb strace gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs patch e2fsprogs-devel krb5-devel libidn libidn-devel openldap-devel nss_ldap openldap-clients openldap-servers libevent-devel libevent uuid-devel uuid mysql-devel

    2.1安装apache依赖

    2.1.1 APR

    # wget http://apache.osuosl.org//apr/apr-1.6.3.tar.gz

    # tar zxf apr-1.6.3.tar.gz# cd apr-1.6.3# ./configure --prefix=/usr/local/apr-1.6.3# make && make install

    2.1.2 apr-util

    # wget http://apache.osuosl.org//apr/apr-util-1.6.1.tar.gz

    # tar zxf apr-util-1.6.1.tar.gz

    # cd apr-util-1.6.1

    # ./configure --prefix=/usr/local/apr-util-1.6.1 --with-apr=/usr/local/apr-1.6.3    (!!版本号要对应啊啊!) # make && make install

    2.1.3 pcre

    # wget https://ftp.pcre.org/pub/pcre/pcre-8.42.tar.gz

    # tar zxf pcre-8.42.tar.gz

    # cd pcre-8.42.tar.gz

    # ./configure

    # make && make install

    2.2开装apache

    #cd /usr/local/src

    #wget http://mirrors.sonic.net/apache//httpd/httpd-2.4.33.tar.gz

    # tar zxf httpd-2.4.33.tar.gz

    # cd httpd-2.4.33

    # mkdir -p /usr/local/apache2.433

    #./configure --prefix=/usr/local/apache2.433 --with-apr=/usr/local/apr-1.6.3 --with-apr-util=/usr/local/apr-util-1.6.1 --with-ssl --enable-ssl --enable-module=so --enable-rewrite --enable-cgid --enable-cg

    #make && make install

    # cp /usr/local/apache2.433/conf/httpd.conf  /usr/local/apache2.433/conf/httpd.conf.default(生手可以把配置文件备份一下,留作日后抢救)

    2.3 配置Apache

    2.3.1配置ServerName

    # vi /usr/local/apache2.433/conf/httpd.conf

    将#ServerName www.example.com:80 改为:ServerName localhost:80

    2.3.2 配置DirectoryIndex

    # vi /usr/local/apache2.433/conf/httpd.conf

    找:DirectoryIndex index.html 改为:DirectoryIndex index.html index.php

    2.3.3开启apache支持伪静态

    # vi /usr/local/apache2.433/conf/httpd.conf

    AllowOverride None 改:AllowOverride All

    LoadModule rewrite_module modules/mod_rewrite.so 去掉# 支持伪静态

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

    #vi /etc/profile  #添加apache服务系统环境变量

    在最后添加下面这一行

    export PATH=$PATH:/usr/local/apache2.433/bin

    2.3.5 把apache加入到系统启动

    # cp /usr/local/apache2.433/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

    2.3.6 设置开机启动

    # chkconfig httpd on

    现在可以用命令 service httpd start || stop || restart 控制httpd了

    查看端口状态 # netstat -an | grep 80

    2.3.7虚拟主机配置

    # vi /usr/local/apache2.433/conf/httpd.conf

    在倒数十行找VirtualHost字眼位置去掉 Include **** extra/virtual-host-httpd.conf

    2.3.8设置你的项目目录

    默认配置 在 httpd.conf

    可以修改成 你自己的设定的目录 如

    注意这里改了,虚拟主机配置文件里面的最好也要改

    三,常见报错:

    1.apache安装报错configure: WARNING: OpenSSL version is too old no

    checking whether to enable mod_ssl…

    configure: error: mod_ssl has been requested but can not be built due to prerequisite failures

    解决办法:#yum install openssl-devel

    #yum update openssl

    2.网站访问403

    You don't have permission to access / on this server. Server unable to read htaccess file, denying access to be safe

    解决办法:chmod -R 755 /var/myproject (给你的项目根目录设置访问权限)

    万一装成功。。。请手动赞。。

    编译按装php请看下篇

    相关文章

      网友评论

          本文标题:Linux(centos6+)安装(Apache2.4+mysq

          本文链接:https://www.haomeiwen.com/subject/qdktsftx.html