首页 > 其他分享 >安装配置Apache支持https和fcgi

安装配置Apache支持https和fcgi

时间:2023-06-08 21:01:24浏览次数:45  
标签:tar apr fcgi test https apache Apache root xt


 Apache安装及配置

1.1 下载软件

1、Apr :(wget http://mirrors.hust.edu.cn/apache//apr/apr-1.5.1.tar.gz)

2、Apr-util :(wget http://mirrors.hust.edu.cn/apache//apr/apr-util-1.5.4.tar.gz)

3、Pcre :(wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.35.tar.bz2)

4、Openssl :(wget http://www.openssl.org/source/openssl-1.0.2.tar.gz)

5、Apache :(wget http://www.eu.apache.org/dist/httpd/httpd-2.4.12.tar.gz)

1.2 安装Apache

请按照下面的顺序安装:

1.2.1安装apr

[root@xt test]# tar -zxf apr-1.5.1.tar.gz  

[root@xt test]# cd  apr-1.5.1 

[root@xt apr-1.5.1]# ./configure --prefix=/usr/local/apr  

[root@xt apr-1.5.1]# make && make install 

1.2.2安装apr-util

[root@xt test]# tar -zxf apr-util-1.5.4.tar.gz  

[root@xt test]# cd apr-util-1.5.4  

[root@xt apr-util-1.5.4]# ./configure --prefix=/usr/local/apr-util -with- apr=/usr/local/apr/bin/apr-1-config  

[root@xt apr-util-1.5.4]# make && make install 

1.2.3 安装pcre

[root@xt test]#tar -xjf pcre-8.35.tar.bz2

[root@xt test]#cd pcre-8.35

[root@xt pcre-8.35]#./configure --prefix=/usr/local/pcre  

[root@xt pcre-8.35]#make && make install 

1.2.4 安装openssl

[root@xt test]#tar -zxf openssl-1.0.2.tar.gz

[root@xt test]# cd openssl-1.0.2

[root@xt openssl-1.0.2]#./config --prefix=${destination_dir} -fPIC no-gost no-shared no-zlib 

[root@xt openssl-1.0.2]#make depend ; make install

1.2.5 安装apache

[root@xt test]Tar -zcf httpd-2.4.12.tar.gz

[root@xt test]Cd httpd-2.4.12

[root@xt httpd-2.4.12]./configure --prefix=/opt/wacos/tools/apache --enable-so --enable-ssl --with-ssl=/usr/local/ssl --enable-mods-shared=all --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-pcre=/usr/local/pcre

[root@xt httpd-2.4.12]#make ; make install

1.3 配置Apache,让apache支持https和fcgi

1.3.1 对https的支持

原理:一般一个http请求默认是80端口,一个https请求默认是443端口,这就要对apache配置虚拟主机以支持同域名多端口。在apache安装目录的conf/extra文件中有一个httpd-ssl.conf文件,里面是这些内容。

Listen 443

<VirtualHost _default_:443>

DocumentRoot "/opt/wacos/tools/apache/htdocs"

ServerName www.example.com:443

ErrorLog "/opt/wacos/tools/apache/logs/error_log"

TransferLog "/opt/wacos/tools/apache/logs/access_log"

</VirtualHost >

https协议是http协议里面加了一层ssl加密过程。服务器端需要一个证书文件和一个密钥文件。下面是生成证书和密钥的过程:

1、openssl genrsa -out server.key 2048      

   运行openssl命令,生成2048位长的私钥server.key

2、openssl req -new -key server.key -out server.csr   

   输入命令以后,需要填写如下内容:

   Country Name(国家:中国填写CN)

   State or Province Name(区域或是省份:CHONGQING)

   Locality Name(地区局部名字:CHONGQING)

   Organization Name(机构名称:填写公司名)

   Organizational Unit Name(组织单位名称:部门名称)

   Common Name(网站域名)

   Email Address(邮箱地址)

   A challenge password(输入一个密码)

   An optional company name(一个可选的公司名称)

   输入完这些内容,就会在当前目录生成server.csr文件

3、openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt

   使用上面的密钥和CSR对证书进行签名

到此为止,就有了服务器私有密钥(server.key)和服务器证书(server.crt)。

接下来把密钥和证书路径添加到上面配置的虚拟主机里面:

SSLCertificateFile "/opt/wacos/tools/apache/conf/server.crt"

SSLCertificateKeyFile "/opt/wacos/tools/apache/conf/server.key"

把https的开关打开

SSLEngine on

这样就完成了对httpd-ssl.conf文件的配置。

在conf目录下有一个httpd.conf文件,打开,

找到#Include conf/extra/httpd-ssl.conf一行,把#去掉。

找到#LoadModule ssl_module modules/mod_ssl.so一行,把#去掉。

重启apache服务器,在浏览器上进行https测试。 

1.3.2 对fcgi的支持

Fcgi是一个进程,需要在apache启动的时候同时加载进程。Apache要支持fcgi,需要加载mod_fcgid.so模块。

安装mod_fcgid.so模块:

[root@xt test](wget http://www.apache.org/dist/httpd/mod_fcgid/mod_fcgid-2.3.9.tar.gz)

[root@xt test]tar -zxf mod_fcgid-2.3.9.tar.gz

[root@xt test]cd mod_fcgid-2.3.9

[root@xt test]APXS=/opt/wacos/tools/apache/bin/apxs  ./configure.apxs

[root@xt test]make && make install

安装成功后,会在module目录中生成mod_fcgid.so文件

打开httpd.conf文件,找到#LoadModule fcgid_module modules/mod_fcgid.so一行,去掉#号。添加以下代码:

<IfModule fcgid_module>
    ScriptAlias /fcgi-bin/ "/opt/wacos/tools/apache/fcgi-bin/"
    <Directory "/opt/wacos/tools/apache/fcgi-bin">
        SetHandler fcgid-script
        Options +ExecCGI
        Order allow,deny
        Allow from all
    </Directory>
</IfModule>

至此,对fcgi支持的配置已经完成。

写一个cgi程序放在fcgi-bin目录中,重启apache测试。

标签:tar,apr,fcgi,test,https,apache,Apache,root,xt
From: https://blog.51cto.com/u_16131207/6443279

相关文章

  • 解析apache的httpd.conf配置内容
    ServerRoot“/usr/local“ServerRoot用于指定守护进程httpd的运行目录,httpd在启动之后将自动将进程的当前目录改变为这个目录,因此如果设置文件中指定的文件或目录是相对路径,那么真实路径就位于这个ServerRoot定义的路径之下。ScoreBoardFile/var/run/......
  • Https基础以及如何配置Https
    一、什么是SSL证书,什么是HTTPSSSL证书是一种数字证书,它使用SecureSocketLayer协议在浏览器和Web服务器之间建立一条安全通道,从而实现:1、数据信息在客户端和服务器之间的加密传输,保证双方传递信息的安全性,不可被第三方窃听;2、用户可以通过服务器证书验证他所访问的网......
  • java 访问ingress https报错javax.net.ssl.SSLHandshakeException: Received fatal al
    一、报错及部署环境Java程序访问测试域名https方法正常,访问生产域名https域名报错,报错如下javax.net.ssl.SSLHandshakeException:Receivedfatalalert:protocol_version测试环境使用KubeSphereingress生产环境使用阿里云ACK服务的ingress配置二、问题原因客户端......
  • Linux 安装git,并且使用https方式 git pull 代码的免密操作
    删除系统自带的gityumremovegit去git下载对应安装包https://github.com/git/git/releaseswgethttps://github.com/git/git/archive/v2.21.0.tar.gz安装依赖yum-yinstallcurl-develexpat-develgettext-developenssl-develzlib-develgccperl-ExtUtils-MakeMaker解压tar......
  • 提高生产力:文件和IO操作(ApacheCommonsIO-汉化分享)
          幸运的是,ApacheCommonsIO等开源组件已经帮我们实现了。      我们可以不用重复造轮子了。1.资料地址1.1官方网站:http://commons.apache.org/proper/commons-io/1.2下载地址:http://commons.apache.org/proper/commons-io/download_io.cgi2.简要介绍(......
  • Apache Pulsar 桌面端图形化管理工具
    ApachePulsar桌面端图形化管理工具ApachePulsar是Apache软件基金会顶级项目,是下一代云原生分布式消息流平台,集消息、存储、轻量化函数式计算为一体,采用计算与存储分离架构设计,支持多租户、持久化存储、多机房跨区域数据复制,具有强一致性、高吞吐、低延时及高可扩展性等流数据......
  • 3_Installing Linux, Apache, MySQL, PHP (LAMP) Stack on Ubuntu 20.04
      地址:https://www.codewithharry.com/blogpost/lamp-stack-ubuntu-20-04/ InstallingLAMPstackonUbuntu20.04in5MinutesThispostwillexplainhowtoinstallLAMPstackonUbuntu20.04.LAMPstackconsistsofthefollowingcomponents:Linux-AnyLi......
  • harbor配置https
    1、首先需要准备好ssl证书,没有安全的ssl证书的话,可以用openssl配置harbor自签名证书生成CA证书私钥:opensslgenrsa-outca.key40962、生成CA证书(有两种配置,域名或者IP两种方式,下边分别说明)域名方式:opensslreq-x509-new-nodes-sha512-days3650\-subj"/C=CN/ST=Beijing......
  • apache2.4禁止IP访问
    如果在apache2.4想禁止使用ip访问,只能通过域名访问https是改这个配置文件conf/extra/httpd-ssl.confhttp是改这个conf/extra/httpd-vhosts.conf将下面这个配置的111.111.111.111修改为你对应的服务器IP复制到配置文件最尾部重启apache服务即可http的根据需要修改端口<Vir......
  • Apache Solr 教程_编程入门自学教程_菜鸟教程-免费教程分享
    教程简介ApacheSolr是一个开源搜索服务器。Solr是用Java语言开发的,主要基于HTTP和ApacheLucene实现。存储在ApacheSolr中的资源存储为Document对象。ApacheSolr入门教程-从基本概念开始,简单易学地了解ApacheSolr,其中包括概述,搜索引擎基础知识,Windows环境,Had......