Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to install python3.6 environment on Linux system

2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces the Linux system how to install python3.6 environment, has a certain reference value, friends in need can refer to. I hope you will learn a lot after reading this article. Next, let the editor take you to learn about it.

I. the creation of users and the installation of python3.6 environment

For a new virtual machine or server, first add the user: useradd-m ice

Add a password for the user: passwd ice

The newly created user cannot use sudo. Add sudo permissions to the created normal user:

Usermod-a-G adm wcyusermod-a-G sudo wcyvim / etc/sudoers modify user permissions

Modify ~ / .vimrc configuration

Syntax onset nuset autoindentset smartindentset tabstop=4set shiftwidth=4set showmatchset rulerset cindentset background=darkset mouse=aset mouse=h

Install python3.6

Sudo apt-get updatesudo apt-get install software-properties-commonsudo add-apt-repository ppa:jonathonf/python-3.6sudo apt-get updatesudo apt-get install python3.6cd / usr/binls | grep pythonsudo rm pythonsudo ln-s python3.6 pythonsudo apt-get install python3-pippip-- versionsudo python pip install-- upgrade pippip-- version

Install a virtual environment

Sudo pip install virtualenvsudo pip install virtualenvwrappermkdir ~ / .virtualenvssudo vim ~ / .bashrc add export WORKON_HOME=$HOME/.virtualenvs source / usr/local/bin/virtualenvwrapper.sh II, install MySQL

Enter the user name and password during installation:

Sudo apt-get install mysql-server

Log in to the database:

Sudo mysql-u root-p

Enable the full access rights of root users

Mysql-u root-puse mysql;update user set host ='% 'where user =' root';grant all privileges on *. * to 'root'@'%' identified by' your password; flush privileges;quit

Modify the ip binding in my.conf

Mysql-u root-puse mysql;update user set host ='% 'where user =' root';grant all privileges on *. * to 'root'@'%' identified by' your password; flush privileges;quit

Restart the service:

Sudo service mysql restart III. Install mongodb

Upload remotely to the server

If you directly use the scp protocol in linux:

Switch to the directory of the file to be uploaded

Scp-r file name user name @ IP (or domain name): the path where the server is uploaded

Scp user name @ IP (or domain name): upload to the local path where the server is located

You can drag directly using winscp

Using gitbash, you can simulate a linux system in the same way as (1)

Installation and configuration of mongodb

Tar-zxvf mongodb-linux-x86_64-ubuntu1604-3.4.0.tgzsudo mv mongodb-linux-x86_64-ubuntu1604-3.4.0 / / usr/local/mongodbsudo vim / etc/profile Last line add export PATH=/usr/local/mongodb/bin:$PATH save exit source / etc/profilesudo vim / etc/mongod.confverbose=trueport=27017logpath=/var/log/mongodb/logs/mongodb.loglogappend=truedbpath=/var/lib/mongodb/dbdirectoryperdb=trueauth=falsefork=truequiet=truesudo mkdir / var/log/mongodb/logs/-psudo touch / var/ Log/mongodb/logs/mongodb.logsudo mkdir / var/lib/mongodb/db-p registration boot: sudo vim / ETC _ init. D _ max _ / lib/lsb/init-functionsPROGRAM=/usr/local/mongodb/bin/mongodMONGOPID= `ps-ef | grep 'mongod' | grep-v grep | awk' {print $2} '`test-x $PROGRAM | | exit 0case "$1" instart) ulimit-n 3000log_begin_msg "Starting MongoDB server" $PROGRAM-f / etc/mongod.conflog_end_msg 0ash stop) log_begin_msg "Stopping MongoDB server" if [!-z "$MONGOPID"]; thenkill-15 $MONGOPIDfilog_end_msg 0 position position status) *) log_success_msg "Usage: / etc/init.d/mongodb {start | stop | status}" exit 1esacexit 0sudo chmod + x / etc/init.d/mongodb

Register the boot script:

Sudo update-rc.d mongodb defaults (Note: remove use of sudo update-rc.d-f mongodb remove)

Start the service:

Sudo service mongodb start

Client connection:

Mongo IV. Install redis

Install tcl:

Sudo apt-get install tcl

Extract the installation package:

Tar-zxvf redis-3.2.5.tar.gz

Create the installation directory and enter it:

Sudo mv redis-3.2.5/ / usr/local/redis cd / usr/local/redis

Compile and install:

Sudo make sudo make test sudo make install

Test:

/ usr/local/redis/src/redis-server/usr/local/redis/src/redis-cliset name iceget name

Create related directories:

Sudo mkdir / etc/redis (configuration file path) sudo mkdir / var/lib/redis (redis data storage path)

Installation Services:

Cd / usr/local/redis/utils sudo. / install_server.sh

Restart the service:

Redis-server redis-cli

Test:

Redis-server redis-cli

Configuration file:

Cd / etc/redissudo vim / etc/redis/6379.confbind 127.0.0.1 bind IPdaemonize yes whether to run requirepass password restart service as daemon: ps ajx | process number sudo redis-server / etc/redis/6379.conf corresponding to grep rediskill-9

Open the client directly:

Redis- client 5. Install git

Installation:

Sudo apt-get install git

Configure git:

Git config-global user.name "ice" git config-global user.email "152516xxxx@qq.com"

Generate the secret key:

Ssh-keygen-t rsa-C 152516xxxx@qq.com

Copy the generated key in the ~ / .ssh/ id_rsa.pub file, open the GitHub network manager, and create a public key

Verify the key:

Ssh-T git@github.com

Test:

Git clone git@github.com: username / username.git VI, nginx installation

Install the zlib dependent libraries:

Sudo apt-get install zlib1g-dev

Enter and decompress the related files:

Tar-xzvf openssl-1.0.1.tar.gztar-xzvf nginx-1.11.3.tar.gztar-xzvf pcre-8.41. Tar.gz

Enter the Nginx decompression directory:

Cd / home/ice/ nginx-1.11.3/

Configure the environment:

/ configure-- prefix=/usr/local/nginx-- with-http_ssl_module-- with-http_flv_module-- with-http_stub_status_module-- with-http_gzip_static_module-- with-pcre=../pcre-8.41-- with-openssl=../openssl-1.0.1

Compile:

Make if "pcre.h No such file or directory" appears, install "sudo apt-get install libpcre3-dev"

Installation

Sudo make install

Description:

Nginx will be installed in the / usr/local/nginx directory conf: store configuration files html: static web page logs: store log files sbin: store executable files

Related command

Start Nginx service: sudo / usr/local/nginx/sbin/nginx close Nginx service: sudo / usr/local/nginx/sbin/nginx-s stop reload configuration: sudo / usr/local/nginx/sbin/nginx-s reload specified configuration file: sudo / usr/local/nginx/sbin/nginx-c / usr/local/nginx/conf/nginx.conf View version information: sudo / usr/local/nginx/sbin/nginx-V View Port 80 program Sequence: nesta-ano | grep 80 closes the program that occupies port 80: sudo fuser-k 80/tcp

Start the service:

Sudo / usr/local/nginx/sbin/nginx or cd change to the sbin directory to execute. / nginx

Open a browser and enter the Nginx server IP address

Configuration

/ usr/local/nginx/conf/nginx.conf global settings: define global error log files, and what level you need to set to enable error_log logs/error.log;#error_log logs/error.log notice;#error_log logs/error.log info Worker_rlimit_nofile: specify the maximum number of file descriptors that can be opened by a nginx, which can be set using "ulimit-n 65535" (virtual machine default setting 1024). Ali CVM defaults to 65535events (nginx working mode) events {use epoll; linux standard working mode, nginx efficient cornerstone worker_connections 1024; define the maximum number of connections per nginx process} http (http setting) sendfile on Enable efficient file transfer mode tcp_nopush on; to prevent network blocking tcp_nodelay on;keepalive_timeout 65; set the timeout for client connection activity gzip on; uses the compression module server (host settings) server {listen 80 Server_name localhsot www.ice.xin 39.105.61.52; charser utf-8; # load balancer module, upstream is the load balancer upstream ice {server 39.105.61.52 upstream 8000 weight=1 max_fails=1 fail_timeout=300s Server 39.105.61.53 server server 8000 weight=1 max_fails=1 fail_timeout=300s;} # load balancing adopts round robin server server 39.105.61.52 weight=1 max_fails=1 fail_timeout=300s } # reverse proxy configuration. Location / {# is suitable for launching # proxy_pass http://www.ice.xin:8000; # proxy_pass http://www.ice.xin:8000; in runserver mode that comes with django. # proxy_set_header Host $http_host; # set uwsgi to launch include uwsgi_params; uwsgi_pass ice;}}

Restart the nginx service:

Sudo / usr/local/nginx/sbin/ nginx7. Deploy the Django project

Install Django:

Sudo pip install Django==1.11.4

Create a Django project: you need to turn off debugging before deployment, allowing any machine to access

Install uwsgi:

Sudo apt-get install libpython3.6-dev (2.7No installation) pip install uwsgi

Create: create a file named uwsgi.ini in the project directory

Configure uwsgi.ini:

[uwsgi] # use the function when using nginx connection, use socketsocket=0.0.0.0:8000# directly as web project server when launched, use # http=0.0.0.0:8000# project directory chdir=/home/'/project# project directory of wsgi.py files, relative to the project directory wsgi-file=project/wsgi.pyprocessess=2threads=2master=Truepidfile=uwsgi.pid# whether to start daemonize=uwsgi.log in the way of daemon

Start:

Uwsgi-ini uwsgi.ini

Stop:

Uwsgi-stop uwsgi.pid

Configure Nginx:

Add: location / static {alias / var/www/xxx/static/;} to / usr/local/nginx/conf/nginx.conf to create a storage file for static files sudo mkdir-vp / var/www/xxx/static/ sudo chmod 777 / var/www/xxx/static/

Configure static files

In settings.py add: STATIC_ROOT = 'var/www/xxx/static/'STATIC_URL =' / static/' migration static file python manage.py collectstatic thank you for reading this article carefully, hope that the editor to share the Linux system how to install python3.6 environment content to help everyone, but also hope that you support a lot, pay attention to the industry information channel, encounter problems to find, detailed solutions waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report