{"id":13342510,"url":"https://github.com/asapdotid/wsl-config","last_synced_at":"2026-04-09T15:44:17.347Z","repository":{"id":113711351,"uuid":"239483087","full_name":"asapdotid/wsl-config","owner":"asapdotid","description":"Configuration Windows Ubuntu for Development Environment (WSL)","archived":false,"fork":false,"pushed_at":"2021-02-24T07:24:37.000Z","size":641,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-18T04:36:10.607Z","etag":null,"topics":["composer","git","linux","mysql","nginx","nodejs","nvm","php","ubuntu","vim","windows","wsl","zsh"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/asapdotid.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-02-10T10:19:17.000Z","updated_at":"2025-05-04T23:00:13.000Z","dependencies_parsed_at":null,"dependency_job_id":"e58c2345-75c8-48b6-9f53-fd0c2cd7ed2b","html_url":"https://github.com/asapdotid/wsl-config","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/asapdotid/wsl-config","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asapdotid%2Fwsl-config","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asapdotid%2Fwsl-config/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asapdotid%2Fwsl-config/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asapdotid%2Fwsl-config/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/asapdotid","download_url":"https://codeload.github.com/asapdotid/wsl-config/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asapdotid%2Fwsl-config/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265553217,"owners_count":23787036,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["composer","git","linux","mysql","nginx","nodejs","nvm","php","ubuntu","vim","windows","wsl","zsh"],"created_at":"2024-07-29T19:29:30.336Z","updated_at":"2025-12-30T19:04:18.216Z","avatar_url":"https://github.com/asapdotid.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Windows 10 Pro - WSL Ubuntu for Web Server (Base Ubuntu 20.04 LTS)\n\nDepending on the operating system you are using:\n\n- Ubuntu 18.04 LTS and you can use the `wsl-ubuntu-18.04` branch\n- Ubuntu 20.04 LTS and you can use the `master` branch\n\n\u003e Note for `Ubuntu 20.04`, pre installation:\n\n```bash\nsudo apt-get clean\nsudo rm -rf /var/lib/apt/lists\nsudo mkdir -p /var/lib/apt/lists/partial\nsudo apt-get clean\nsudo apt-get update\nsudo apt-get -u dist-upgrade\n```\n\n---\n\n## Customize your terminal (Oh My Zsh) on Ubuntu\n\nInstall ZSH and support for Powerline fonts\n\n```bash\nsudo apt install zsh -y\nsudo apt install powerline fonts-powerline -y\n```\n\nInstall Oh-my-zsh se instruction on [oh-my-zsh web](https://ohmyz.sh/#install)\n\nvia `curl`\n\n```bash\nsh -c \"$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)\"\n```\n\nor via `wget`\n\n```bash\nsh -c \"$(wget https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh -O -)\"\n```\n\nFollow the instruction and change terminal theme do you want.\n\nInstall Plugin for your ZSH\n\n1. zsh-syntax-highlighting [repo](https://github.com/zsh-users/zsh-syntax-highlighting) and [installation](https://github.com/zsh-users/zsh-syntax-highlighting/blob/master/INSTALL.md)\n1. zsh-autosuggestions [repo](https://github.com/zsh-users/zsh-autosuggestions) and [installtion](https://github.com/zsh-users/zsh-autosuggestions/blob/master/INSTALL.md)\n1. zsh-completions [repo and installation](https://github.com/zsh-users/zsh-completions)\n\nNow in your `.zshrc` look:\n\n```bash\nplugins=(git zsh-syntax-highlighting zsh-autosuggestions zsh-completions)\nautoload -U compinit \u0026\u0026 compinit\n```\n\n## Customize your Aliases on Ubuntu\n\n\u003e Copy from repo on `.config` directory and paste to your root or home user.\n\nRename file `.env.sample` to `.env` in your `.config` directory and change content in block:\n\n```bash\n# Your environment variables, you should change depend of your system setup\nTLD_DOMAIN='test'\nNGINX_VHOST_LOCATION=$HOME'/.config/vhosts'\nPROJECT_LOCATION=$HOME'/projects/www'\n```\n\nYou can change with your own project.\n\nThen\n\nSetup sources aliases and functions to your `.zshrc`\n\n```bash\nsource $HOME/.config/.aliases\nsource $HOME/.config/.functions\n```\n\n## Customize your VIM on Ubuntu\n\n\u003e Copy file `.vimrc` to your root or home user directory\n\nOpen terminal\n\n```bash\nvim\n```\n\nFrom your terminal console will see installation all plugin from yout `.vimrc` or you can add plugin manualy.\n\n![Finish Installation Vim Plugin](./images/wsl-vim-installation-plugin.jpg \"Show finish installation on vim\")\n\n---\n\n## **LEMP Stack** + **Node Js**\n\n## Before run all file bash script\n\nYou can mount windows drive to WSL which create wsl config on etc\n\n`sudo vim /etc/wsl.conf`\n\nAdd this config:\n\n```bash\n# Enable extra metadata options by default\n[automount]\nenabled = true\nroot = /\noptions = \"metadata,umask=22,fmask=11\"\nmountFsTab = false\n\n# Enable DNS – even though these are turned on by default, we’ll specify here just to be explicit.\n[network]\ngenerateHosts = true\ngenerateResolvConf = true\n```\n\nSave it `:wq` and restart WSL (open PowerShell as Administrator) then execute below this\n\n```bash\nGet-Service LxssManager | Restart-Service\n```\n\n![Restart WSL](./images/wsl-powershell-restart-wsl.jpg \"Restart WSL from PowerShell as Administrator\")\n\nYou can check that drive show on wsl:\n\n`ls -al /c/` or `ls -al /d/`\n\nThan you can link (Win10) project directory to (WSL) home directory etc:\n\n`ln -s /d/projects ~/.`\n\n![Restart WSL](./images/wsl-list-home-dir.jpg \"Show list home directory WSL\")\n\nNext step:\n\n```bash\nsudo apt update \u0026\u0026 sudo apt upgrade -y\n```\n\n\u003e Copy or clone this repository to your home directory\n\u003e Change directory to project `wsl-web-config`\n\n### 1. Install Nginx\n\n\u003e ./install-nginx-on-wsl.sh\n\nCopy all snippet files configuration: `sudo cp -r etc/nginx/snippets/* /etc/nginx/snippets`\nAnd you can change Nginx config `nginx.conf` for optimize, sample config: `etc/nginx/nginx.conf`\nAdding custom Virtual Hosts to your Nginx config, sample `$HOME/.config/vhosts`\n\n// you can change \"username\" with your username\n\n\u003e include /home/`username`/.config/vhosts/\\*;\n\nSample virtual host for `Laravel` project, file name: `laravel-project`\n\n\u003e set \\$base /home/`username`/projects/laravel-project; change by your username\n\n```bash\nserver {\n    listen 80;\n    listen [::]:80;\n\n    server_name laravel-project.test;\n    set $base /home/username/projects/laravel-project;\n    root $base/public;\n\n    index index.php index.html index.htm;\n\n    location / {\n        try_files $uri $uri/ /index.php?$query_string;\n    }\n\n    error_page 404 /index.php;\n\n    location ~ \\.php$ {\n        include snippets/php_fastcgi.conf;\n    }\n\n    # additional config\n    include snippets/general.conf;\n\n    location ~ /\\.(?!well-known).* {\n        deny all;\n    }\n}\n```\n\nAfter install and custom configurations setup now with aliases you can run services:\n\n- `s:nginx start`\n- `s:nginx restart`\n- `s:nginx stop`\n- `s:nginx status`\n\n### 2. Install MySQL\n\n\u003e ./install-mysql8-on-wsl.sh\n\nHanddling MySQL Error Socket `/var/run/mysqld/mysqld.sock`\n\n```bash\ns:mdb stop\nsudo usermod -d /var/lib/mysql/ mysql\ns:mdb start\n```\n\nor\n\n```bash\nsudo service mysql stop\nsudo usermod -d /var/lib/mysql/ mysql\nsudo service mysql start\n```\n\nNow you have MySQL Server on your system (use aliases).\n\n- `s:mdb start`\n- `s:mdb restart`\n- `s:mdb stop`\n- `s:mdb status`\n\nStart Service and try use mysql cli\n\n```bash\nsudo mysql -u root -p\n```\n\nSetup secure MySQL with password\n\n```bash\nsudo mysql_secure_installation\n```\n\nYou can see password validate configuration metrics using the following query in MySQL client:\n\n```bash\nsudo mysql -u root -p\n```\n\n```bash\nmysql\u003e SHOW VARIABLES LIKE 'validate_password%';\n```\n\nThe output should be something like that :\n\n| Variable_name                        | Value  |\n| ------------------------------------ | ------ |\n| validate_password.check_user_name    | ON     |\n| validate_password.dictionary_file    |\n| validate_password.length             | 8      |\n| validate_password.mixed_case_count   | 1      |\n| validate_password.number_count       | 1      |\n| validate_password.policy             | MEDIUM |\n| validate_password.special_char_count | 1      |\n\nThen you can set the password policy level lower, for example:\n\n```bash\nmysql\u003e SET GLOBAL validate_password.length = 6;\nmysql\u003e SET GLOBAL validate_password.number_count = 0;\nmysql\u003e SET GLOBAL validate_password.policy = 0;\n```\n\n```bash\nmysql\u003e SHOW VARIABLES LIKE 'validate_password%';\n```\n\nThe output should be something like that :\n\n| Variable_name                        | Value |\n| ------------------------------------ | ----- |\n| validate_password.check_user_name    | ON    |\n| validate_password.dictionary_file    |\n| validate_password.length             | 6     |\n| validate_password.mixed_case_count   | 1     |\n| validate_password.number_count       | 1     |\n| validate_password.policy             | LOW   |\n| validate_password.special_char_count | 1     |\n\nYou can install with above script and with aliases you can run services:\n\n- `s:mdb start`\n- `s:mdb restart`\n- `s:mdb stop`\n- `s:mdb status`\n\n### 3. Install PHP7.4 FPM\n\nNOTE: Ubuntu 20.04 ships with PHP 7.4 in its upstream repositories. Just install it and the extensions you with the apt package manager.\n\n\u003e ./install-php-fpm-on-wsl.sh\n\nYou can install with above script and with aliases you can run services:\n\n- `s:php start`\n- `s:php restart`\n- `s:php stop`\n- `s:php status`\n\n\u003e Fastcgi Settings on `/etc/nginx/snippets/php_fastcgi.conf`\n\u003e TCP `fastcgi_pass 127.0.0.1:9000;`\n\u003e Socket `fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;`\n\nBefore you can user fastcgi_pass `TCP` you should change php7.4-fpm config on www.conf: `/etc/php/7.4/fpm/pool.d/www.conf`\n\n```bash\n; The address on which to accept FastCGI requests.\n; Valid syntaxes are:\n;   'ip.add.re.ss:port'    - to listen on a TCP socket to a specific IPv4 address on\n;                            a specific port;\n;   '[ip:6:addr:ess]:port' - to listen on a TCP socket to a specific IPv6 address on\n;                            a specific port;\n;   'port'                 - to listen on a TCP socket to all addresses\n;                            (IPv6 and IPv4-mapped) on a specific port;\n;   '/path/to/unix/socket' - to listen on a unix socket.\n; Note: This value is mandatory.\nlisten = /run/php/php7.4-fpm.sock\n```\n\nChange to:\n\n```bash\n; The address on which to accept FastCGI requests.\n; Valid syntaxes are:\n;   'ip.add.re.ss:port'    - to listen on a TCP socket to a specific IPv4 address on\n;                            a specific port;\n;   '[ip:6:addr:ess]:port' - to listen on a TCP socket to a specific IPv6 address on\n;                            a specific port;\n;   'port'                 - to listen on a TCP socket to all addresses\n;                            (IPv6 and IPv4-mapped) on a specific port;\n;   '/path/to/unix/socket' - to listen on a unix socket.\n; Note: This value is mandatory.\n; listen = /run/php/php7.4-fpm.sock\nlisten = 127.0.0.1:9000\n```\n\n### 4. Install Redis Server\n\n\u003e ./install-redis-on-wsl.sh\n\nNow you have Redis Server on your system (use aliases).\n\n- `s:rdb start`\n- `s:rdb restart`\n- `s:rdb stop`\n- `s:rdb status`\n\n### 5. Install NODE JS use NVM\n\n\u003e ./install-nvm-on-wsl.sh\n\nNow you have Node JS on your system.\n\nReference [NVM Repo](https://github.com/nvm-sh/nvm#installing-and-updating)\n\n### 6. Install MongoDB from Package Repo Ubuntu\n\n\u003e ./install-mongodb-on-wsl.sh\n\nNow you have MongoDB Server on your system (use aliases).\n\n- `s:mgdb start`\n- `s:mgdb restart`\n- `s:mgdb stop`\n- `s:mgdb status`\n\nConnection to mongodb shell\n\n```bash\nmongo --host 127.0.0.1:27017\n```\n\n**Adding Admin User**\n\nBy default, authentication is not enabled for MongoDB users. In production environment, it may be required to secure your server and enable user authentication.\n\nUse the steps below to do that.\n\nIf you want to enable authentication, run the commands to create a new admin user after you’ve logged into MongoDB server.\n\n```bash\nmongo --host 127.0.0.1:27017\n```\n\n```bash\n\u003e use admin\n```\n\nThen run the commands below to create a new admin user\n\n```bash\n\u003e db.createUser({user:\"admin\", pwd:\"new_password_here\", roles:[{role:\"root\", db:\"admin\"}]})\n```\n\nYou should see a successful admin user created:\n\n```bash\nSuccessfully added user: {\n\t\"user\" : \"admin\",\n\t\"roles\" : [\n\t\t{\n\t\t\t\"role\" : \"root\",\n\t\t\t\"db\" : \"admin\"\n\t\t}\n\t]\n}\n```\n\nExit and continue below to enable MongoDB logon authentication.\n\nRun the commands below to open MongoDB config file.\n\n```bash\nsudo vim /lib/systemd/system/mongod.service\n```\n\nThen change the highlighted line to look like the one below and save.\n\n```bash\n[Service]\nUser=mongodb\nGroup=mongodb\nExecStart=/usr/bin/mongod --auth --config /etc/mongod.conf\nPIDFile=/var/run/mongodb/mongod.pid\n```\n\nSave and exit.\n\nRestart MongDB to make the changes apply.\n\n```bash\ns:mgdb start\n```\n\nAfter installing MongoDB, its default configuration file is located at `/etc/mongod.conf`.\n\nIt is recommended to enable authentication since all users can access the database without authenticating.\n\nTo do that, open the configuration file by running the commands below:\n\n```bash\nsudo nano /etc/mongod.conf\n```\n\nThen edit the line shown below to enabled:\n\n```bash\nsecurity:\n  authorization: enabled\n```\n\nRestart MongoDB services after making the changes above.\n\n```bash\ns:mgdb restart\n```\n\nNow only authentication users will be allowed to access the database server.\n\n```bash\nmongo -u admin -p new_password_here --authenticationDatabase admin\n```\n\nRun the commands below to verify that authentication is enabled.\n\n```bash\nmongo -u admin -p --authenticationDatabase admin\n```\n\nYou should then be prompted for a password.\n\n### 7. Install Postgresql\n\n\u003e ./install-postgrsql-on-wsl.sh\n\nNow you have Postgres Server on your system (use aliases).\n\n- `s:pdb start`\n- `s:pdb restart`\n- `s:pdb stop`\n- `s:pdb status`\n\n**Set PostgreSQL admin user’s password and do testing**\n\nSet a password for the default admin user\n\n```bash\nsudo su - postgres\npostgres@asap:~$ psql -c \"alter user postgres with password 'StrongPassword'\"\n```\n\nTesting create user\n\n```bash\ncreateuser asapdotid\n```\n\nAdd test database:\n\n```bash\ncreatedb testdb -O asapdotid\n```\n\nSetup password for user Asapdotid\n\n```bash\npsql\npostgres=# alter user asapdotid with password 'asapdotid123';\n```\n\nConnect to use database `testdb`\n\n```bash\n\\c testdb\n```\n\nCreate table and add some dummy data:\n\n```bash\ncreate table test_table ( id int,first_name text, last_name text );\ninsert into test_table (id,first_name,last_name) values (1,'Foo','Bar');\nselect * from test_table;\n```\n\nAfter successfully create table, you should drop table and quite from `testdb`\n\n```bash\nDROP TABLE test_table;\n/q\n```\n\nSo you can drop databse `testdb`:\n\n```bash\npostgres@asap:~$ dropdb testdb;\n```\n\n---\n\n## Add correct permission files and directory optional (Laravel storage \u0026 boostrap/cache directory)\n\nYou can run shell script `setPermission.sh` and follow instruction\n\nfirst setup `setPermission.sh` to executable:\n\n\u003e chmod +x setPermission.sh\n\nThen execute the file in terminal: `./setPermission.sh`\n\nor\n\nYou can add in composer.json on root Laravel project\n\n```bash\n\"scripts\": {\n    \"post-install-cmd\": [\n      \"chgrp -R www-data storage bootstrap/cache\",\n      \"chmod -R ug+rwx storage bootstrap/cache\"\n    ]\n}\n```\n\n---\n\nDo not hesitate if there are suggestions and criticisms 😃 [@asapdotid](https://github.com/asapdotid)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasapdotid%2Fwsl-config","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fasapdotid%2Fwsl-config","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasapdotid%2Fwsl-config/lists"}