Ubuntu20.04 Python Web 环境安装包含数据库、Pycharm、Nginx等软件
2021/9/24 19:10:55
本文主要是介绍Ubuntu20.04 Python Web 环境安装包含数据库、Pycharm、Nginx等软件,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
(1)sudo passwd:更改root密码
su:可以直接切换root密码
---------------------------------------------------------------------------------------------------------------------------
(2)更改源:
备份原来的源:cp -ra /etc/apt/sources.list /etc/apt/sources.list.bak
修改文件权限:chmod -R 777 /etc/apt/
修改地址:/etc/apt/sources.list,把下面的进行复制。
deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
更新缓存和升级
sudo apt-get update
sudo apt-get upgrade
sudo apt-get update --fix-missing
sudo apt-get upgrade
---------------------------------------------------------------------------------------------------------------------------
(3)安装VMwearTools:
安装方法一:
1、点击VMware虚拟机工具栏里的重新安装VMwearTools
2、把光盘里的安装文件复制到本地进行文件提取
3、sudo ./vmware-install.pl
安装方法二:
sudo apt upgrade
sudo apt install open-vm-tools-desktop -y
sudo reboot
---------------------------------------------------------------------------------------------------------------------------
(4)vim 安装
apt install vim
---------------------------------------------------------------------------------------------------------------------------
(5)mariadb安装:
设置清华大学源:
sudo apt-get install software-properties-common
sudo apt-key adv --fetch-keys 'https://mariadb.org/mariadb_release_signing_key.asc'
sudo add-apt-repository 'deb [arch=amd64,arm64,ppc64el] https://mirrors.tuna.tsinghua.edu.cn/mariadb/repo/10.5/ubuntu focal main'
sudo apt update
sudo apt -y install mariadb-server
# 安装完成 默认自启动
# 如果没有 请用如下 查看
sudo systemctl status mariadb
# 开机自启动
sudo systemctl enable mariadb --now
设置密码
sudo mysql_secure_installation
n
n
y
n
y
y
设置管理用户
命令输入 mysql
# 设置权限
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'newmariadb';
或
GRANT ALL PRIVILEGES on *.* TO 'admin'@'%' IDENTIFIED BY 'newmariadb' with grant option;
# 设置 密码
SET PASSWORD FOR root=PASSWORD('newmariadb');
# 应用刷新
flush privileges;
# 退出
exit;
设置远程可以登录和数据库软件参数
sudo vim /etc/mysql/mariadb.conf.d/50-server.cnf
把原有的127.0.0.1修改成下面的
bind-address=0.0.0.0
修改端口
sudo vim /etc/mysql/my.cnf
port = 3358
保存
sudo ufw allow 3358
最后重启
sudo systemctl restart mariadb
# 重启
sudo systemctl restart mariadb
# 启动
sudo systemctl start mariadb
# 关闭
sudo systemctl stop mariadb
# 状态
sudo systemctl status mariadb
---------------------------------------------------------------------------------------------------------------------------
(6)mysql安装
1、虚拟机网络设置成NAT模式
2、sudo apt install mysql-server
3、sudo mysql -u root -p(直接回车进入mysql)
4、创建用户和密码
CREATE USER 'root'@'%' IDENTIFIED BY 'newmysql';
5、权限赋给root用户,所有ip都能连接
GRANT ALL ON *.* TO 'root'@'%' WITH GRANT OPTION;
6、更新root密码否则,远程登录会报错
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'newmysql';
7、再次刷新
FLUSH PRIVILEGES;
8、sudo vi /etc/mysql/mysql.conf.d/mysqld.cnf
找到bind-address = 127.0.0.1 将其注释
esc
:wq(保存退出)
9、sudo ufw allow 3306
10、关掉mysql服务:sudo /etc/init.d/mysql stop
11、启动mysql服务:sudo /etc/init.d/mysql start
12、查看服务状态
sudo service mysql status
13、停止服务
sudo service mysql stop
14、启动服务
sudo service mysql start
15、重启服务
sudo service mysql restart
16、登录MySQL数据库
mysql -u root -p
17、卸载命令
需要完全清理MySQL时,可以完全卸载。
sudo apt purge mysql-*
sudo rm -rf /etc/mysql/ /var/lib/mysql
sudo apt autoremove
sudo apt autoclean
---------------------------------------------------------------------------------------------------------------------------
(7)java安装:
apt install openjdk-8-jre-headless
查看版本
java -version
---------------------------------------------------------------------------------------------------------------------------
(8)python3.8.10安装:
到官网上下载:https://www.python.org/downloads/
选择Gzipped source tarball进行下载
sudo apt-get install -y gcc make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev
然后进行解压:tar -zxvf Python-3.8.10.tgz
cd Python-3.8.10
./configure --enable-optimizations
sudo make install
sudo ln -sf /usr/local/bin/python3.8 /usr/bin/python3.8
sudo ln -sf /usr/local/bin/pip3 /usr/bin/pip3
sudo ln -sf /usr/local/bin/python3.8 /usr/bin/python
sudo ln -sf /usr/share/pyshared/lsb_release.py /usr/local/lib/python3.8/site-packages/lsb_release.py
---------------------------------------------------------------------------------------------------------------------------
(9)python3-pip安装
apt install python3-pip
pip install --upgrade pip
---------------------------------------------------------------------------------------------------------------------------
(10)sqlite3安装:
sudo apt-get install sqlite3
---------------------------------------------------------------------------------------------------------------------------
(11)pycrypto安装
pip3 install pycrypto
---------------------------------------------------------------------------------------------------------------------------
(12)net-tools安装
apt install net-tools
---------------------------------------------------------------------------------------------------------------------------
(13)spark3.0.0安装
到spark官网下载
https://mirrors.tuna.tsinghua.edu.cn/apache/spark/spark-3.0.2/spark-3.0.2-bin-hadoop2.7.tgz
https://mirrors.tuna.tsinghua.edu.cn/apache/spark/spark-3.1.1/spark-3.1.1-bin-hadoop2.7.tgz
修改文件权限:chmod -R 777 /usr/local/
把压缩包解压到/usr/local/下,并且更名为spark
vim ~/.bashrc
在下面增加两行:
export SPARK_HOME=/usr/local/spark
export PATH=${SPARK_HOME}/bin:$PATH
保存退出
最后激活环境变量
source ~/.bashrc
---------------------------------------------------------------------------------------------------------------------------
(14)py4j安装
sudo pip3 install py4j
降低log4j级别
进入spark-2.4.0-bin-hadoop2.7下面的conf目录
cp conf/log4j.properties.template conf/log4j.properties
修改参数
vim /conf/log4j.properties
将 log4j.rootCategory=INFO, console
替换为 log4j.rootCategory=ERROR, console
保存退出
---------------------------------------------------------------------------------------------------------------------------
(15)numpy安装
sudo pip3 install numpy
超快安装方法
pip3 install -i http://pypi.douban.com/simple --trusted-host pypi.douban.com numpy
运行 ./bin/pyspark
---------------------------------------------------------------------------------------------------------------------------
(16)Redis安装
sudo apt-get install redis-server
找到/etc/redis/redis.conf文件,在# requirepass foobared下面增加
requirepass 123456密码
找到bind 127.0.0.1 默认是打开的; 注释 bind 127.0.0.1 换成 bind 0.0.0.0
按esc,输入:wq进行保存退出
/etc/init.d/redis-server stop
/etc/init.d/redis-server start
/etc/init.d/redis-server restart
开放端口6379
sudo ufw allow 6379
测试:
redis-cli
redis> set foo bar
OK
redis> get foo
"bar"
如果出现(error) NOAUTH Authentication required.就输入密码auth "123456"
在执行上面的语句。
在windows里安装Another Redis DeskTop Manager,进行链接
Host:IP地址
Port:端口号
Auth:Redis密码
Name:root用户名
---------------------------------------------------------------------------------------------------------------------------
(17)Nginx安装
apt-get install nginx
查看nginx是否安装成功
nginx -v
启动nginx
cd /etc/
service nginx start
在浏览器中输入127.0.0.1可以看到nginx欢迎页面
nginx删除
sudo apt-get --purge remove nginx
---------------------------------------------------------------------------------------------------------------------------
(18)zlib安装:
sudo apt-get install zlib1g-dev
---------------------------------------------------------------------------------------------------------------------------
(19)rpm安装:
apt install rpm
---------------------------------------------------------------------------------------------------------------------------
(20)禅道安装:
https://www.zentao.net/dynamic/zentaopms15.0.stable-80347.html
下载软件,选择64位
tar -zxvf ZenTaoPMS.15.0.stable.zbox_64.tar.gz -C /opt
修改禅道自带apache、mysql端口:
修改禅道自带的apache端口: /opt/zbox/zbox -ap 8950
修改禅道自带的mysql端口: /opt/zbox/zbox -mp 9001
开启以下端口
sudo ufw allow 8950
sudo ufw allow 9001
开启禅道
/opt/zbox/zbox start
访问地址:http://localhost:8950
禅道默认管理员帐号是 admin,密码 123456
---------------------------------------------------------------------------------------------------------------------------
(21)Mongodb安装
apt-get install gnupg -y
wget -qO - https://www.mongodb.org/static/pgp/server-4.2.asc | apt-key add -
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.2 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-4.2.list
apt-get update -y
apt-get install mongodb-org -y
安装完成后,请启动MongoDB服务,并使用以下命令使其在重新启动时启动
systemctl start mongod
systemctl enable mongod
检查MongoDB服务的状态:systemctl status mongod
卸载MongoDB:
sudo apt-get --purge remove mongodb mongodb-clients mongodb-server
---------------------------------------------------------------------------------------------------------------------------
(22)mongodb-compass安装
在官网下载mongodb-compass_1.21.1_amd64.deb文件
https://www.mongodb.com/try/download/compass
点击下载的文件,右键用软件安装打开即可,在应用程序里可以找到
---------------------------------------------------------------------------------------------------------------------------
(23)clickhouse数据库安装
需要通过源码编译特定的版本进行安装
grep -q sse4_2 /proc/cpuinfo && echo "SSE 4.2 supported" || echo "SSE 4.2 not supported"
新建apt的clickhouse仓库配置:
sudo vim /etc/apt/sources.list
deb https://mirrors.tuna.tsinghua.edu.cn/clickhouse/deb/stable/ main/
添加依赖并更新apt数据库
sudo apt install dirmngr
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv E0C56BD4
sudo apt update
安装clickhouse服务端及客户端
sudo apt-get install clickhouse-client clickhouse-server
设置密码
配置远端访问
sudo chmod 600 /etc/clickhouse-server/config.xml
vim /etc/clickhouse-server/config.xml
找到<listen_host>0.0.0.0</listen_host>并且去掉注释
启动clickhouse
sudo systemctl start clickhouse-server
查看clickhouse状态
sudo systemctl status clickhouse-server
添加开机启动
sudo systemctl enable clickhouse-server
测试本地链接(密码是空的就可以,直接回车)
clickhouse-client
测试客户端登录(密码是空的就可以,直接回车)
clickhouse-client -h 192.168.31.128 -u default --password
开启9000端口
sudo ufw allow 9000
开启8123端口
sudo ufw allow 8123
运行:clickhouse-client
---------------------------------------------------------------------------------------------------------------------------
(24)Windows下安装部署DBeaver连接clickhouse
1、先安装java,因为想Dbeaver必须安装java,这里不再描述了。
2、到Dbeaver官网下载软件:https://dbeaver.io/download/
3、安装完之后打开软件在菜单上找到窗口里的首选先然后找到添加,把下面的源添加进去:
http://maven.aliyun.com/nexus/content/groups/public/
4、点击新建链接将看到所有数据,选择clickhouse,用户名和密码设置为空,输入ubuntu20.04虚拟机的IP地址即可链接成功!
5、在Pycharm里链接clickhouse,端口号是8123,然后把虚拟机的IP地址复制过来就可以了。用户名和密码由于没有进行设置所有就都为空。
---------------------------------------------------------------------------------------------------------------------------
(25)Pycharm安装
官网下载:https://www.jetbrains.com/pycharm/download/#section=linux
下载之后进行解压,然后到pycharm-2021.1.1目录的bin目录里执行./pycharm.sh,这里不要用root权限执行,用普通用户就可以。
---------------------------------------------------------------------------------------------------------------------------
(26)谷歌浏览器安装:wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo apt install ./google-chrome-stable_current_amd64.deb
这篇关于Ubuntu20.04 Python Web 环境安装包含数据库、Pycharm、Nginx等软件的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-12-13用Nginx防范DDoS攻击的那些事儿
- 2024-12-13用Terraform在AWS上搭建简单NGINX服务器指南
- 2024-10-29Nginx发布学习:从入门到实践的简单教程
- 2024-10-28Nginx发布:新手入门教程
- 2024-10-21nginx 怎么设置文件上传最大20M限制-icode9专业技术文章分享
- 2024-10-17关闭 nginx的命令是什么?-icode9专业技术文章分享
- 2024-09-17Nginx实用篇:实现负载均衡、限流与动静分离
- 2024-08-21宝塔nginx新增8022端口方法步骤-icode9专业技术文章分享
- 2024-08-21nginx配置,让ws升级为wss访问的方法步骤-icode9专业技术文章分享
- 2024-08-15nginx ws代理配置方法步骤-icode9专业技术文章分享