1.安装supervisor

yum install -y supervisor

安装supervisor.jpg

2.配置config文件

  vim /etc/supervisord.conf

进入配置界面
配置界面2.png
□配置访问 将127.0.0.1:9001 修改为0.0.0.0:9001 所有都可以访问 user password就是访问用户和密码 自定义即可
1.png
□配置子配置进程文件
2.png
3.supervisor的常规操作

开机启动supervisor

systemctl enable supervisord

启动supervisor

systemctl start supervisord

停止supervisor

systemctl stop supervisord

查看supervisor状态

systemctl status supervisord

重载supervisor配置

supervisorctl reload

查看supervisor使用的端口

ps aux | grep supervisord

卸载supervisor

yum -y remove supervisor

停止supervisor所有进程

supervisorctl stop all

4.开启防火墙
A、腾讯云或阿里云 安全组添加9001端口(自行在服务商处理)
B、服务器开放端口

firewall-cmd --query-port=9001/tcp          //监测端口是否开启
firewall-cmd --add-port=9001/tcp            //开启80端口
firewall-cmd --remove-port=9001/tcp       //关闭80端口
sudo firewall-cmd --reload                  //重新加载配置

5.其他
查询系统日志命令

journalctl -xe

   /usr/bin/supervisord -c /etc/supervisord.conf 

6.常见问题

error: <class 'socket.error'>, [Errno 2] No such file or directory: file: /usr/lib64/python2.7/socket.py line: 224

解决:

/usr/bin/python2 /usr/bin/supervisord -c /etc/supervisord.conf

supervisorctl管理命令

supervisorctl status        //查看所有进程的状态
supervisorctl stop [all]|[x]    //停止所有或指定关闭x
supervisorctl start [all]|[x]    //启动所有或指定启动x
supervisorctl restart       //重启es
supervisorctl update        //配置文件修改后使用该命令加载新的配置
supervisorctl reload        //重新启动配置中的所有程序

    #转发机制
location /{
    index  index.html index.htm;
    if (!-e $request_filename) {
        rewrite ^/(.*) /index.html last;
        break;
    }
}

 实现:https://h5.xxx.com/mobile/acticity/album?id=1

function get_init_field($table){
            //$table=$this->request->param('model');
            $dbname = Config::get('database.database');
            $prefix = Config::get('database.prefix');
            $sql="select COLUMN_NAME ,DATA_TYPE from information_schema.COLUMNS where TABLE_SCHEMA = ? and table_name = ? and DATA_TYPE = 'int'";
            $columnList = Db::query($sql, [$dbname, $table]);
            $fieldlist = [];
            foreach ($columnList as $index => $item) {
            $fieldlist[] = $item['COLUMN_NAME'];
            }
            return json($fieldlist);
}

名词解释

$table 即为表名
$dbname 数据库名
$prefix 数据库前缀

命令

select COLUMN_NAME ,DATA_TYPE from information_schema.COLUMNS where TABLE_SCHEMA ='washbox' and table_name = 'fa_user' and DATA_TYPE = 'int';

SELECT
    TABLE_NAME,
    DATA_LENGTH + INDEX_LENGTH,
    TABLE_ROWS,
    concat(round((DATA_LENGTH + INDEX_LENGTH) / 1024 / 1024,2),'MB') AS DATA
FROM
    information_schema. TABLES
WHERE
    TABLE_SCHEMA = 'washbox' -- 数据库名
ORDER BY
    DATA + 0 DESC;

最近在做一个数据库管理功能,用于计算数据库资源情况。方便维护。

在centos7.5主机部署了lnmp1.8环境
部署thinkphp5的程序时候,rewrite转发配置正常。但显示空白,经过多番研究,发现是fastcgi的安全目录open_Dir问题
/usr/local/nginx/conf
【fastcgi.conf】
大概在26-27行

# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param  REDIRECT_STATUS    200;
#未改前
#fastcgi_param PHP_ADMIN_VALUE "open_basedir=$document_root/:/tmp/:/proc/";
#修改后
fastcgi_param PHP_ADMIN_VALUE "open_basedir=$document_root/../:/tmp/:/proc/";

OK 大功告成