LoginSignup
3
2

More than 3 years have passed since last update.

作った vue アプリケーションをubuntuとapache2でawsにデプロイする方法

Posted at

環境

ubuntu 18.04
apache2 2.4

今回はawsで開発していきます。
インスタンスを作成して、ssh接続をしたところから解説していきます.

今回はapache2を使うので、
インバウンドで80ポートを開放しておかないとapache2が適応されないので注意してください。

$ sudo apt update
$ sudo apt install apache2
$ sudo apt install nodejs
$ sudo apt install npm
$ sudo apt purge nodejs npm
$ npm install --save

と順番に打って必要なモジュールをインストールします。

次にデプロイするアプリケーションを引っ張ってきます。

先にローカルで作っておいたファイルをgithubで保存して、それをダウンロードしていきます。

$ git clone <githubのパス>.git

次に本番環境用のディレクトリを作ります。
アプリケーションを作る際に特に設定をいじっていなかったら

$ npm run build

でデプロイ用のディレクトリ(dist)が作れると思います。

次にapache2の設定を書き換えていきます。

$ vim cd /etc/apache2/sites-available/vue.conf

(confファイルの名前はなんでもいい)

/etc/apache2/sites-available/vue.conf

<VirtualHost *:80>
  ServerName <パブリックdns>または<パブリックipアドレス>
  DocumentRoot git colneを打ったディレクトリの絶対パス/dist
</VirtualHost>

と書き換えます。

これで完成です。

3
2
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
3
2