Linux(Ubuntu)相关应用快速部署(数据库等常用)

环境示例:
Ubuntu 16.04.6 LTS
Python 3.5.2
Mysql 14.14 Distrib 5.7.30
Redis 4.x.x
Nginx 1.12.2

说明:minconda适用各种linux,其他皆为ubuntu环境下

1 安装miniconda(python环境)
wget https://repo.anaconda.com/miniconda/Miniconda3-py310_23.1.0-1-Linux-x86_64.sh #下载脚本
sh Miniconda3-py39_4.12.0-Linux-x86_64.sh # 执行
~/miniconda3/bin/conda init #初始化Shell,以便直接运行conda
conda create --name d2 python=3.9 #关启shell,创建虚拟环境
conda activate d2 #激活 d2环境

2 安装redis(6379)
sudo apt-get install redis-server #安装
ps -ef|grep redis #检查
redis-cli #登录

启动路径 /usr/local/redis/bin/redis-server
配置文件路径:sudo vim /etc/redis/redis.conf

3 安装mysql(3306)
sudo apt-get install mysql-server #安装
配置root,密码:1234
mysql uroot -p #登录
use mysql;
update user set host='%' where user='root'; #修改数据
vim /etc/mysql/mysql.conf.d/mysqld.cnf #修改bind-address =0.0.0.0
service mysql restart #重启

配置文件路径:sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf

4.安装mongodb (27017)
导入公钥
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 0C49F3730359A14518585931BC711F9BA15703C6
创建源文件
echo "deb [ arch=amd64,arm64 ] http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.4.list
sudo apt-get update #更新本地数据包
sudo apt-get install -y mongodb-org #安装
vim /etc/mongodb.conf # 修改bind_ip = 127.0.0.1,your_server_ip
sudo systemctl restart mongodb #重启
mongo --eval 'db.runCommand({ connectionStatus: 1 })' #查看版本等信息

配置文件路径:vim /etc/mongod.conf
参考:https://juejin.cn/post/6977209790267621412

5 安装Nginx
sudo apt-get install nginx #安装
vim /etc/nginx/nginx.conf(主目录) #配置文件路径
vim /etc/nginx/conf.d/meanning12.conf (项目配置文件)
nginx #首次输入直接启动,不得再次输入
nginx -s reload #平滑重启,重新读取nginx的配置文件,而不重启进程
nginx -s stop #停止
nginx -t #检测nginx.conf语法

配置文件路径:vim /etc/nginx/nginx.conf(主目录)

6 安装uwsgi
pip3 install uwsgi #安装
touch uwsgi.ini #构建配置文件
uwsgi --ini uwsgi.ini #启动命令

7 安装supervisor
pip install supervisor #安装
echo_supervisord_conf > /etc/supervisord.conf #添加配置文件
mkdir -p /etc/supervisor.d // supervisord 支持include 的方式将多个配置放置不同文件中, 需要配置文件中指定
supervisord -c /etc/supervisord.conf #启动

参考文章:https://www.cnblogs.com/huahuawang/p/15232013.html

相关配置示例下载路径:https://www.aliyundrive.com/s/wT3yEXR7wBc(0x5r)

 

######systemctl 控制 systemd 服务#######

以mongo示例,其他以此类推

sudo systemctl enable mongodb #开机自启
sudo systemctl disable mongodb #禁止开机自启

sudo systemctl status mongodb #查看
sudo systemctl stop mongodb #停止
sudo systemctl start mongodb #启动
sudo systemctl restart mongodb #重启

 

posted @ 2023-04-27 17:07  风hua  阅读(29)  评论(0编辑  收藏  举报