配置

0 基本信息

服务器os centos 7

1. 安装编译环境

  yum install zlib-devel bzip2-devel  openssl-devel ncurses-devel

2.安装python3

  • 下载
wget --no-check-certificate https://www.python.org/ftp/python/3.6.5/Python-3.6.5.tgz
  • 创建安装目录解压
sudo mkdir /usr/local/python3

tar -zxvf Python-3.6.5.tgz

cd Python-3.6.5/
  • 编译安装
sudo ./configure --prefix=/usr/local/python3 # 指定创建的目录
sudo make
sudo make install # 编译安装
  • 创建软链接
sudo ln -s /usr/local/python3/bin/python3 /usr/bin/python3  # python3 软链接
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3  # pip3软链接

3.安装node环境

  • 安装编译环境
    yum -y install gcc make gcc-c++  openssl-devel wget
  • 安装版本10.14.2
ver=10.14.2  # 此处为版本号
wget -c https://nodejs.org/dist/v$ver/node-v$ver.tar.gz
tar -xzf node-v$ver.tar.gz
cd node-v$ver
./configure && make && sudo make install
  • 验证安装成功
node -v

4. gunicorn 配置

  • 安装Gunicorn
    pipenv shell
    pipenv install gunicorn
  • 采用python文件作为配置
   """
    异步gevent方式
   """
   from gevent import monkey;monkey.patch_all()
   import mutilprocessing
   debug = True   # 是否开启debug
   loglevel = 'debug'
   bind = '127.0.0.1:5000'  # 服务器地址
   pidfile = '/var/log/sips/gunicorn.pid'
   logfile = '/var/log/sips/gunicorn.log'
   workers = multiprocessing.cpu_count() * 2 + 1  # worker数量
   timeout = 30     # 同步worker的过期时间,选用异步没用
   worker_class = 'gevent'

5.nginx命令

  • 启动
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
  • 重启
cd /usr/local/nginx/sbin
./nginx -s reload

Mysql安装配置

  • 安装
下载并安装MySQL官方的 Yum Repository
wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
yum -y install mysql57-community-release-el7-10.noarch.rpm
yum -y install mysql-community-server
  • 启动
systemctl start  mysqld.service  # 启动mysql 
systemctl restart  mysqld.service  # 重启mysql
systemctl stop  mysqld.service    # 暂停mysql
systemctl status  mysqld.service  # mysql状态
  • 获得初始密码
grep "password" /var/log/mysqld.log
  • 防火墙端口
firewall-cmd --zone=public --add-port=3306/tcp --permanent
  • 重启防火墙
systemctl restart firewalld.service
  • 查看所有开放的端口
firewall-cmd --list-ports

Redis安装配置

  • 安装
yum install redis
  • 启动
# 启动redis
service redis start
# 停止redis
service redis stop
# 查看redis运行状态
service redis status
# 查看redis进程
ps -ef | grep redis
  • 开机自动启动
chkconfig redis on
  • redis-cli
redis-cli
  • 开放redis端口
firewall-cmd --zone=public --add-port=637/tcp --permanent

推荐阅读更多精彩内容