2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

WSL(Ubuntu)にssh、MySQL、PHP、Apache2 を入れるまで。

Posted at

WSL(Ubuntu)にssh、MySQL、PHP、Apache2 を入れるまで。

WSL の Ubuntu をインストールする。

省略

初期設定。

// rootのパスワードを設定
$ sudo passwd root

# su -

// 日本語化
# apt install -y language-pack-ja manpages-ja manpages-ja-dev
# update-locale LANG=ja_JP.UTF8

// リポジトリ一覧の更新と、パッケージの更新。
# apt update
# apt upgrade -y

※ 途中、以下の「サービス再起動」に関して聞かれるので Yes で進む。
 Restart services during package upgrades without asking?   

// 終わったら再起動する。Windows を再起動するか、
// 管理者で Windowsコマンドプロンプト を開いて以下を実行してサービスを再起動する。
net stop LxssManager
net start LxssManager

WSLのプロンプトが見にくいので、tera term が使えるようにする。

# cd /etc/ssh
# vi sshd_config

PasswordAuthentication yes

※ この時、配色の関係で vi の画面が非常に見えにくい場合は以下を実行して色を無くす。
:syntax off

// ssh に必要なキーを作成するらしい。
# ssh-keygen -A
# service ssh start

// ここから tera term で繋ぐ。

MySQL を入れる。

// mysql が入っているかを確認。
# dpkg -l | grep mysql

// インストール(mysql-server-5.7 が入った)
# apt install mysql-server

// ↓で確認したら、mysql-client は一緒に入ってた。
# dpkg -l | grep mysql

// 起動して、とりあえず入れるところまで確認。
# service mysql start
# mysql

WindowsのCドライブは容量をあまり使いたくないのでデータディレクトリを D ドライブに移す。

// いったんプロセスを落とす。
# service mysql stop

// D ドライブを drvfs でマウントしなおす。これをしないと、chmod や chown が効かなかった。
# umount /mnt/d
# mount -t drvfs D: /mnt/d -o metadata

// my.cnf はあまり触りたくなかったのでデータディレクトリを移動して、シンボリックリンクを設定する。
# mv /var/lib/mysql /mnt/d/mysql/
# ln -s /mnt/d/mysql /var/lib/mysql

# service mysql start

php を入れる。

# apt install php

// ↑ だけで、apache2 も libapache2-mod-php も入ってきた。

# service apache2 start

// 動くか確認。
# cd /var/www/html
# echo '<?php phpinfo();' > index.php

// http://localhost/index.php で、Server API が "Apache 2.0 Handler" になっていることを確認。
2
3
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
2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?