Foundation
-
不用三方包 给 Laravel 开启 Swoole,分享
Swoole 是一款优秀的 PHP 扩展,利用其可以实现原生 PHP 很难做到的常驻服务和异步。正好我有个 Laravel 项目可以折腾,就研究了下。 Laravel 项…
-
使用 Docker 来开发 PHP,Laradock 系列 3:Mailhog,分享
当应用程序已经注册或订阅用户时,发送邮件可能是必不可少的功能之一。 在开发过程中,我们倾向于使用 SMTP 测试服务器,例如 mailtrap.io。 Mailtrap …
-
Laravel之Contracts和Facades详解,分享
Contracts Contracts其实就是倡导面向接口编程,来达到解耦的目的。而这些通用的接口已经由Laravel为你设计好了。就是这些Contracts. 那么…
-
关于PHP7.0与PHP5.6下Laravel博客应用性能对比分析详解,分享
目前我安装的 Homestead 虚拟机版本是 2.1.8: 该版本 Homestead 上预装的 PHP 版本是 5.6.15: 我们使用 ab 命令(Apache 提供的性能测…
-
新品分析:Windows Server 2008 Foundation分享
Windows Server 2008 Foundation是微软近期推出的一款面向小企业的Windows Server版本,该版本专为不超过15名用户的小企业量身打造,是结合…
-
sed 替换、修改链接文件注意问题网站安全分享!
sed 替换、修改链接文件注意问题#系统与版本
[root@localhost ~]# cat /etc/redhat-release
CentOS release 6.8 (Final)
[root@localhost ~]# sed –version
GNU sed version 4.2.1
Copyright (C) 2009 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE,
to the extent permitted by law.因为sed -i /etc/sysconfig/selinux(selinux文件是/etc/selinux/config的软链接)配置文件重启SELINUX没有关闭,才发现原来sed -i是不能直接修改软链接文件的,如下我修改之后的后果:
[root@localhost ~]# ll /etc/sysconfig/selinux
lrwxrwxrwx. 1 root root 17 Dec 20 11:31 /etc/sysconfig/selinux -> ../selinux/config
[root@localhost ~]# ll /etc/selinux/config
-rw-r–r–. 1 root root 458 Dec 20 11:31 /etc/selinux/config[root@localhost ~]# sed -i “s/SELINUX=enforcing/SELINUX=disabled/g” /etc/sysconfig/selinux
[root@localhost ~]# ll /etc/sysconfig/selinux
-rw-r–r–. 1 root root 457 Dec 22 19:18 /etc/sysconfig/selinux我们发现链接文件不再是链接文件了,后来查看sed –help选项时发现如下选项说明
–follow-symlinks
follow symlinks when processing in place; hard links will still be broken.-i[SUFFIX], –in-place[=SUFFIX]
edit files in place (makes backup if extension supplied). The default operation mode is to
break symbolic and hard links. This can be changed with –follow-symlinks and –copy.-c, –copy
use copy instead of rename when shuffling files in -i mode. While this will avoid breaking
links (symbolic or hard), the resulting editing operation is not atomic. This is rarely the
desired mode; –follow-symlinks is usually enough, and it is both faster and more secure.#测试
[root@localhost ~]# echo “test” >>test
[root@localhost ~]# ln -s test test-zsq
[root@localhost ~]# ll -i test-zsq #链接文件
260727 lrwxrwxrwx. 1 root root 4 Dec 22 19:21 test-zsq -> test
[root@localhost ~]# cat test-zsq
test#如果直接-i删除,链接文件将失效
[root@localhost ~]# sed -i “s/test//g” test-zsq
[root@localhost ~]# ll -i test-zsq
260726 -rw-r–r–. 1 root root 1 Dec 22 19:29 test-zsq#重新添加再测试,加上-c选项
[root@localhost ~]# rm -rf test-zsq
[root@localhost ~]# ln -s test test-zsq
[root@localhost ~]# ll -i test-zsq
260726 lrwxrwxrwx. 1 root root 4 Dec 22 19:33 test-zsq -> test
[root@localhost ~]# echo “test” >>test
[root@localhost ~]# sed -i -c ‘/test/d’ test-zsq
[root@localhost ~]# ll -i test-zsq
260726 lrwxrwxrwx. 1 root root 4 Dec 22 19:33 test-zsq -> test#–follow-symlinks选项
[root@localhost ~]# rm -rf test-zsq
[root@localhost ~]# ln -s test test-zsq
[root@localhost ~]# echo “test” >> test
[root@localhost ~]# cat test
test
[root@localhost ~]# sed -i –follow-symlinks ‘/test/d’ test
[root@localhost ~]# ls -l test-zsq
lrwxrwxrwx. 1 root root 4 Dec 22 19:50 test-zsq -> test
[root@localhost ~]# cat test–follow-symlinks比-c选项更快更安全
-c, –copy
use copy instead of rename when shuffling files in -i mode.
While this will avoid breaking links (symbolic or hard), the
resulting editing operation is not atomic. This is rarely
the desired mode; –follow-symlinks is usually enough, and
it is both faster and more secure.链接文件/etc/rc.local也是/etc/rc.d/rc.local的软连接,用sed添加删除启动服务要特别注意
有可能配置的链接文件失效而导致服务起不来在centos 5.x系列中运行相同的操作没有出现类似的现象
经查是sed的版本不同造成的影响,centos 5系列的还是使用老版本的sed,没有–follow-symlinks类似的选项[root@DNS ~]# sed –version
GNU sed version 4.1.5
Copyright (C) 2003 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE,
to the extent permitted by law.
[root@DNS ~]# sed –help
Usage: sed [OPTION]… {script-only-if-no-other-script} [input-file]…-n, –quiet, –silent
suppress automatic printing of pattern space
-e script, –expression=script
add the script to the commands to be executed
-f script-file, –file=script-file
add the contents of script-file to the commands to be executed
-i[SUFFIX], –in-place[=SUFFIX]
edit files in place (makes backup if extension supplied)
-c, –copy
use copy instead of rename when shuffling files in -i mode
(avoids change of input file ownership)
-l N, –line-length=N
specify the desired line-wrap length for the `l’ command
–posix
disable all GNU extensions.
-r, –regexp-extended
use extended regular expressions in the script.
-s, –separate
consider files as separate rather than as a single continuous
long stream.
-u, –unbuffered
load minimal amounts of data from the input files and flush
the output buffers more often
–help display this help and exit
–version output version information and exit