• centos7环境下编译安装apache2.4.41匹配php-fpm模式


    # 查看apache的版本
    # 可以看到使用了 APR 1.6.5 APR-UTIL 1.6.1
    # /www/server/apache/bin/httpd -V
    Server version: Apache/2.4.41 (Unix)
    Server built:   Oct 11 2019 21:26:47
    Server's Module Magic Number: 20120211:88
    Server loaded:  APR 1.6.5, APR-UTIL 1.6.1
    Compiled using: APR 1.6.5, APR-UTIL 1.6.1
    Architecture:   64-bit
    Server MPM:     prefork
      threaded:     no
        forked:     yes (variable process count)
    Server compiled with....
     -D APR_HAS_SENDFILE
     -D APR_HAS_MMAP
     -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
     -D APR_USE_SYSVSEM_SERIALIZE
     -D APR_USE_PTHREAD_SERIALIZE
     -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
     -D APR_HAS_OTHER_CHILD
     -D AP_HAVE_RELIABLE_PIPED_LOGS
     -D DYNAMIC_MODULE_LIMIT=256
     -D HTTPD_ROOT="/www/server/apache"
     -D SUEXEC_BIN="/www/server/apache/bin/suexec"
     -D DEFAULT_PIDLOG="logs/httpd.pid"
     -D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
     -D DEFAULT_ERRORLOG="logs/error_log"
     -D AP_TYPES_CONFIG_FILE="conf/mime.types"
     -D SERVER_CONFIG_FILE="conf/httpd.conf"
    
    # 查看openssl版本
    # /usr/local/openssl/bin/openssl 
    OpenSSL> version
    OpenSSL 1.0.2l  25 May 2017
    
    
    # apache已经按照的模块
    
    # /www/server/apache/bin/httpd -M
    AH00180: WARNING: MaxRequestWorkers of 25200 exceeds ServerLimit value of 1000 servers, decreasing MaxRequestWorkers to 1000. To increase, please see the ServerLimit directive.
    Loaded Modules:
     core_module (static)
     so_module (static)
     http_module (static)
     authn_file_module (shared)
     authn_core_module (shared)
     authz_host_module (shared)
     authz_groupfile_module (shared)
     authz_user_module (shared)
     authz_core_module (shared)
     access_compat_module (shared)
     auth_basic_module (shared)
     reqtimeout_module (shared)
     ext_filter_module (shared)
     filter_module (shared)
     deflate_module (shared)
     mime_module (shared)
     log_config_module (shared)
     env_module (shared)
     headers_module (shared)
     setenvif_module (shared)
     version_module (shared)
     remoteip_module (shared)
     proxy_module (shared)
     proxy_connect_module (shared)
     proxy_ftp_module (shared)
     proxy_http_module (shared)
     proxy_fcgi_module (shared)
     proxy_scgi_module (shared)
     proxy_wstunnel_module (shared)
     proxy_ajp_module (shared)
     proxy_balancer_module (shared)
     proxy_express_module (shared)
     slotmem_shm_module (shared)
     ssl_module (shared)
     lbmethod_byrequests_module (shared)
     lbmethod_bytraffic_module (shared)
     lbmethod_bybusyness_module (shared)
     lbmethod_heartbeat_module (shared)
     mpm_prefork_module (shared)
     unixd_module (shared)
     status_module (shared)
     autoindex_module (shared)
     dir_module (shared)
     alias_module (shared)
     rewrite_module (shared)
     http2_module (shared)
    
    
    # 按照依赖
    yum -y install gcc make prce-devel openssl-devel expat-devel 
    
    # 获取apache、apr、api-util 软件源码
    wget http://archive.apache.org/dist/httpd/httpd-2.4.41.tar.gz
    wget https://archive.apache.org/dist/apr/apr-util-1.6.1.tar.gz
    wget https://archive.apache.org/dist/apr/apr-1.6.5.tar.gz
    
    # 按照apr和apr-util
    cd /usr/local/src/
    tar xf apr-1.6.5.tar.gz
    cd apr-1.6.5
    ./configure --prefix=/usr/local/lab/apr1.6.5
    make && make install
    
    tar xf apr-util-1.6.1.tar.gz
    cd apr-util-1.6.1
    ./configure --prefix=/usr/local/lab/apr-util1.6.1 --with-apr=/usr/local/lab/apr1.6.5
    make && make install
    
    
    # --with-openssl=/usr/local/openssl-1.0.2p 使用自带的openssl版本后报错,用系统自带的openssl
    
    /usr/bin/ld: /usr/local/lab/openssl-1.0.2p/lib/libssl.a(s3_srvr.o): relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
    
    /usr/bin/ld: final link failed: Nonrepresentable section on output
    collect2: error: ld returned 1 exit status
    make[4]: *** [mod_ssl.la] Error 1
    make[4]: Leaving directory `/usr/local/src/httpd-2.4.41/modules/ssl'
    make[3]: *** [shared-build-recursive] Error 1
    make[3]: Leaving directory `/usr/local/src/httpd-2.4.41/modules/ssl'
    make[2]: *** [shared-build-recursive] Error 1
    make[2]: Leaving directory `/usr/local/src/httpd-2.4.41/modules'
    make[1]: *** [shared-build-recursive] Error 1
    make[1]: Leaving directory `/usr/local/src/httpd-2.4.41'
    make: *** [all-recursive] Error 1
    
    
    # 编译 apache2.4.41 参数
    ./configure --prefix=/usr/local/httpd-2.4.41 --enable-isapi --enable-file-cache --enable-cache --enable-mem-cach --enable-deflate --enable-expires --enable-headers  --enable-proxy --enable-proxy-balancer --enable-proxy-ftp --enable-proxy-http --enable-proxy-scgi --enable-unixd --enable-static-rotatelogs --enable-static-htpasswd --enable-static-htdigest --enable-static-logresolve --enable-static-htdbm --enable-static-ab --enable-static-checkgid --enable-static-htcacheclean --enable-vhost-alias --enable-rewrite --enable-mime-magic --enable-so --enable-ssl --with-ssl=/usr/local/lab/openssl-1.0.2p --enable-cgi --enable-rewrite --with-zlib --with-pcre --with-apr=/usr/local/lab/apr1.6.5 --with-apr-util=/usr/local/lab/apr-util1.6.1 --enable-modeles=most --enable-mpms-shared=all --with-mpm=prefork
    
    # make && make install
    
    
    # httpd.conf配置
    
    [/usr/local/httpd-2.4.41/conf]# egrep -v '^#|^$' httpd.conf
    ServerRoot "/usr/local/httpd-2.4.41"
    Listen 80
    Listen 443
    LoadModule mpm_prefork_module modules/mod_mpm_prefork.so
    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 proxy_module modules/mod_proxy.so
    LoadModule proxy_connect_module modules/mod_proxy_connect.so
    LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
    LoadModule proxy_http_module modules/mod_proxy_http.so
    LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so
    LoadModule proxy_scgi_module modules/mod_proxy_scgi.so
    LoadModule ssl_module modules/mod_ssl.so
    LoadModule unixd_module modules/mod_unixd.so
    LoadModule status_module modules/mod_status.so
    LoadModule autoindex_module modules/mod_autoindex.so
    <IfModule !mpm_prefork_module>
            #LoadModule cgid_module modules/mod_cgid.so
    </IfModule>
    <IfModule mpm_prefork_module>
            #LoadModule cgi_module modules/mod_cgi.so
    </IfModule>
    LoadModule dir_module modules/mod_dir.so
    LoadModule alias_module modules/mod_alias.so
    LoadModule rewrite_module modules/mod_rewrite.so
    <IfModule unixd_module>
    User daemon
    Group daemon
    </IfModule>
    ServerAdmin you@example.com
    ServerName 0.0.0.0:80
    <Directory />
        AllowOverride none
        Require all denied
    </Directory>
    DocumentRoot "/usr/local/httpd-2.4.41/htdocs"
    <Directory "/usr/local/httpd-2.4.41/htdocs">
        Options Indexes FollowSymLinks
        AllowOverride None
        Require all granted
    </Directory>
    <IfModule dir_module>
        DirectoryIndex 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/ "/usr/local/httpd-2.4.41/cgi-bin/"
    </IfModule>
    <IfModule cgid_module>
    </IfModule>
    <Directory "/usr/local/httpd-2.4.41/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
    </IfModule>
    <IfModule proxy_html_module>
    Include conf/extra/proxy-html.conf
    </IfModule>
    <IfModule ssl_module>
    SSLRandomSeed startup builtin
    SSLRandomSeed connect builtin
    </IfModule>
    Include conf/vhost.d/*.conf
    
    
    [/usr/local/httpd-2.4.41/conf]# cat vhost.d/chinasoft.cn.conf 
    <VirtualHost *:80>
        ServerAdmin webmaster@example.com
        DocumentRoot "/data/www/vhosts/chinasoft.cn"
        ServerName www.chinasoft.cn
        ServerAlias chinasoft.cn ori-www.chinasoft.cn
        errorDocument 404 /404.html
        ErrorLog "/data/www/logs/apache_log/error/chinasoft.cn_error.log"
        CustomLog "/data/www/logs/apache_log/access/chinasoft.cn_access.log" combined
    
            <IfModule mod_rewrite.c>
                    RewriteEngine on
                    RewriteCond %{HTTP_HOST} ^chinasoft.cn [NC]
                    RewriteRule ^(.*) https://www.chinasoft.cn/ [L,R=301]
            </IfModule>
    
         <Files ~ (.user.ini|.htaccess|.git|.svn|.project|LICENSE|README.md)$>
           Order allow,deny
           Deny from all
        </Files>
        
        #PHP
        <FilesMatch .php$>
                SetHandler "proxy:unix:/tmp/php-cgi.sock|fcgi://localhost"
        </FilesMatch>
        
        #PATH
        <Directory "/data/www/vhosts/chinasoft.cn">
            SetOutputFilter DEFLATE
            Options FollowSymLinks
            AllowOverride All
            Require all granted
            DirectoryIndex index.php index.html index.htm default.php default.html default.htm
        </Directory>
        
        <IfModule alias_module>
                    Alias /viewer/ /data/www/vhosts/chinasoft.cn/server/
        </IfModule>
    </VirtualHost>
    
    <VirtualHost *:443>
        ServerAdmin webmasterexample.com
        DocumentRoot "/data/www/vhosts/chinasoft.cn/"
        ServerName www.chinasoft.cn
        ServerAlias chinasoft.cn ori-www.chinasoft.cn 
        errorDocument 404 /404.html
        ErrorLog "/data/www/logs/apache_log/error/chinasoft.cn_error.log"
        CustomLog "/data/www/logs/apache_log/access/chinasoft.cn_access.log" combined
            <IfModule mod_rewrite.c>
                    RewriteEngine on
                    RewriteCond %{HTTP_HOST} ^chinasoft.cn [NC]
                    RewriteRule ^(.*) https://www.chinasoft.cn/ [L,R=301]
            </IfModule>
    
        #SSL
        SSLEngine On
        SSLCertificateFile /usr/local/nginx/conf/cert2016/chinasoft_cn.pem
        SSLCertificateKeyFile /usr/local/nginx/conf/cert2016/chinasoft_cn.key.pem
        SSLCipherSuite EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH
        SSLProtocol All -SSLv2 -SSLv3 -TLSv1
        SSLHonorCipherOrder On
        
        #PHP
        <FilesMatch .php$>
                SetHandler "proxy:unix:/tmp/php-cgi.sock|fcgi://localhost"
        </FilesMatch>
        
        
        #DENY FILES
         <Files ~ (.user.ini|.htaccess|.git|.svn|.project|LICENSE|README.md)$>
           Order allow,deny
           Deny from all
        </Files>
        
        #PATH
        <Directory "/data/www/vhosts/chinasoft.cn/">
            SetOutputFilter DEFLATE
            Options FollowSymLinks
            AllowOverride All
            Require all granted
            DirectoryIndex index.php index.html index.htm default.php default.html default.htm
        </Directory>
        
        <IfModule alias_module>
                    Alias /viewer/ /data/www/vhosts/chinasoft.cn/server/
        </IfModule>
    </VirtualHost>
  • 相关阅读:
    测试平台系列(69) 数据构造器支持sql语句
    Selenium获取动态图片验证码
    测试平台系列(68) 解决数据驱动带来的麻烦
    测试平台系列(67) 玩转数据驱动
    3班6组项目测试心得
    3班6组第一次迭代博客
    需求分析心得
    数据库设计心得
    结对编程总结
    代码欣赏
  • 原文地址:https://www.cnblogs.com/reblue520/p/12701016.html
Copyright © 2020-2023  润新知