• 欢迎访问VPS岛网站,国外VPS,国内VPS,国外服务器,国内服务器,服务器主机,测评及优惠码,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站 QQ群

centos7源码安装apache

Apache技术 Lee_吉 54次浏览 已收录 0个评论
  1. 安装软件:
    a. httpd官方网站/下载地址:
    http://httpd.apache.org/download.cgi
    或
    https://github.com/dollarphper/soft/raw/master/apache/httpd-2.4.34.tar.gz

    b. arp、arp-util官方网站:

    http://apr.apache.org/download.cgi
    或
    https://github.com/dollarphper/soft/raw/master/apache/apr-1.6.3.tar.gz
    https://github.com/dollarphper/soft/raw/master/apache/apr-util-1.6.1.tar.gz

    c. pcre官方网站:

    https://www.pcre.org/
    或
    https://github.com/dollarphper/soft/raw/master/apache/pcre-8.42.tar.gz
  2. 安装:
    a. 安装依赖:
    yum  -y  install  expat-devel
    yum  -y  install  libxml2-devel

    b. 解压:

    tar  -xzf  httpd-2.4.34.tar.gz
    tar  -xzf  apr-1.6.3.tar.gz
    tar  -xzf  apr-util-1.6.1.tar.gz
    tar  -xzf  pcre-8.42.tar.gz

    c. 移动apr、apr-util到httpd目录下并重命名:

    mv  apr-1.6.3  httpd-2.4.34/srclib/apr
    mv  apr-util-1.6.1  httpd-2.4.34/srclib/apr-util

    d. 安装pcre:
    d-1. 创建文件夹:

    mkdir  /etc/pcre

    d-2. 进入pcre目录:

    cd  pcre-8.42

    d-3. 编译安装:

    ./configure  --prefix=/etc/pcre
    make  &&  make  install  &&  make  clean

    e. 安装apache:
    e-1. 创建文件夹:

    mkdir  /etc/httpd

    e-2. 进入apache目录:

    cd  httpd-2.4.34

    e-3. 编译安装:

    ./configure  --prefix=/etc/httpd  -with-pcre=/etc/pcre/bin/pcre-config  -with-included-apr
    make  &&  make  install  &&  make  clean

    e-4. 创建apache用户:

    useradd  -s  /sbin/nologin  -M  apache

    e-5. 安装gzip模块:

    /etc/httpd/bin/apxs  -i  -c  -a  /home/lee/lamp/apache/httpd-2.4.34/modules/filters/mod_deflate.c

    e-6. 安装rewrite模块:

    /etc/httpd/bin/apxs  -i  -c  -a  /home/lee/lamp/apache/httpd-2.4.34/modules/mappers/mod_rewrite.c
  3. 配置:
    a. 修改配置文件:
    vim /etc/httpd/conf/httpd.conf
    ServerRoot "/etc/httpd"
    ServerName lee
    User apache
    Group apache
    Listen 80
    LoadModule authn_file_module modules/mod_authn_file.so
    LoadModule authn_core_module modules/mod_authn_core.so
    LoadModule authz_host_module modules/mod_authz_host.so
    LoadModule authz_groupfile_module modules/mod_authz_groupfile.so
    LoadModule authz_user_module modules/mod_authz_user.so
    LoadModule authz_core_module modules/mod_authz_core.so
    LoadModule access_compat_module modules/mod_access_compat.so
    LoadModule auth_basic_module modules/mod_auth_basic.so
    LoadModule reqtimeout_module modules/mod_reqtimeout.so
    LoadModule filter_module modules/mod_filter.so
    LoadModule mime_module modules/mod_mime.so
    LoadModule log_config_module modules/mod_log_config.so
    LoadModule env_module modules/mod_env.so
    LoadModule headers_module modules/mod_headers.so
    LoadModule setenvif_module modules/mod_setenvif.so
    LoadModule version_module modules/mod_version.so
    LoadModule unixd_module modules/mod_unixd.so
    LoadModule status_module modules/mod_status.so
    LoadModule autoindex_module modules/mod_autoindex.so
    LoadModule dir_module modules/mod_dir.so
    LoadModule alias_module modules/mod_alias.so
    LoadModule php7_module        modules/libphp7.so
    LoadModule deflate_module     modules/mod_deflate.so
    LoadModule rewrite_module     modules/mod_rewrite.so
    <IfModule deflate_module>
    SetOutputFilter DEFLATE
    SetEnvIfNoCase Request_URI .(?:gif|jpe?g|png)$ no-gzip dont-vary
    SetEnvIfNoCase Request_URI .(?:exe|t?gz|zip|bz2|sit|rar)$ no-gzip dont-vary
    SetEnvIfNoCase Request_URI .(?:pdf|doc|avi|mov|mp3|rm)$ no-gzip dont-vary
    AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css
    AddOutputFilterByType DEFLATE application/x-javascript
    </IfModule>
    LimitRequestBody 10485760
    <IfModule unixd_module>
    User apache
    Group apache
    </IfModule>
    ServerAdmin you@example.com
    <Directory />
    AllowOverride none
    Require all denied
    </Directory>
    DocumentRoot "/var/www/html"
    <Directory "/var/www/html">
    Header set Access-Control-Allow-Origin *
    Options Indexes FollowSymLinks
    AllowOverride all
    Require all granted
    AcceptPathInfo on
    </Directory>
    <IfModule dir_module>
    DirectoryIndex index.php index.html
    </IfModule>
    <Files ".ht*">
    Require all denied
    </Files>
    ErrorLog "logs/error_log"
    LogLevel warn
    <IfModule log_config_module>
    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
    LogFormat "%h %l %u %t \"%r\" %>s %b" common
    <IfModule logio_module>
    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
    </IfModule>
    CustomLog "logs/access_log" common
    </IfModule>
    <IfModule alias_module>
    ScriptAlias /cgi-bin/ "/etc/httpd/cgi-bin/"
    </IfModule>
    <IfModule cgid_module>
    </IfModule>
    <Directory "/etc/httpd/cgi-bin">
    AllowOverride None
    Options None
    Require all granted
    </Directory>
    <IfModule headers_module>
    RequestHeader unset Proxy early
    </IfModule>
    <IfModule mime_module>
    TypesConfig conf/mime.types
    AddType application/x-compress .Z
    AddType application/x-gzip .gz .tgz
    AddType application/x-httpd-php .php .phtml .php3 .inc
    </IfModule>
    <IfModule proxy_html_module>
    Include conf/extra/proxy-html.conf
    </IfModule>
    <IfModule ssl_module>
    SSLRandomSeed startup builtin
    SSLRandomSeed connect builtin
    </IfModule>

    b. 新建文件夹:

    mkdir  -p  /var/www/html
  4. 测试:
    a. 启动命令:
    /etc/httpd/bin/apachectl  -k  start

    b. 停止命令:

    /etc/httpd/bin/apachectl  -k  stop

    c. 重启命令:

    /etc/httpd/bin/apachectl  -k  restart

    d. 启动apache:
    e. 创建测试文件:

    echo  "hello world"  >  /var/www/html/index.html

    f. 浏览器访问:
    centos7源码安装apache


VPS岛 的文章和资源来自互联网,仅作为参考资料,如果有侵犯版权的资源请尽快联系站长,我们会在24h内删除有争议的资源。丨 转载请注明centos7源码安装apache
喜欢 (0)
发表我的评论
取消评论
表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址