顯示具有 jetbrains 標籤的文章。 顯示所有文章
顯示具有 jetbrains 標籤的文章。 顯示所有文章

2021-10-03

安裝 jetbrains projector 並以 user systemd 方式啟動

 安裝很簡單,直接參考github官方網站:
https://github.com/JetBrains/projector-installer

設定:
projector config list
projector config  edit <APP_NAME>

憑證:
若有用let's encrypt,可直接用如下指令安裝,記得憑證過期一樣要再重安裝一次
(APP_NAME可能為IntelliJ或DataGrip,可參照 ~/.projector/configs):

projector install-certificate <APP_NAME> --certificate /etc/letsencrypt/live/<change.to.your.site.com>/fullchain.pem --key /etc/letsencrypt/live/<change.to.your.site.com>/privkey.pem;

以下補充如何以user systemd的方式自啟動,這樣ide點擊exit或reload時就會重新啟動,也不用登入tty,以下以新增 IntelliJ IDEA為例:
mkdir -p ~/.config/systemd/user/
vi ~/.config/systemd/user/idea.service
加入:
======================
[Unit]
Description=Jetbrains Projector - IDEA

[Service]
Type=simple
#注意這裡要改為用 run.sh 執行
ExecStart=%h/.projector/configs/IntelliJ/run.sh
Restart=always

[Install]
WantedBy=default.target
======================
再執行(以一般使用者身份執行即可)
systemctl --user start idea
systemctl --user status idea
systemctl --user enable idea
#不用tty登入也可reboot時自啟動
loginctl enable-linger <username> 

ref:
https://youtrack.jetbrains.com/issue/PRJ-298
https://wiki.archlinux.org/title/systemd/User#Automatic_start-up_of_systemd_user_instances

2021-09-08

安裝jetbrains projector (Server Side)

 1.先依照github頁面步驟安裝projector
https://github.com/JetBrains/projector-installer#Installation

2.幫機器設定一個domain,並記得修改/etc/hostname

3.幫domain上letsencrypt憑證(不需要裝http server,因為我們需要的只是憑證而已),對外的80 port防火牆記得開。譬如OS是Ubuntu 20.04就照著選,伺服器選「None of the above」(cerbot已自帶http伺服器可自動認證)
https://certbot.eff.org/lets-encrypt/ubuntufocal-other

且certbot會產生systemd service及timer以後會自動更新憑證:
/etc/systemd/system/snap.cerbot.renew.service
/etc/systemd/system/snap.cerbot.renew.timer

4.安裝ide: projector install,再照著數字選擇你要安裝的ide跟版本,可以裝好幾個ide,所有ide安裝好後設定檔會放在 ~/.projector/configs/<config_name>
安裝時建議channel選tested,表示是有測試過能正常在projector運行的ide,否則裝非tested的有時會有些奇奇怪怪的問題。

5.設定ide:projector config edit,再照著數字選擇個別ide設定檔並設定(如ide要開在哪個port、要不要設token...等), 其中有一項會問你要不要設定ssl,選是的話會先使用jetbrains的自簽憑證。注意設定完port後也要記得開防火牆

6.幫projector裝上letsencrypt憑證,記住每裝一個ide就要重複一次上憑證的動作:
projector install-certificate <config_name> --certificate /etc/letsencrypt/live/your.domain.com.tw/cert.pem --key /etc/letsencrypt/live/your.domain.com.tw/privkey.pem

7.執行ide:projector run <config_name>
會出現連線的網址,如果有設定token,網址會帶token參數,把網址ip換成domain即可

8.可用(1)瀏覽器(2)projector client app (3)chrome的projector應用程式
等三種方式連線

9.若不想在server安裝projector, 也可以直接在本機的jetbrains ide裝projector plugin後成為本機伺服器,但每次有人從外部連線時需要點擊確認才能連線。

10.若多人共用同一台伺服器,建議修改 /et/clogin.defs 的umask值為 027,這樣使用者(ide)之後新建的檔案權限other(別人)就會是不可讀不可寫。

11.每次離開(exit)IDE, 那麼就等同於projector停止,需再project run <config_name>一次才能再啟動並連進ide,若要保持ide及projector運作,就不要在IDE點擊exit,或寫個 systemd 或用watchdog讓projector每次關閉後會再自動重啟。

2021-01-21

iItelliJ 設定PHP XDEBUG環境

 一、安裝composer、php-cgi(注意,必須是cgi,不能用cli或fpm)、php-xdebug
sudo apt-get install php-cgi php-xdebug
sudo curl -s https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer
sudo chown root.root /usr/local/bin/composer
sudo chmod 755 /usr/local/bin/composer

二、修改xdebug設定
sudo vi /etc/php/7.2/cgi/conf.d/20-xdebug.ini
加上
xdebug.remote_enable=1

php-cgi --version //須出現xdebug字眼
with Xdebug v2.6.0, Copyright (c) 2002-2018, by Derick Rethans

三、chrome或firefox安裝xdebug plugin
https://www.jetbrains.com/help/idea/2020.3/browser-debugging-extensions.html
擴充功能選項的IDE Key選擇PHPSTORM

四、修改IntelliJ的language & frameworks / PHP 設定
新增 /usr/bin/php-cgi

五、執行選單 Run / Web Server Debug Validation,看是否能正常debug

若使用intellij內建的web server + php-cgi,可能會沒有$_SERVER['SERVER_NAME'] 造成無法正常透過瀏覽器debug,下面的ref有解法但不一定有用,似乎是intellij的bug,似乎還是得換成nginx或apache才能解決,若用外部server,須到 language & frameworks / PHP / Servers及build,excution,deployment->Deployment去新增對應的server


ref:
https://www.jetbrains.com/help/idea/2020.3/configuring-xdebug.html
https://www.jetbrains.com/help/idea/2020.3/zero-configuration-debugging.html
https://youtrack.jetbrains.com/issue/WI-54542
https://stackoverflow.com/questions/23344106/php-storm-debugging-creates-empty-server-definitions
https://www.cnblogs.com/Renyi-Fan/p/9117895.html