LoginSignup
3
2

More than 5 years have passed since last update.

Windows Subsystem for Linux(旧bash on windows)からPhpStormを動かす

Last updated at Posted at 2018-05-21

グッバイcmder

ヾ(・ω<)ノ" 三三三● ⅱⅲ コロコロ♪

関連記事
* Bash on Ubuntu on Windowsを使う(1)
* Bash on Ubuntu on Windowsを使う(2):初期設定
* Bash on Ubuntu on Windowsを使う(3):WindowsからLinuxを使う


------------------- ↓ 余談はここから ↓-------------------

Windows Creators Update以降、
Windows上で動作するLinux環境が充実してきた。
現在では

とストアに並び、
自由にインストール。
ターミナルを実行すれば簡単にLinux環境が動く上、
Cygwinと違いエミュレータではないので高速動作する。

私はPhpStormというIDEを使っているが、
これにはターミナルが実装されていて、
Pathを指定すればWSL上のPHPも実行することができる。
PathがWindowsと異なり、
ほとんど使い物にならない。

そこで発想を変えてPhpStormをWSL上で動かすことができるのか調べてみたところ、
どうやら不可能ではないらしい。


------------------- ↓ 本題はここから ↓-------------------

PhpStorm on Debian GNU/Linux

VcXsrv Windows X Serverのインストール

XサーバーにはVcXsrvを使います。
以下のページよりファイルをダウンロードしてWindows上でインストールする
https://sourceforge.net/projects/vcxsrv/files/vcxsrv/

ダウンロードファイルを実行して、
何も考えずNextを押しましょう。
実行後もNextを連打。
常駐させておく。

以下を参考にどうぞ。

参考:
http://vogel.at.webry.info/201612/article_3.html

WSLのインストール

こちらは主題ではないので、
別の記事を参考にインストールしてほしい。
ここではDebian GNU/Linuxを使っている。

各種パッケージは予め入れておく
$ sudo apt-get install bash-completion build-essential x11-apps libxtst6 git 
localeの状態を確認
$ sudo apt-get install task-japanese
# sudo vi /etc/locale.gen
ja_JP.UTF-8の行のコメントを解除
$ sudo locale-gen
$ sudo update-locale LANG=ja_JP.UTF-8
$ locale
LANG=ja_JP.UTF-8
LANGUAGE=
LC_CTYPE="ja_JP.UTF-8"
LC_NUMERIC="ja_JP.UTF-8"
LC_TIME="ja_JP.UTF-8"
LC_COLLATE="ja_JP.UTF-8"
LC_MONETARY="ja_JP.UTF-8"
LC_MESSAGES="ja_JP.UTF-8"
LC_PAPER="ja_JP.UTF-8"
LC_NAME="ja_JP.UTF-8"
LC_ADDRESS="ja_JP.UTF-8"
LC_TELEPHONE="ja_JP.UTF-8"
LC_MEASUREMENT="ja_JP.UTF-8"
LC_IDENTIFICATION="ja_JP.UTF-8"
LC_ALL=
X11設定
$ set -o noclobber # 念のため
$ echo 'export DISPLAY=localhost:0.0' >> ~/.bashrc
$ source ~/.bashrc
XWindow動作確認
$ xeyes &

xwindow01_xeyes.PNG

PhpStormのインストール

準備

PhpStormダウンロードページでLinux版を選択。
「DOWNLOAD」ボタンを押す。
次のページにでてくる「direct link」のアドレスをコピーしておく。
(ダウンロード自体は停止)

例:https://download.jetbrains.com/webide/PhpStorm-2018.1.4.tar.gz

WSL上でダウンロード

適当なディレクトリにダウンロードする。

$ cd
$ wget https://download.jetbrains.com/webide/PhpStorm-2018.1.4.tar.gz

/optに展開する

$ sudo tar xvf PhpStorm-2018.1.4.tar.gz -C /opt/
$ cd /opt/PhpStorm-181.5087.24
インストーラーを実行
$ /opt/PhpStorm-181.5087.24/bin/phpstorm.sh &

普通にPhpStormのインストーラーが起動するので、
Windowsに入れるようにインストールする。

Complete-Installation_017.png


------------------- ↓ 後書はここから ↓-------------------

普通にインストーラーを実行すると以下のエラーが出る。

$ sudo /opt/PhpStorm-181.5087.24/bin/phpstorm.sh

Start Failed: Internal error. Please report to http://jb.gg/ide/critical-startup-errors

com.intellij.ide.plugins.PluginManager$StartupAbortedException: java.lang.reflect.InvocationTargetException
        at com.intellij.ide.plugins.PluginManager.a(PluginManager.java:80)
        at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at com.intellij.ide.plugins.PluginManager.a(PluginManager.java:77)
        ... 1 more
Caused by: java.lang.UnsatisfiedLinkError: /opt/PhpStorm-181.5087.24/jre64/lib/amd64/libawt_xawt.so: libXtst.so.6: cannot open shared object file: No such file or directory
        at java.lang.ClassLoader$NativeLibrary.load(Native Method)
        at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1941)
        at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1824)
        at java.lang.Runtime.load0(Runtime.java:809)
        at java.lang.System.load(System.java:1086)
        at java.lang.ClassLoader$NativeLibrary.load(Native Method)
        at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1941)
        at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1845)
        at java.lang.Runtime.loadLibrary0(Runtime.java:870)
        at java.lang.System.loadLibrary(System.java:1122)
        at java.awt.Toolkit$3.run(Toolkit.java:1636)
        at java.awt.Toolkit$3.run(Toolkit.java:1634)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.awt.Toolkit.loadLibraries(Toolkit.java:1633)
        at java.awt.Toolkit.<clinit>(Toolkit.java:1673)
        at com.intellij.ui.AppUIUtil.updateFrameClass(AppUIUtil.java:154)
        at com.intellij.idea.StartupUtil.prepareAndStart(StartupUtil.java:89)
        at com.intellij.idea.MainImpl.a(MainImpl.java)
        at com.intellij.idea.MainImpl.start(MainImpl.java:41)
        ... 6 more


Also, an UI exception occurred on attempt to show above message:
java.lang.NoClassDefFoundError: Could not initialize class java.awt.Toolkit
        at java.awt.Component.<clinit>(Component.java:597)
        at com.intellij.idea.Main.showMessage(Main.java:174)
        at com.intellij.idea.Main.showMessage(Main.java:150)
        at com.intellij.ide.plugins.PluginManager.processException(PluginManager.java:147)
        at com.intellij.ide.plugins.PluginManager$1.uncaughtException(PluginManager.java:65)
        at java.lang.Thread.dispatchUncaughtException(Thread.java:1956)

libxtst6がインストールされていないのが原因。

$ sudo apt-get install libxtst6
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