uwsgi

# 进入项目根目录

# 启动
# uwsgi –ini 配置文件路径
uwsgi –ini uwsgi.ini

# 重启
pkill -f uwsgi

# 停止
# uwsgi –stop 配置文件路径
uwsgi –stop uwsgi.ini
Nginx

# 启动Nginx
sudo /usr/local/nginx/sbin/nginx

# 停止Nginx
sudo /usr/local/nginx/sbin/nginx -s stop

# 重启Nginx
sudo /usr/local/nginx/sbin/nginx -s reload

# 编辑配置文件
sudo vim /usr/local/nginx/conf/nginx.conf

# 开机自动加载
sudo systemctl enable nginx
Mariadb

# 安装
sudo yum install mariadb-server

# 启动,
sudo systemctl start mariadb

# 重启
sudo systemctl restart mariadb

# 设置安全规则 配置mysql的端口
# 设置bind-ip

vim /etc/my.cnf
#在 [mysqld]:
#下面加一行
bind-address = 0.0.0.0

# 设置开机重启
systemctl enable mariadb

# 重启服务器
sudo systemctl restart mariadb
MySQL

# 启动mysql服务
sudo service mysql start

# 停止服务
sudo service mysql stop

# 重启服务
sudo servie mysql restart

# 编辑配置文件
sudo vim /ect/mysql/conf.d

# 开机自动加载
sudo systemctl enable mysqld
Redis

# 启动redis
sudo redis-server /etc/redis/redis.conf
service redis start

# 查看进程
ps aux | grep redis

# 退出redis
sudo kill -9 进程ID

# 编辑配置文件
sudo vi /etc/redis/redis.conf

# 登录客户端
sudo redis-cli -h 192.168.1.104
FastDFS

cd /etc/fdfs
# 启动服务器命令
sudo service fdfs_trackerd start
sudo service fdfs_storaged start

# 重启服务器命令
sudo service fdfs_trackerd restart
sudo service fdfs_storaged restart

# 编辑/etc/fdfs/tracker.conf配置文件
sudo vim /etc/fdfs/tracker.conf

# 编辑/etc/fdfs/storage.conf配置文件
sudo vim /etc/fdfs/storage.conf
Celery

# 在进入虚拟环境状态下
cd ~/Downloads/项目名

# 启动
celery -A celery_tasks.tasks worker -l info

# 退出
ctrl+c

# 进入python编辑器
from celery_tasks.tasks import generate_static_index

# 生成首页静态页面命令
generate_static_index.delay()
利用python一键启动所有服务器

/home/parallels/Desktop/server_strat.py

import os
# 启动服务器
nginx = os.system(“sudo /usr/local/nginx/sbin/nginx”)
redis = os.system(“sudo redis-server /etc/redis/redis.conf”)
fdfs_trackerd = os.system(“sudo service fdfs_trackerd start”)
fdfs_storaged = os.system(“sudo service fdfs_storaged start”)
# 检查服务器状态
os.system(‘ps aux | grep nginx’)
os.system(‘ps aux | grep redis’)
os.system(‘ps aux | grep fdfs_trackerd’)
os.system(‘ps aux | grep fdfs_storaged’)
# 打开项目文件夹
os.chdir(“/home/parallels/Downloads/dailyfresh”)
# 启动uwsgi
os.system(“uwsgi –ini uwsgi.ini”)
# 启动celery服务器
celery = os.system(“celery -A celery_tasks.tasks worker -l info”)
终端启动

workon 虚拟环境名
python /home/parallels/Desktop/server_strat.py
%title插图%num