Skip to content

Instantly share code, notes, and snippets.

@duboiss
Last active March 12, 2021 14:17
Show Gist options
  • Save duboiss/36f008912603e36173b6baa7cdf09250 to your computer and use it in GitHub Desktop.
Save duboiss/36f008912603e36173b6baa7cdf09250 to your computer and use it in GitHub Desktop.
A clean install with WSL2 / Ubuntu 20.10 for developers : PHP / Node.js / Rust / Others

Ubuntu 20.10

A clean install with WSL2 / Ubuntu 20.10 for developers : PHP / Node.js / Rust / Others

Table of contents

Add WSL2

Update to Ubuntu 20.1

sudo apt update && sudo apt upgrade -y && sudo nano /etc/update-manager/release-upgrades

Change lts to normal. Reboot WSL with wsl --shutdown in powershell/cmd.

sudo do-release-upgrade

Answer yes to each question, Ubuntu will restart by itself. You can now check your version with lsb_release -a.

Optional

Disable sudo password prompt

sudo visudo

Replace %admin ALL=(ALL) ALL by %admin ALL=(ALL) NOPASSWD: ALL.

Remove Windows path and disable swap

https://docs.microsoft.com/fr-fr/windows/wsl/wsl-config

sudo nano /etc/wsl.conf

[interop] 
enabled=false # enable launch of Windows binaries; default is true 
appendWindowsPath=false # append Windows path to $PATH variable; default is true

[wsl2]
swap=0

In Powershell: wsl --shutdown.

Optional - zsh & oh-my-zsh

sudo apt install zsh && chsh -s $(which zsh) && sh -c "$(wget https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh -O -)"

Update nano

/!\ You need to have the clock correctly configured. You need gcc, libncurses-dev and make packages.

sudo apt install gcc libncurses-dev make

Uninstall current nano

Uninstall nano, its dependencies and its config files. Does not affect personal files and the logs.

sudo apt-get autoremove --purge nano

Install latest version

See latest version.

wget https://www.nano-editor.org/dist/v5/nano-5.6.tar.gz && tar -zxvf nano-5.6.tar.gz && cd nano-5.6
./configure && sudo make install
cd .. && sudo rm -rf nano-5.6 nano-5.6.tar.gz

PHP

Repository

Add ppa:ondrej/php to always get the latest PHP version available.

sudo add-apt-repository ppa:ondrej/php && sudo apt update && sudo apt upgrade -y

Install PHP with a specific version.

sudo apt install php8.0 -y

Extensions

Add the extensions you want. Unzip is used by composer.

sudo apt install php-{amqp,apcu,curl,gd,intl,mbstring,mysql,pgsql,redis,sqlite3,xdebug,xml,zip} unzip -y

https://doc.ubuntu-fr.org/php#modules

Configuration

First solution - Manual editing

nano /etc/php/8.0/cli/php.ini
Second solution - By CLI

Install a utility for manipulating .ini files.

sudo apt install crudini

Now you can easily edit your configuration. Example:

sudo crudini --set /etc/php/8.0/cli/php.ini Date date.timezone "Europe/Paris"
sudo crudini --set /etc/php/8.0/cli/php.ini PHP realpath_cache_ttl 600

Cachetool

Installation instructions

curl -sLO https://github.com/gordalina/cachetool/releases/latest/download/cachetool.phar && chmod +x cachetool.phar && sudo mv cachetool.phar /usr/bin/cachetool

PHPBrew

https://github.com/phpbrew/phpbrew#requirement

Composer

wget -O composer-setup.php https://getcomposer.org/installer
sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer

Volta (node/npm/yarn)

Installation instructions

curl https://get.volta.sh | bash && source ~/.bashrc && volta install node yarn

Rust & cargo

Installation instructions

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh && source $HOME/.cargo/env

Other tools

Git

Git is already installed. Just think to configure your .gitconfig and global .gitignore.

Docker

Docker is already available if Docker Desktop is installed on windows and use WSL2 engine.

Symfony CLI

curl -sS https://get.symfony.com/cli/installer | bash && sudo mv $HOME/.symfony/bin/symfony /usr/local/bin/symfony

See all versions:

npm -v && yarn -v && php -v && composer -V && docker -v && docker-compose -v && git --version && cargo -V

httpie, jq, bat, exa

httpie & jq

sudo apt install httpie jq

bat https://github.com/sharkdp/bat

sudo apt install bat && sudo ln -s /usr/bin/batcat /usr/bin/bat

exa https://github.com/ogham/exa Build from source to get latest features.

git clone https://github.com/ogham/exa.git && cd exa && cargo build --release
sudo cp target/release/exa /usr/bin/exa && cd .. && rm -rf exa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment