频道栏目
首页 > 资讯 > Linux > 正文

Linux系统下apache软件安装教程

17-04-20        来源:[db:作者]  
收藏   我要投稿

Linux系统下apache软件安装教程。

yum install -y httpd httpd-manual 安装apache软件

systemctl start httpd ; systemctl enable httpd 启动apache服务

查看监听端口:

ss -antlp |grep httpd

LISTEN

0

128

:::80

:::*

users:((“httpd”,4347,4),(“httpd”,4346,4),(“httpd”,4345,4),(“httpd”,4344,4),(“httpd”

,4343,4),(“httpd”,4342,4))

www.westos.org

3Apache主配置文件: /etc/httpd/conf/httpd.conf

ServerRoot “/etc/httpd” 用于指定Apache的运行目录

Listen 80 监听端口

User apache 运行apache程序的用户和组

Group apache

ServerAdmin root@localhost 管理员邮箱

DocumentRoot “/var/www/html” 网页文件的存放目录

###!/usr/bin/perl

print “Content-type: text/html\n\n”;

print date;

[root@httpserver cgi]# chmod +x index.cgi

[root@httpserver html]# vim /etc/httpd/conf/httpd.conf

178

179 DirectoryIndex test.html index.html index.cgi

180

[root@httpserver cgi]# systemctl restart httpd

[root@httpserver cgi]# setenforce 0

[root@httpserver cgi]# semanage fcontext -l | grep http

/var/www/[^/]/cgi-bin(/.)? all files system_u:object_r:httpd_sys_script_exec_t:s0

[root@httpserver cgi]# ls -Zd /www/html/cgi/

[root@httpserver cgi]# semanage fcontext -a -t “httpd_sys_content_t” ‘/www/html/cgi(/.*)?’

修改安全上下文

[root@httpserver cgi]# restorecon -FvvR /www/html/cgi 扫描

restorecon reset /www/html/cgi context unconfined_u:object_r:httpd_sys_content_t:s0->system_u:object_r:httpd_sys_content_t:s0

restorecon reset /www/html/cgi/index.cgi context unconfined_u:object_r:httpd_sys_content_t:s0->system_u:object_r:httpd_sys_content_t:s0

[root@httpserver cgi]# vim /etc/httpd/conf/httpd.conf

[root@httpserver cgi]# cat /etc/httpd/conf/httpd.conf

DirectoryIndex test.html index.html index.cgi

自定义自签名证书

如果加密的通信非常重要,而经过验证的身份不重要,管理员可以通过生成self-

signed certificate来避免与认证机构进行交互所带来的复杂性。

使用genkey实用程序(通过crypto-utils软件包分发),生成自签名证书及其关联的

私钥。为了简化起见,genkey将在“正确”的位置(/etc/pki/tls目录)创建证书及其

关联的密钥。相应地,必须以授权用户(root)身份运行该实用程序。

生成自签名证书

1. 确保已安装crypto-utils软件包。

[root@server0 ~]# yum install crypto-utils mod_ssl

2. 调用genkey,同时为生成的文件指定唯一名称(例如,服务器的主机全名)。

–days可以指定证书有效期

[root@server0 ~]# genkey server0.example.com

www.westos.org

12记录生成的证书(server0.example.com.crt)和关联的私钥(

server0.example.com.key)的位置

www.westos.org

13继续使用对话框,并选择合适的密钥大小。(默认的2048位密钥为推荐值)

www.westos.org

14在生成随机数时比较慢,敲键盘和移动鼠标可以加速

www.westos.org

15拒绝向认证机构(CA)发送证书请求(CSR)。

拒绝加密私钥

www.westos.org

16为服务器提供合适的身份。Common Name必须与服务器的主机全名完全匹配。

(注意,任何逗号都应使用前导反斜线[]进行转义)

www.westos.org

17安装证书及其私钥

1. 确定已安装mod_ssl软件包。

[root@server0 ~]# yum install mod_ssl

2. 由于私钥是敏感信息,请确保其只被root用户读取。

[root@server0 ~]# ls -l /etc/pki/tls/private/server0.example.com.key

-r——–. 1 root root 1737 Dec 22 15:06 /etc/pki/tls/private/server0.example.com.key

3. 编辑/etc/httpd/conf.d/ssl.conf, 将SSLCertificateFile和SSLCertificateKeyFile指令设置为分别指

向X.509证书和密钥文件。

SSLCertificateFile /etc/pki/tls/certs/server0.example.com.crt

SSLCertificateKeyFile /etc/pki/tls/private/server0.example.com.key

4. 重启Web服务器。

[root@server0 ~]# systemctl restart httpd

5. 如要进行确认,请使用https协议(https://serverX.example.com)通过Web客户端(如Firefox

)访问Web服务器。

Web客户端可能会发出它不认可证书发行者的警告。这种情况适用自签名证书。要求Web客户端

绕过证书认证。(对于Firefox,请选择“I Understand the Risks” [我了解风险]、“Add Exception” [

添加例外]和“Confirm Security Exception”[确认安全例外]。)

www.westos.org

18网页重写

把所有80端口的请求全部重定向由https来处理

相关TAG标签
上一篇:[RK3288][Android6.0] 调试笔记 --- 开机默认选择24小时制时间格式
下一篇:黑客入侵 阿里云发布Windows系统高危漏洞修复方案
相关文章
图文推荐

关于我们 | 联系我们 | 广告服务 | 投资合作 | 版权申明 | 在线帮助 | 网站地图 | 作品发布 | Vip技术培训 | 举报中心

版权所有: 红黑联盟--致力于做实用的IT技术学习网站