LoginSignup
4
5

More than 5 years have passed since last update.

サーバにPython環境の構築とデータの転送

Posted at

開発環境

  • Linux
  • bash

サーバにPython環境の構築

 まず、サーバにPython環境を構築したいユーザアカウントでログインします。その後、ホームディレクトリで下記のコマンドを実行します。

$ git clone https://github.com/yyuu/pyenv.git .pyenv
$ mkdir .pyenv/shims .pyenv/versions
$ cd .pyenv/plugins
$ git clone https://github.com/yyuu/pyenv-virtualenv.git

 上記のコマンドが完了したら、.bashrcに下記のプログラムを追記します。

export PYENV_ROOT=~/.pyenv
export PATH=~/.pyenv/shims:~/.pyenv/bin:/usr/local/bin:$PATH
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"

 その後、下記のコマンドを実行すると、環境変数を反映させることができます。

$ source .bashrc

データの転送

 ローカル環境にあるファイルをサーバ上に転送するためには、scpコマンドを実行します。scpの使い方は下記のようになっています。

scp ローカル環境上にある転送したいファイルのパス ユーザ名@リモートホスト名:保存先のパス

 理解しやすいように、例を挙げて説明します。
 それぞれの要素が下記の具体例で与えられたとします。その場合は、下記のコマンドのようになります。

要素 具体例
ローカル環境上にある転送したい
ファイルのパス
/usr/home/box/data.txt
ユーザ名 chocolate
リモートホスト名 apple
保存先のパス /home/chocolate
# ファイルを転送する場合
scp /usr/home/box/data.txt chocolate@apple:/home/chocolate

# フォルダごと転送する場合
scp -r /usr/home/box chocolate@apple:/home/chocolate
4
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
5