Linux 第十二周上课笔记 阿帕奇服务

apache

[[email protected] ~]# yum install httpd -y

[[email protected] html]# yum install httpd-manual -y

更改默认发布文件

[[email protected] html]# vim /etc/httpd/conf/httpd.conf

更改默认发布目录

[[email protected] html]# mkdir /www/westos -p

[[email protected] html]# semanage fcontext -a -t httpd_sys_content_t ‘/www/westos(/*)?‘

[[email protected] html]# restorecon -RvvF /www/

restorecon reset /www context unconfined_u:object_r:default_t:s0->system_u:object_r:default_t:s0

restorecon reset /www/westos context unconfined_u:object_r:default_t:s0->system_u:object_r:httpd_sys_content_t:s0

[[email protected] html]# cd /www/westos/

[[email protected] westos]# vim index.html

[[email protected] westos]# ls -Z

-rw-r--r--. root root unconfined_u:object_r:httpd_sys_content_t:s0 index.html

[[email protected] westos]# vim /etc/httpd/conf/httpd.conf

120 DocumentRoot "/www/westos"

121 <Directory "/www/westos">

122     Require all granted

123 </Directory>

[[email protected] westos]# systemctl restart http

[[email protected] westos]# vim /etc/httpd/conf/httpd.conf

120 DocumentRoot "/www/westos"

121 <Directory "/www/westos">

122     Require all granted

123     Order Allow,Deny

124     Allow from All

125     Deny from 172.25.254.209

126 </Directory>

[[email protected] westos]# systemctl restart http

[[email protected] westos]# vim /etc/httpd/conf/httpd.conf

120 DocumentRoot "/www/westos"

121 <Directory "/www/westos">

122     Require all granted

123     Order Deny,Allow

124     Allow from ALL

125     Deny from 172.25.254.209

[[email protected] westos]# systemctl restart http

[[email protected] westos]# vim /etc/httpd/conf/httpd.conf

120 DocumentRoot "/www/westos"

121 <Directory "/www/westos">

122     Require all granted

123     Order Deny,Allow

124     Allow from 172.25.254.9

125     Deny from ALL

用户认证

[[email protected] httpd]# htpasswd -cm htpasswdfile admin

New password:

Re-type new password:

Adding password for user admin

[[email protected] httpd]# htpasswd -m htpasswdfile westos

New password:

Re-type new password:

Adding password for user westos

[[email protected] westos]# vim /etc/httpd/conf/httpd.conf

120 DocumentRoot "/www/westos"

121 <Directory "/www/westos">

122    # Require all granted

123    AllowOverride All

124    Authuserfile /etc/httpd/htpasswdfile

125    Authname "Please input username and passwd"

126    Authtype basic

127    Require user admin

128 </Directory>

[[email protected] httpd]# systemctl restart httpd

[[email protected] westos]# vim /etc/httpd/conf/httpd.conf

120 DocumentRoot "/www/westos"

121 <Directory "/www/westos">

122    # Require all granted

123    AllowOverride All

124    Authuserfile /etc/httpd/htpasswdfile

125    Authname "Please input username and passwd"

126    Authtype basic

127    Require valid-user

128 </Directory>

[[email protected] httpd]# systemctl restart httpd

[[email protected] ~]# cd /var/www/html/

[[email protected] ~]# vim index.html

www.westos.com

[[email protected] ~]# mkdir /var/www/virtual/news.westos.com/html -p

[[email protected] ~]# cd /var/www/virtual/news.westos.com/html

[[email protected] html]# vim index.html

[[email protected] html]# mkdir /var/www/virtual/music.westos.com/html -p

[[email protected] html]# cd /var/www/virtual/music.westos.com/html

[[email protected] html]# vim index.html

[[email protected] html]# cd /etc/httpd/conf.d/

[[email protected] conf.d]# vim default.conf

<Virtualhost _default_:80>

Documentroot /var/www/html

Customlog "logs/default.log" combined

</Virtualhost>

<Directory "/var/www/html">

Require all granted

</Directory>

[[email protected] conf.d]# vim news.conf

<Virtualhost *:80>

Servername news.westos.com

Documentroot /var/www/virtual/news.westos.com/html

Customlog "logs/default.log" combined

</Virtualhost>

<Directory "/var/www/virtual/news.westos.com/html">

Require all granted

</Directory>

[[email protected] conf.d]# vim music.conf

<Virtualhost *:80>

Servername music.westos.com

Documentroot /var/www/virtual/music.westos.com/html

Customlog "logs/default.log" combined

</Virtualhost>

<Directory "/var/www/virtual/music.westos.com/html">

Require all granted

</Directory>

[[email protected] conf.d]# systemctl restart httpd.service

测试机上的更改

vim /etc/hosts

172.25.254.109 www.westos.com westos.com news.westos.com music.westos.com

https

[[email protected] conf.d]# yum install mod_ssl -y

[[email protected] conf.d]# yum install crypto-utils -y

[[email protected] conf.d]# genkey www.westos.com

/usr/bin/keyutil -c makecert -g 1024 -s "CN=www.westos.com, OU=linux, O=westos, L=xi‘an, ST=shannxi, C=CN" -v 1 -a -z /etc/pki/tls/.rand.9611 -o /etc/pki/tls/certs/www.westos.com.crt -k /etc/pki/tls/private/www.westos.com.key

cmdstr: makecert

cmd_CreateNewCert

command:  makecert

keysize = 1024 bits

subject = CN=www.westos.com, OU=linux, O=westos, L=xi‘an, ST=shannxi, C=CN

valid for 1 months

random seed from /etc/pki/tls/.rand.9611

output will be written to /etc/pki/tls/certs/www.westos.com.crt

output key written to /etc/pki/tls/private/www.westos.com.key

Generating key. This may take a few moments...

Made a key

Opened tmprequest for writing

/usr/bin/keyutil Copying the cert pointer

Created a certificate

Wrote 882 bytes of encoded data to /etc/pki/tls/private/www.westos.com.key

Wrote the key to:

/etc/pki/tls/private/www.westos.com.key

[[email protected] conf]# cd /etc/httpd/conf.d

[[email protected] conf.d]# vim ssl.conf

100 SSLCertificateFile /etc/pki/tls/certs/www.westos.com.crt

107 SSLCertificateKeyFile /etc/pki/tls/private/www.westos.com.key

[[email protected] conf.d]# systemctl restart httpd.service

测试机

网页重写与虚拟主机的https

[[email protected] html]# cd /etc/httpd/conf.d/

[[email protected] conf.d]# firewall-cmd --permanent --add-service=http

success

[[email protected] conf.d]# firewall-cmd --permanent --add-service=https

success

[[email protected] conf.d]# firewall-cmd --reload

success

[[email protected] conf.d]# vim music.conf

<Virtualhost *:80>

Servername music.westos.com

RewriteEngine on                           允许网页重写

RewriteRule ^(/.*)$ https://%{HTTP_HOST}$1 [redirect=301]     ##重写为https

</Virtualhost>

<Directory "/var/www/virtual/music.westos.com/html">

Require all granted                      ##授权

</Directory>

<Virtualhost *:443>                                  ##443端口

Servername music.westos.com

Documentroot /var/www/virtual/music.westos.com/html

Customlog "logs/default-443.log" combined     ##产生的日志放在logs/default-443.log 下

SSLEngine on                       ##开启认证

SSLCertificateFile /etc/pki/tls/certs/www.westos.com.crt      ##证书

SSLCertificateKeyFile /etc/pki/tls/private/www.westos.com.key ##钥匙

</Virtualhost>

[[email protected] conf.d]# vim news.conf

<Virtualhost *:80>

Servername news.westos.com

RewriteEngine on

RewriteRule ^(/.*)$ https://%{HTTP_HOST}$1 [redirect=301]

</Virtualhost>

<Directory "/var/www/virtual/news.westos.com/html">

Require all granted

</Directory>

<Virtualhost *:443>

Servername news.westos.com

Documentroot /var/www/virtual/news.westos.com/html

Customlog "logs/news-443.log" combined

SSLEngine on

SSLCertificateFile /etc/pki/tls/certs/www.westos.com.crt

SSLCertificateKeyFile /etc/pki/tls/private/www.westos.com.key

</Virtualhost>

[[email protected] conf.d]# systemctl restart httpd

测试机操作

[[email protected] ~]# vim /etc/hosts

172.25.254.109 www.westos.com westos.com news.westos.com music.westos.com

打开firefox输入http://music.westos.com 会自动跳转为https://music.westos.com.

php

[[email protected] html]# vim index.php

<?php

phpinfo ();

?>

[[email protected] html]# vim /etc/httpd/conf/httpd.conf

163     DirectoryIndex index.php index.html

[[email protected] html]# chmod +x /var/www/html

[[email protected] html]# systemctl restart httpd.service

cgi

[[email protected] html]# mkdir cgi

[[email protected] html]# yum install http-manual -y

[[email protected] html]# cd cgi/

vim index.cgi

#!/usr/bin/perl

print "Content-type: text/html\n\n";

print `date`;

[[email protected] html]# cd /etc/httpd/conf.d/

[[email protected] conf.d]# vim default.conf

<Virtualhost _default_:80>

DocumentRoot /var/www/html

Customlog "logs/default.log" combined

</Virtualhost>

<Directory "/var/www/html">

Options +ExecCGI

AddHandler cgi-script .cgi

</Directory>

[[email protected] conf.d]# chmod +x /var/www/html/cgi/*

[[email protected] conf.d]# semanage fcontext -a -t httpd_sys_script_exec_t ‘/var/www/html/cgi/(/.*)?‘

[[email protected] conf.d]# restorecon -RvvF /var/www/html/cgi/

[[email protected] conf.d]# systemctl restart httpd.service

论坛

[[email protected] html]# yum install mariadb -y  安装数据库

若没有安装数据库,安装后要进行安全设置。因为一般情况下我们不会把数据库的端口裸露在外,所以要隐藏端口。

[[email protected] html]# vim /etc/my.cnf

10 skip-networking=1

[[email protected] html]# netstat -antlpe | grep mariadb

[[email protected] html]# setenforce 0

[[email protected] html]# systemctl start mariadb

下载论坛安装包

Discuz_X3.2_SC_UTF8.zip

[[email protected] html]# unzip Discuz_X3.2_SC_UTF8.zip

[[email protected] html]# chmod 777 upload/ -R

时间: 2024-10-08 17:06:08

Linux 第十二周上课笔记 阿帕奇服务的相关文章

Linux第十二周

1.请描述一次完整的http请求处理过程: 1.建立TCP连接 2.Web浏览器向Web服务器发送请求 3.Web浏览器发送请求头信息 建立连接后,客户机发送一个请求给服务器,请求方式的格式为:统一资源标识符(URL).协议版本号,后边是MIME信息包括请求修饰符.客户机信息和可能的内容 4.Web服务器应答 服务器接到请求后,给予相应的响应信息,其格式为一个状态行,包括信息的协议版本号.一个成功或错误的代码,后边是MIME信息包括服务器信息.实体信息和可能的内容. 5.Web服务器发送应答头信

面向对象程序设计-C++ Type conversion (Static) &amp; Inheritance &amp; Composition【第十二次上课笔记】

这节课继续讲解了 static 作为静态数据成员 / 成员函数的用法 具体详解我都已注释出来了,大家可以慢慢看 有任何问题都可以在这篇文章下留言我会及时解答 :) //static 静态数据成员 //static 静态成员函数 #include <iostream> using namespace std; class Integer { public: int i; static int number; //Declaration, 整个类只有一个版本,所有对象共享 //const stat

第十二周学习笔记

先检查有没有对应类型的接口,没有必须先到网上下载,重新开启SQL SEVER即可 64位以上的系统必须用 Microsoft Ace Oledb 12.0 版本的 要选对数据库 没有查询到表格的可以建立表格 用INSERT INTO 语句可以插入数据 ----------删除 删除格式代码,可以用子查询来当做删除条件,如下图所示

Linux第五周上课笔记(1),rpm软件安装,yum源,yum仓库

第五周上课笔记 一.应用软件的安装 1.认识软件:|libmp3lame0|-3.99.3-23|.el7|.x86_64|.rpm 软件名     软件版本   适用系统 64位  红帽适用软件 2.如何安装软件 1.rpm rpm      -vih    name.rpm      安装,-v:显示过程,-h:指定加密方式为哈希加密 -e      name          卸载 -q      name          查询软件生成文件 -qlp  name.rpm        查

2017-2018-1 《Linux内核原理与设计》第十二周作业

<linux内核原理与设计>第十二周作业 Sql注入基础原理介绍 分组: 和20179215袁琳完成实验 一.实验说明 ??SQL注入攻击通过构建特殊的输入作为参数传入Web应用程序,而这些输入大都是SQL语法里的一些组合,通过执行SQL语句进而执行攻击者所要的操作,本章课程通过 LAMP 搭建 Sql 注入环境,两个实验分别介绍 Sql 注入爆破数据库.Sql 注入绕过验证两个知识点. 首先通过下面命令将代码下载到实验楼环境中,作为参照对比进行学习. $ wget http://labfil

学习进度第十二周

  第十二周 所花时间(包括上课) 11h(4h上课,7课下) 代码量(行) 220 博客量(篇) 1 了解到的知识点 这个星期主要进行了安卓实验和大作业的编写,从中学到了利用安卓SQLite 数据库 进行表的存储以及应用,按照教程成功编写了一个特别小的视频播放器,学会了进度 条等控件的使用.

学习进度-第十二周

  第十二周 所花时间(包括上课) 10小时 代码量(行) 48行 博客量(篇) 3篇 了解到的知识点

第十二周学习进度

第十二周:   第十二周 所花时间(包括上课) 上课4小时,课后4小时 代码量(行) 160 博客量 1 了解到的知识点 找水王

20145317《信息安全系统设计基础》第十二周学习总结1

20145317<信息安全系统设计基础>第十二周学习总结1 教材学习内容总结 第九周学习内容总结http://www.cnblogs.com/5317p/p/6052889.html 第十周学习内容总结http://www.cnblogs.com/5317p/p/6076074.html 第十一周学习内容总结http://www.cnblogs.com/5317p/p/6106708.html 视频学习内容总结 指针与声明 C语言中变量的声明包括两个部分: 类型 声明符 对于简单类型,声明并不