在 Solaris 里查看文件系统被进程占用常用的命令是 fuser。
Linux 里面,这个包的名字是 psmisc。
# rpm -qf /sbin/fuser
psmisc-22.20-11.el7.x86_64
因此安装这个包即可使用 fuser 命令。
# fuser .
/var/www/html: 29995c
当前目录被进程号 29995 的程序占用。
移动互联网(微信生态),物联网技术服务商
在 Solaris 里查看文件系统被进程占用常用的命令是 fuser。
Linux 里面,这个包的名字是 psmisc。
# rpm -qf /sbin/fuser
psmisc-22.20-11.el7.x86_64
因此安装这个包即可使用 fuser 命令。
# fuser .
/var/www/html: 29995c
当前目录被进程号 29995 的程序占用。
# yum install php-composer-installers
# composer config -g repo.packagist composer https://packagist.phpcomposer.com
# composer update
# composer create-project topthink/think projectname –prefer-dist
为生产环境作准备
最后提醒一下,在部署代码到生产环境的时候,别忘了优化一下自动加载:
# composer dump-autoload –optimize
安装包的时候可以同样使用–optimize-autoloader。不加这一选项,你可能会发现20%到25%的性能损失。
在 Windows 7 上安装了 Oracle Virtualbox,跑 CentOS 7 Guest。MariaDB 数据库默认侦听在 127.0.0.1。
VirtualBox 上开启两块网卡,一块做 NAT,把所有 3306 转发到 CentOS 上,一块做桥接。
enp0s3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.7.66 netmask 255.255.255.0 broadcast 192.168.7.255
enp0s8: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.0.3.15 netmask 255.255.255.0 broadcast 10.0.3.255
连接不同的界面,可以看到如下错误:
# mysql -h 192.168.7.52 -u xiaobao -p
Enter password:
ERROR 2013 (HY000): Lost connection to MySQL server at ‘reading initial communication packet’, system error: 0
# mysql -h 192.168.7.66 -u xiaobao -p
Enter password:
ERROR 2003 (HY000): Can’t connect to MySQL server on ‘192.168.7.66’ (111)
解决问题的办法就是让 MySQL 听在所有网络界面上, 即注释掉 /etc/my.cnf 里如下一行:
bind-address = 127.0.0.1
重启: # service mariadb restart
当然, 2013 错误的另外一个解决办法是添加一行:
skip-name-resolve
实际上要考虑服务器端 /etc/resolv.conf 是否正确配置。
在 Apache 配置文件 /etc/httpd/conf/httpd.conf 上加上以下两行,能隐藏具体的 Apache 版本信息以保护服务器由于潜在的漏洞而招致攻击。
ServerSignature Off
ServerTokens Prod
设置之前的 http 头:
# curl -I http://localhost/
HTTP/1.1 200 OK
Date: Fri, 19 May 2017 00:20:09 GMT
Server: Apache/2.4.6 (CentOS) OpenSSL/1.0.1e-fips
Cache-Control: max-age=0, no-cache
Content-Type: text/html; charset=UTF-8
# service httpd reload
Redirecting to /bin/systemctl reload httpd.service
设置之后的 http 头:
# curl -I http://localhost/
HTTP/1.1 200 OK
Date: Fri, 19 May 2017 00:20:19 GMT
Server: Apache
Cache-Control: max-age=0, no-cache
Content-Type: text/html; charset=UTF-8
如果还没有安装过 pip , 就用 yum install python-pip 安装,然后就升级 pip:
# pip install –upgrade pip
添加或者 renew 单独证书:
# certbot --apache -d mydomain.yj777.cn certonly
Renew 所有证书,可以把下面的行写到 cronjob。
15 3 1,15 * * /usr/bin/certbot renew –quiet
== 2018/1/20 后记:
如果运行 certbot certificates 看到错误:certbot ImportError: No module named OpenSSL
可以考虑,重新安装 pyOpenSSL 模块。
也就是先 pip uninstall certbot pyOpenSSL
再 pip install cerbot 即可, pyOpenSSL 会自动安装。
== 2018/2/5 后记:
遇到 " OSError: ctypes.util.find_library() did not manage to locate a library called 'augeas'" 错误:
yum install augeas-libs
遇到:“UnknownExtra: requests 2.6.0 has no such extra feature ‘security’” 错误:
# pip install acme –upgrade
以上基本上能解决大部分的 certbot(Let’s Encrypt) 安装和升级中发现的问题,如果还有问题,就点击联系我们,留言吧。我们会提供有偿的支持服务。
如果是在 CentOS6 上部署的话, 需要先升级 Python:
crontab 的写法,每周三,凌晨 4:00 更新:
00 4 * * 3 /usr/local/bin/certbot renew –quiet –noninteractive –installer nginx –pre-hook “service nginx stop” –post-hook “service nginx start”