Last active
October 7, 2025 07:31
-
-
Save valorin/c78e7d0285203c4a1cdb0ff1ee290900 to your computer and use it in GitHub Desktop.
WSL setup script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# System | |
alias dotfiles='git --git-dir=/home/valorin/.dotfiles/ --work-tree=/home/valorin' | |
alias dt='git --git-dir=/home/valorin/.dotfiles/ --work-tree=/home/valorin' | |
alias fixinodes='echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p' | |
alias ll='ls -lah' | |
alias tarsnap-backup='sudo tarsnap -cvf backup-$(date +%Y-%m-%d_%H-%M-%S) /home /root /etc /var' | |
# Security | |
alias safe-composer='composer install --ignore-platform-reqs --no-plugins --no-scripts --audit' | |
alias sqlmap="python3 ~/tools/sqlmap/sqlmap.py" | |
#alias sqlmap="python3 ~/dev/sqlmap/sqlmap.py --threads=10 --level=5 --risk=3 --dbms=MySQL --batch" | |
# Dev | |
alias start-all='sudo service ssh start && sudo service redis-server start && sudo service mysql start && sudo service php8.4-fpm start && sudo service nginx start && mailcatcher' | |
alias stop-all='sudo service redis-server stop && sudo service mysql stop && sudo service php8.4-fpm stop && sudo service nginx stop && sudo service ssh stop && killall mailcatcher ; sleep 1 && ps ax' | |
alias restart-all='sudo service redis-server restart && sudo service mysql restart && sudo service php8.4-fpm restart && sudo service nginx restart' | |
alias dev-prod-commit-prod='killall webpack ; npm run prod && git add public/ && git add -p && git commit -v && git push origin main && git checkout prod && git pull origin prod && git merge main --no-edit && git push origin prod && git checkout main && git status' | |
alias dev-build-commit-prod='killall node ; npm run build && git add public/ && git add -p && git commit -v && git push origin main && git checkout prod && git pull origin prod && git merge main --no-edit && git push origin prod && git checkout main && git status' | |
alias dev-commit-prod='git add -p && git commit -v && git push origin main && git checkout prod && git pull origin prod && git merge main --no-edit && git push origin prod && git checkout main && git status' | |
alias dev-merge-prod='git push origin main && git checkout prod && git pull origin prod && git merge main --no-edit && git push origin prod && git checkout main && git status' | |
alias use-php7.1='sudo update-alternatives --set php /usr/bin/php7.1' | |
alias use-php7.2='sudo update-alternatives --set php /usr/bin/php7.2' | |
alias use-php7.3='sudo update-alternatives --set php /usr/bin/php7.3' | |
alias use-php7.4='sudo update-alternatives --set php /usr/bin/php7.4' | |
alias use-php8.0='sudo update-alternatives --set php /usr/bin/php8.0' | |
alias use-php8.1='sudo update-alternatives --set php /usr/bin/php8.1' | |
alias use-php8.2='sudo update-alternatives --set php /usr/bin/php8.2' | |
alias use-php8.3='sudo update-alternatives --set php /usr/bin/php8.3' | |
alias use-php8.4='sudo update-alternatives --set php /usr/bin/php8.4' | |
alias viewlog='tail -f -n 450 storage/logs/l*.log | grep -i -P "^\[\d{4}\-\d{2}\-\d{2} \d{2}:\d{2}:\d{2}\]|Next [\w\W]+?\:|/app/" --color' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -xe | |
# | |
# Instructions: | |
# | |
# 1. Replace or remove dotfiles repo | |
if [ ! -d ~/.dotfiles/ ]; then | |
git clone [email protected]:valorin/dotfiles.git --bare ~/.dotfiles | |
echo "alias dotfiles='git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME'" >> ~/.bash_aliases | |
fi | |
# | |
# 2. Define the PHP versions you need | |
declare -a VERSIONS=("7.4" "8.0" "8.1" "8.2" "8.3" "8.4") | |
##### END OPTIONS | |
# Password-less sudo for simplicity | |
sudo sed -i "s/%sudo\tALL=(ALL:ALL) ALL/%sudo\tALL=(ALL:ALL) NOPASSWD:ALL/" /etc/sudoers | |
# Configure repo for GitHub CLI | |
wget -qO- https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo tee /etc/apt/keyrings/githubcli-archive-keyring.gpg > /dev/null | |
sudo chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg | |
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null | |
# Add PPAs for WSL Utilities and Ondrej Sury's PHP | |
#sudo add-apt-repository -y ppa:wslutilities/wslu | |
sudo add-apt-repository -y ppa:ondrej/php | |
# Ensure everything is updated via apt before installing new stuff | |
sudo apt -y update | |
sudo apt -y upgrade | |
sudo apt -y dist-upgrade | |
sudo apt -y autoremove | |
# Install multiple PHP versions (versions defined at top) | |
USERNAME=$(whoami) | |
for VERSION in "${VERSIONS[@]}"; do | |
sudo apt install -y php$VERSION-cli php$VERSION-fpm \ | |
php$VERSION-mysql php$VERSION-sqlite3 \ | |
php$VERSION-bcmath php$VERSION-curl php$VERSION-gd php$VERSION-intl php$VERSION-mbstring \ | |
php$VERSION-readline php$VERSION-xsl php$VERSION-zip \ | |
php$VERSION-pcov | |
sudo sed -i "s/www-data/$USERNAME/" /etc/php/$VERSION/fpm/pool.d/www.conf | |
sudo sed -i "s/^upload_max_filesize = .*M/upload_max_filesize = 32M/" /etc/php/$VERSION/fpm/php.ini | |
sudo sed -i "s/^post_max_size = .*M/post_max_size = 32M/" /etc/php/$VERSION/fpm/php.ini | |
sudo sed -i "s/^;sendmail_path =.*$/sendmail_path = \/usr\/bin\/env catchmail -f php@localhost/" /etc/php/$VERSION/cli/php.ini | |
sudo sed -i "s/^;sendmail_path =.*$/sendmail_path = \/usr\/bin\/env catchmail -f php@localhost/" /etc/php/$VERSION/fpm/php.ini | |
done | |
sudo apt install -y php-imagick php-pcov php8.3-imagick | |
# Ensure local bin dir exists | |
mkdir -p /home/$USERNAME/.local/bin | |
# Install composer | |
if [ ! -f /home/$USERNAME/.local/bin/composer ]; then | |
wget https://raw.githubusercontent.com/composer/getcomposer.org/76a7060ccb93902cd7576b67264ad91c8a2700e2/web/installer -O - -q | php -- --quiet | |
mv composer.phar ~/.local/bin/composer | |
fi | |
# Update any existing installed composer packages | |
if [ -f /home/$USERNAME/.config/composer/composer.json ]; then | |
/home/$USERNAME/.local/bin/composer global update | |
fi | |
# Install useful global composer packages | |
/home/$USERNAME/.local/bin/composer global require psy/psysh friendsofphp/php-cs-fixer laravel/installer laravel/envoy laravel/forge-cli laravel/pint | |
# Install useful packages | |
sudo apt install -y \ | |
zip vim htop grc bash-completion git-extras gh sqlmap \ | |
redis-server php-redis mysql-server mysql-client \ | |
build-essential patch ruby-dev zlib1g-dev liblzma-dev libsqlite3-dev \ | |
nginx certbot python3-certbot-nginx python3-certbot-dns-cloudflare \ | |
openssh-server nodejs npm | |
# Add current user to www-data group | |
sudo usermod -G $USERNAME www-data | |
# Open up MySQL | |
sudo sed -i "s/^bind-address/#bind-address/" /etc/mysql/mysql.conf.d/mysqld.cnf | |
# Install mailcatcher (for local mail debugging) | |
sudo gem install mailcatcher | |
# Save the useful 'update everything in one line' command into bash history, so it can be easily found with Ctrl+R later. | |
echo "sudo apt -y update && sudo apt -y upgrade && sudo apt -y dist-upgrade && sudo apt -y autoremove && composer self-update && composer global upgrade" >> ~/.bash_history |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment