2018年9月

通过 sysresccd LiveCD 重置Linux系统 root 用户密码

环境:CentOS 6,SystemRescueCd

过程:

1.fdisk -l # 在 sysresccd 里先看磁盘分区情况,如本例,判断原CentOS 6 主要文件在 /dev/sda3
reset-password-1.png

2.mount /dev/sda3 /mnt/custom # 将CentOS 6文件挂载到当前的 /mnt/custom

3.chroot /mnt/custom # chroot 到 /mnt/custom

4.passwd # 更换root 用户密码

5.exit # 退出chroot
reset-password-2.png

6.重启,正常加载到CentOS 6,测试新密码生效

参考:http://www.linux-magazine.com/Online/Features/Resetting-Passwords-with-SystemRescueCd

在宝塔面板安装php5.6的ffmpeg-php扩展

感谢瓜老板。

环境:宝塔面板,php5.6

过程:

1.git clone https://github.com/nilsringersma/ffmpeg-php # 下载ffmpeg-php的相关文件

2.cd ffmpeg-php # 转到 ffmpeg-php 的目录

3./www/server/php/56/bin/phpize # 运行 phpize

4../configure --with-php-config=/www/server/php/56/bin/php-config --enable-skip-gd-check # 配置
ffmpeg-php-1.png

5.make # 编译

6.make install # 安装
ffmpeg-php-2.png

7.在软件管理,php5.6的设置窗口里,打开配置文件,在末尾加上:extension=/www/server/php/56/lib/php/extensions/no-debug-non-zts-20131226/ffmpeg.so
ffmpeg-php-3.png

8.重载php5.6后,在phpinfo中,可以看到ffmpeg的相关信息
ffmpeg-php-4.png

参考:

在 web.py 中用阿里云的免费证书设置https访问

网友发帖问,所以有此实践。

环境:Debian9,python2.7

过程:

1.pip install web.py # 安装 web.py,本例版本是 web.py-0.39
webpy-1.png

2.pip install pyOpenSSL # 还需安装这个包
webpy-2.png

3.vi test.py # 创建测试文件,内容如下:(请替换相应的ssl证书存储路径)

import web
from web.wsgiserver import CherryPyWSGIServer

CherryPyWSGIServer.ssl_certificate = "/root/swas.anqun.org.pem"
CherryPyWSGIServer.ssl_private_key = "/root/swas.anqun.org.key"

urls = ("/.*", "hello")
app = web.application(urls, globals())

class hello:
    def GET(self):
        return 'Hello, world!'

if __name__ == "__main__":
    app.run()

webpy-3.png

4.python test.py # 运行测试,默认在8080端口上
webpy-4.png

5.在浏览器里访问,如本例,https://swas.anqun.org:8080,正常
webpy-5.png

参考:http://webpy.org/cookbook/ssl

在IIS 7 里添加 .7z 文件 MIME类型

环境:Windows 2008 R2

过程:

图1:在浏览器地址栏里输入完整的.7z文件网址,提示404 - 找不到文件或目录
iis-mime-7z-0.png

图2:在IIS站点管理界面,打开 “MIME 类型”
iis-mime-7z-1.png

图3:点击“添加”,增加文件扩展名为.7z,MIME类型为 application/octet-stream
iis-mime-7z-2.png

图4:保存设置后。再在浏览器里访问.7z文件网址,浏览器会弹框提示保存到哪了
iis-mime-7z-3.png

参考:

替换typecho默认模板中外部的http文件链接为https

新版本的浏览器,对包含http文件链接的站点访问,不显示绿色的。使用谷歌浏览器访问本博客,会在地址栏右端显示“不运行不安全的脚本”。通过浏览器自带的F12调试工具,知道是外部的一个css和两个js脚本文件引用地址(cdn.staticfile.org)是http,并不是https开头的。

操作:

1.转到typecho文件目录,执行 grep -rnw './' -e 'cdn.staticfile.org' 查看到http网址引用,在 usr/themes/default/header.php 中
typecho-js-https-1.png

2.sed -i 's/http:\/\/cdn.staticfile.org/https:\/\/cdn.staticfile.org/g' usr/themes/default/header.php 用https替换http
typecho-js-https-2.png

3.再次在浏览器测试,谷歌浏览器显示网页是https的,正常

参考: