摘要: centos7安装python开发环境(python3,postgresql,sublime,supervisor)

一. 安装gnome

1.最小化安装centos7。
2.安装X11。yum groupinstall "X Window System"。
3.安装gnome。全安装:yum groupinstall -y "GNOME Desktop"。最小安装:yum install gnome-classic-session gnome-terminal。 nautilus-open-terminal control-center liberation-mono-fonts。
4.开机启动图形界面:ln -sf /lib/systemd/system/graphical.target /etc/systemd/system/default.target。
5.重启:reboot。
6.安装字体:yum groupinstall Fonts。
7.更新字体缓存: fc-cache。
8.安装优化工具:yum install gnome-tweak-tool.noarch。
9.安装归档工具:yum install file-roller。

二.安装python3

1.官网下载python。
2.解压下载好的压缩包。
3.创建目录mkdir /usr/local/python_3.5.2。
4.进入解压目录sudo ./configure --prefix=/usr/local/python_3.5.2 。
5.make。
6.make install。
7.创建连接 ln -s /usr/local/python_3.5.2/bin/python3.5  /usr/local/bin/python3。
说明:yum和supversion等使用python2,所以不将/usr/bin/python连接到python3.使用python3时加#!/usr/bin/env python3。
8.python资源。编程网站:The Python Challenge,Project Euler。语法参考:《python学习手册》,官方网站。

三.安装PostgreSQL9.5

1.下载。在postgresql的官方即可找到源码文件目录,地址如下:https://www.postgresql.org/ftp/source/,在下载列表中根据需求选择版本。
2. 配置编译安装。进入pg压缩包目录通过tar -zxvf ./postgresql-9.5.5.tar.gz进行解压,进入解压目录。通过./configure --help可以看到编译相关的帮助信息。编译时指定一个安装目录./configure --prefix=/usr/local/postgresql。配置完成了。接下来就可以编译安装了:make install clean。(新系统安装过程中可能出现的问题)没有c编译器,提示缺少readline库,缺少zlib库。分别执行yum install gcc,yum install readline-devel,yum install zlib-devel。
3.用户权限与环境变量。编译安装成功后,接下来要做的就是创建一个普通用户,因为默认超级用户(root)不能启动postgresql,所以需要创建一个普通用户来启动数据库,执行以下命令创建用户:useradd postgres。接下来需要设置权限,将postgres的数据目录全部赋权给postgres用户(此处我将postgres的数据目录指定在在/usr/local/postgresql/data目录下):chown -R postgres:postgres /usr/local/postgresql/。最后为了方便起见设置一下相关的环境变量,此处仅仅设置postgres用户的环境变量,所以首先通过su - postgres切换到postgres用户,打开.bash_profile文件并追加以下内容:PGHOME=/usr/local/postgresql,export PGHOME,PGDATA=/usr/local/postgresql/data,export PGDATA。 ln -s /usr/local/postgresql/bin/pg_ctl  /usr/local/bin/pg_ctl。
4.初始化数据库。由于配置了环境变量,所以此处我们直接执行initdb即可完成db初始化,但在这之前我们可以通过initdb --help看一下初始化相关的帮助信息。可以看到在使用initdb进行初始化的同时我们可以指定参数来同时进行一些初始化工作,例如指定pgdata(postgresql数据目录)、指定encoding(编码)、指定数据库超级用户的用户名和密码等等,在最后面我标记出的这段话指出了如果data目录没有指定,则会默认使用环境变量中的PGDATA,由于之前我们刚刚设置了PGDATA环境变量,所以此处我们也就无需再额外指定,最后执行初始化命令即可:initdb。同时在postgresql的目录可以看到生成的数据目录data以及该目录的相关数据和配置文件。
5.配置文件。pg_hba.conf和postgresql.conf两个配置文件,一个是访问控制配置(127.0.0.1改为信任的客户端ip网段使其可以远程访问),一个是postgresql主配置文件(listen_address=localhost改为星号使其监听整个网络),方便起见我这里将pg_hba.conf的ip地址修改为0.0.0.0/0,而加密方式改为md5,就表示需要密码访问,算是提供一个最低级的安全防护。开放pg的5432端口。
6.将端口加入防火墙。firewall-cmd --zone=public --add-port=5432/tcp --permanent 或者 firewall-cmd --add-service=postgresql --permanent  开放postgresql服务firewall-cmd --reload 重载防火墙
7.启动和连接。pg_ctl start -D /usr/local/postgresql/data -l /usr/local/postgresql/log/pg_server.log
8.设置postgres用户的密码(默认为空)。切换用户,su - postgres。登录数据库,psql -U postgres ,执行后提示符变为 'postgres=#'。设置postgres用户密码, ALTER USER postgres WITH PASSWORD 'abc123'  ,会提示输入两次密码。退出数据库, \q  。
9.postgresql服务脚本。vim /lib/systemd/system/postgresql.service 。# It's not recommended to modify this file in-place, because it will be# overwritten during package upgrades.  If you want to customize, the# best way is to create a file "/etc/systemd/system/postgresql.service",# containing#   .include /lib/systemd/system/postgresql.service#   ...make your changes here...# For more info about custom unit files, see# http://fedoraproject.org/wiki/Systemd#How_do_I_customize_a_unit_file.2F_add_a_custom_unit_file.3F# For example, if you want to change the server's port number to 5433,# create a file named "/etc/systemd/system/postgresql.service" containing:#   .include /lib/systemd/system/postgresql.service#   [Service]#   Environment=PGPORT=5433# This will override the setting appearing below.# Note: changing PGPORT or PGDATA will typically require adjusting SELinux# configuration as well; see /usr/share/doc/postgresql-*/README.rpm-dist.# Note: do not use a PGDATA pathname containing spaces, or you will# break postgresql-setup.# Note: in F-17 and beyond, /usr/lib/... is recommended in the .include line# though /lib/... will still work.[Unit]Description=PostgreSQL database serverAfter=network.target[Service]Type=forkingUser=postgresGroup=postgres# Port number for server to listen onEnvironment=PGPORT=5432# Location of database directoryEnvironment=PGDATA=/usr/local/postgresql_9.6.2/data# Where to send early-startup messages from the server (before the logging# options of postgresql.conf take effect)# This is normally controlled by the global default set by systemd# StandardOutput=syslog# Disable OOM kill on the postmasterOOMScoreAdjust=-1000ExecStart=/usr/local/postgresql_9.6.2/bin/pg_ctl start -D ${PGDATA} -s -o "-p ${PGPORT}" -w -t 300 -l /usr/local/postgresql_9.6.2/data/log/pg_server.logExecStop=/usr/local/postgresql_9.6.2/bin/pg_ctl stop -D ${PGDATA} -s -m fastExecReload=/usr/local/postgresql_9.6.2/bin/pg_ctl reload -D ${PGDATA} -s# Give a reasonable amount of time for the server to start up/shut downTimeoutSec=300[Install]WantedBy=multi-user.target
10.自启动脚本都能够添加到systemctl自启动服务。systemctl enable postgresql.servicesystemctl start/restart/stop postgresql.service

四.安装supervisor。

1.安装supervisor。pip install supervisor。
2.产生配置文件。echo_supervisord_conf > /usr/local/etc/supervisord.conf。
3.supervisor服务启动脚本。vim /lib/systemd/system/supervisord.service 。supervisord开机自启动脚本(各版本系统):https://github.com/Supervisor/initscripts 。# supervisord service for systemd (CentOS 7.0+)# by ET-CS (https://github.com/ET-CS)[Unit]Description=Supervisor daemon[Service]Type=forkingExecStart=/usr/bin/supervisord -c /usr/local/etc/supervisord.confExecStop=/usr/bin/supervisorctl $OPTIONS shutdownExecReload=/usr/bin/supervisorctl $OPTIONS reloadKillMode=processRestart=on-failureRestartSec=42s[Install]WantedBy=multi-user.target
4.自启动脚本都能够添加到systemctl自启动服务。systemctl enable supervisord.servicesystemctl start/restart/stop supervisor.service

五.安装Sublime Text 3。

1.下载解压。进入解压目录:ln -s /usr/local/sublime-text-3/sublime_text  /usr/local/bin/sublime3。
2.安装插件管理器。从 Sublime Text 3 官方获取用于安装Package Control 的代码。依次点击 View > Show Console (快捷键Ctrl + `)打开控制台。在控制台中粘贴官方代码,然后点击回车。最后重启。
3.安装插件。主题Flatland,Agila,Material Theme,Brogrammer;扩展侧边栏中菜单选项SideBarEnhancements;终极 Python 插件Anaconda;文件创建AdvancedNewFile;版本控制git;函数生成描述DocBlockr_python;代码静态检查工具框架SublimeLinter-pyflakes。
4.配置。修改快捷键 Sublime Text > Preferences > Package Settings > 插件 > Key Bindings – User。修改配置Sublime Text > Preferences > Package Settings > 插件 > Settings – User。
5.配置python3版本。Sublime Text > Preferences > Package Settings >Anaconda> Settings – default。将"python_interpreter": "python"改为"python_interpreter": "python3"。
文章来源:https://yq.aliyun.com/articles/78727?utm_campaign=wenzhang&utm_medium=article&utm_source=QQ-qun&201759&utm_content=m_20124

centos7安装python开发环境(python3,postgresql,sublime,supervisor)相关推荐

  1. Windows下Eclipse+PyDev安装Python开发环境

    1.简介 Eclipse是一款基于Java的可扩展开发平台.其官方下载中包括J2EE方向版本.Java方向版本.C/C++方向版本.移动应用方向版本等诸多版本.除此之外,Eclipse还可以通过安装插 ...

  2. mac怎么安装python开发环境搭建_Mac OS搭建Python开发环境

    简书 Wwwwei 转载请注明原创出处,谢谢! 前言 最近在看一些关于机器学习的内容,其中大量代码需要Python的运行环境,所以搭建了Python开发环境,这里记录下,方便大家学习. 安装Pytho ...

  3. 如何确定python开发环境已经配置好_python学习第一天:window安装python开发环境完整篇...

    Python是跨平台的,它可以运行在Windows.Mac和各种Linux/Unix系统上: 要开始学习Python编程,首先就得把Python安装到电脑里.安装后,你会得到Python解释器(就是负 ...

  4. win7安装python开发环境,运行python

    在win7上安装python的开发环境是非常简单的事情 Step1:下载python安装文件 url:https://www.python.org/download 去这里找到你想要下载的文件 Ste ...

  5. CentOS7安装PHP开发环境1-源码安装Nginx

    OS:CentOS 7 Nginx:1.16.0 目录 安装后的脚本 重启nginx.PHP脚本 开机启动脚本 安装前的准备 1.安装Nginx所需的pcre库 2.安装Nginx所需的openssl ...

  6. 1.6 Mac安装Python开发环境

    考虑到部分同学使用Mac系统,下面介绍下Mac下的相关Python开发方法.由于受众相对小众,介绍可能内容不全,更多内容要做好多搜索的思想准备:) 1)安装Python 仍然也是在Python官网下载 ...

  7. Ubuntu16.04 安装Python开发环境

    安装Pycharm Pycharm下载与准备 官网下载无需多言:https://www.jetbrains.com/pycharm/download/#section=linux 安装JDKUbunt ...

  8. sublime搭建python开发环境_使用sublime搭建python开发环境

    sublime Text具有漂亮的用户界面和强大的功能,例如代码缩略图,Python的插件,代码段等.还可自定义键绑定,菜单和工具栏.Sublime Text的主要功能包括:拼写检查,书签,完整的 P ...

  9. mac如何安装python_手把手教你安装Python开发环境(二)之Mac电脑安装Python解释器...

    Mac电脑使用的操作系统为OSX,系统本身自带Python2.X的解释器.但目前主流的Python核心系统是3.X,所以我们建议都安装最新的版本进行操作.以下就是Python3.X解释器在Mac电脑上 ...

  10. VS2022安装Python开发环境

    1 前言 对习惯使用VS2022,VS2019--编辑和调试C\C++\C#的同学来说,能不能在VS2022中开发和调测Python程序呢?答案是肯定的.如果您已经会在VS20XX中编辑调测Pytho ...

最新文章

  1. 【FFmpeg】AVPacket的使用详解
  2. 清除webBrowser 缓存和Cookie的解决方案
  3. springboot整合flink
  4. 桃李不言,下自成蹊——《大数据》编辑部祝各位老师节日快乐!
  5. mysql 5.7 my default_Windows64位mysql5.7以上版本包解压中没有data目录和my-default.ini及服务无法启动的快速解决办法(问题小结)...
  6. android 获取linux线程状态,Android 的进程与线程总结
  7. 在Java中使用标准输入输出设备进行字符串,整数浮点数等 的输入输出操作
  8. 机器学习:激活函数的作用和原理
  9. 2022年C语言教程入门和最新C语言自学教程C语言进阶教程大全
  10. 2021 全国大学生电子设计竞赛题目
  11. kali免杀工具Veil Evasion
  12. web 应用程序与桌面应用程序的区别与优缺点
  13. 04 分布式文件系统以及MapReduce入门程序
  14. 芝法酱躺平攻略(5)—— SpringBoot编写公主连结公会战报刀工具
  15. python零基础网站制作_为做网站而准备
  16. Windows安装ADB驱动
  17. 怎样引流推广?一文讲透引流的核心秘密
  18. 挥泪裁测试员?软件测试六边形战士技能,互联网裁员潮不存在的......
  19. 移动硬盘加密软件TrueCrypt使用指南
  20. python怎么换背景颜色_Python给照片换底色(基于opencv模块)

热门文章

  1. 自动排单功能的一些思考
  2. linux网络lo是什么,Linux基礎必懂:eth0,eth1,eth2,lo是什么意思?
  3. educoder考试可以切屏吗_线上考试真的好多人作弊吗?
  4. ubuntu_使用ros显示imu的状态(6)
  5. mysql连接失败问题
  6. 一台服务器​最大并发 tcp 连接数多少?65535?
  7. python中哈希是什么意思_python hash是什么
  8. 电脑版微信多开的三种方法
  9. 【Matlab元胞自动机】元胞自动机双边教室疏散【含源码 1208期】
  10. 导出微信聊天记录并输出