Linux 玩法

php 跑不了,只来404

同一台linux服务器上建两个网站(www.A.com, www.B.com),现在A和B都跑起来了,但只有 A 能跑 php, B只能跑静态 html 文件,不知道哪里设置出了问题。服务器架构是 nginx+fastcgi(php)+mysql。 A.conf 和 B.conf 文件几乎一样,只是替换了相应的目录和域名。
 
查看日志:/var/log/nginx/error.log 
 
Unable to open primary script: /data/wwwroot2/test.php (Operation not permitted)" while reading response header from upstream
 
找到 /usr/local/php/etc/ > php-fpm.conf(或php.ini)
 
php_admin_value[open_basedir]=/data/wwwroot/:/tmp/:/data/wwwroot2/
 
/etc/init.d/php-fpm restart
 
参考:PHP 配置文件中open_basedir选项作用 http://www.jb51.net/article/19231.htm
 

phg 跑 curl 超时,防火墙配置(只能访问本地,不能访问外部 URL 问题解决)

iptables -A INPUT -p tcp -m tcp --sport 80 -j ACCEPT (http)
如果要访问(比如 微信sdk) https 还要添加 443(https)
如果此命令不行,直接编辑 vi /etc/sysconfig/iptables 吧,在里面添加规则:
-A INPUT -p tcp -m tcp --sport 80 -j ACCEPT
 
vi /etc/sysconfig/iptables
-A INPUT -p tcp -s 192.168.0.0/23 -m tcp --dport 22 -j ACCEPT // SFTP
 
然后重启 iptables:service iptables start
再试试:curl "http://baidu.com/"
 
(开启:chkconfig iptables on)
 
iptables -L -n
 
复习下:
service iptables status 查看iptables状态
service iptables restart iptables服务重启
service iptables stop iptables服务禁用
 

开启php的错误日志记录

/usr/local/php/bin/php /data/wwwroot/xxx.php 这样执行,输出日志
默认,php报错是不记录进日志文件,而是直接从屏幕上显示,这很不便于排查问题。打开php的错误日志记录也很简单。
编辑php.ini
log_errors = On
error_log = /usr/local/php/log/error.log
 

chmod 用法 via

将目前目录下的所有档案与子目录的拥有者皆设为 users 群体的使用者 lamport : 
chmod -R lamport:users * 
-rw------- (600) -- 只有属主有读写权限。 
-rw-r--r-- (644) -- 只有属主有读写权限;而属组用户和其他用户只有读权限。 
-rwx------ (700) -- 只有属主有读、写、执行权限。 
-rwxr-xr-x (755) -- 属主有读、写、执行权限;而属组用户和其他用户只有读、执行权限。 
-rwx--x--x (711) -- 属主有读、写、执行权限;而属组用户和其他用户只有执行权限。 
-rw-rw-rw- (666) -- 所有用户都有文件读、写权限。这种做法不可取。 
-rwxrwxrwx (777) -- 所有用户都有读、写、执行权限。更不可取的做法。 
 

CP 覆盖目录

比如 wordpress 升级时,先把 wordpress.zip 上传到 /data/wwwroot/tmp 目录,然后进入 tmp 目录 cp -r * ../ 即可

CP 目录复制

cp -ri A/* A1/ 回车
若复制过程中询问是否覆盖,输入y按回车

看端口对应的进程
netstat -lnpt
telnet ip 端口
 
cd /etc/logrotate.d/
ls -al
 cat nginx
logrotate -f /etc/logrotate.d/nginx
logrotate --force /etc/logrotate.d/nginx
 
 
echo "xxxx" > /data/wwwroot/x.html
tail access.log
 

配置 php-fpm.conf

centos:/data/log/php-fpm> 查看日志
 /etc/init.d/php-fpm reload
 
/etc/nginx/conf.d
/etc/init.d/nginx restart
 
dig a.com
 
tail -f access.log | grep 'xxx_Team'
 
SFTP 配置
vi /etc/ssh/sshd_config
原文地址:https://www.cnblogs.com/linr/p/4538303.html