阿里云重启后应用启动记录

我的阿里云服务器重启了,好多应用挂了,应用启动命令都忘了,想了好久才想起来,这里记录一下,以防类似情况发生

nginx 启动

1
service nginx start

nginx设置开机自启动

1
systemctl enable nginx

关闭开机启动

1
systemctl disable nginx

nginx相关命令

1
2
3
4
5
6
7
# systemctl start nginx.service          启动nginx服务
# systemctl stop nginx.service  停止服务
# systemctl restart nginx.service  重新启动服务
# systemctl list-units --type=service 查看所有已启动的服务
# systemctl status nginx.service 查看服务当前状态
# systemctl enable nginx.service 设置开机自启动
# systemctl disable nginx.service 停止开机自启动

nginx 无法访问root权限的文件内容解决方案

将 普通用户(这里是nginx用户) 添加到 root 用户组

1
usermod -G root nginx

重启nginx。问题解决

启动webhook

进入webhook目录/app/webhook

1
nohup webhookit -c webhook.py > hook.log 2>&1 &

django应用启动

我的django应用使用的uwsgi启动的,启动命令

1
uwsgi3 --ini uwsgi.ini

Python2 的话,使用 /usr/bin/uwsgi

停止命令

1
uwsgi3 --stop uwsgi.pid

重启命令

1
uwsgi3 --reload uwsgi.pid

使用supervisord管理应用

我的django应用有好几个,我使用supervisord去管理

supervisord 配置文件位置/etc/supervisord.conf
启动supervisord

1
2
3
supervisord -c /etc/supervisord.conf    #加载相应配置文件
或者
supervisord #加载默认配置文件

启动所有应用

1
supervisorctl start all

具体命令参考supervisor的用法

因为我是使用的是sock文件,启动后还需要修改sock文件的权限,直接改成777的

1
chmod -R 777 webapp.sock

启动redis

启动命令

1
./src/redis-server redis.conf

哨兵模式启动命令

1
src/redis-sentinel sentinel.conf --sentinel

启动php应用

1
service php-fpm start

在root下启动后,依然不能访问,最后排查原因发现又是是sock文件权限不够
修改php的sock文件权限,文件路径/var/run/php-fpm

1
chmod -R 777 php-fpm.sock
打赏

请我喝杯咖啡吧~

支付宝
微信