Alternatively execute the following command to locate the loaded php.ini configuration file for the command line (cli) php --ini | grep Loaded Loaded Configuration File: /etc/php/7.3/cli/php.ini 3 command:
php --ini | grep Loaded Loaded Configuration File: /etc/php/7.3/cli/php.iniPlease, note that the above php.ini file location is used by php --ini | grep Loaded Loaded Configuration File: /etc/php/7.3/cli/php.ini 3command. For the Apache web-server the above path will translate to:
This article requires Windows 10 (Build Version 1709 [The Fall Creators Update]) or above to work.
Although WSL exists since Version 1607 [Anniversary Update], it’s harder to setup and more buggy.
In this tutorial we will setup this development environment in WSL (In Part 1)
Apache 2.4
MySQL 5.7
PHP 7.2 (Run as FPM)
phpMyAdmin
Composer
With those tools under Windows 10 (In Part 2)
PHPStorm
Bash and Linux CLI tools
PHP Deployer
A. Installation
1. Enable “Windows Subsystem for Linux”
Start > Search “Turn Windows features on or off”
The result should show up after typing first two words
Check “Windows Subsystem for Linux”, Click “OK”, Reboot
2. Install Ubuntu 18.04 on WIndows
Start > Search”Microsoft Store”, open it and search for “Ubuntu 18.04”
Install and launch it first time, it takes some time to initialize.
Enter desired username and password for the Linux subsystem.
3. Start enjoying your Linux subsystem!
B. Install and Configure Packages
Part B works exactly the same way as Ubuntu 18.04.
If you are familiar with Ubuntu 18.04, you may skip this part and use your own method for installation.
1. Update all installed packages
Let’s do a apt install -y php7.2-cli php7.2-fpm php7.2-opcache php7.2-mysql php7.2-mbstring php7.2-xml php7.2-zip php7.2-bz2 php7.2-curl php7.2-gd
apt install -y apache2
apt install -y mysql-server
apt install -y git3 first
sudo -i
apt update
apt dist-upgrade2. Install Apache, PHP, MySQL, git
apt install -y php7.2-cli php7.2-fpm php7.2-opcache php7.2-mysql php7.2-mbstring php7.2-xml php7.2-zip php7.2-bz2 php7.2-curl php7.2-gd apt install -y apache2 apt install -y mysql-server apt install -y git3. Configure PHP
Enable PHP FPM for Apache
a2enconf php7.2-fpm a2enmod proxy_fcgiIncrease PHP resources limits for development
4. Configure Apache2
Enable rewrite module
a2enmod rewriteEnable .htaccess in all directories
sed -i ':a;N;$!ba;s/AllowOverride None/AllowOverride All/3' /etc/apache2/apache2.conf5. Configure MySQL
Remove test user and databases
mysql_secure_installationIt will make several changes to MySQL login crediitcal
(Press ENTER multiple time until finish if you don’t care)
Enable MySQL root password login
MySQL 5.7 under Ubuntu 18.04 do not allow password login for security reason,
But it doesn’t matter much in our development machine, so we change it in order to use phpMyAdmin.
6. Install and enable phpMyAdmin (From git)
git clone --depth=1 --branch=STABLE git://github.com/phpmyadmin/phpmyadmin.git /var/www/phpMyAdmin randomBlowfishSecret=`openssl rand -base64 32`; sed -e "s|cfg\['blowfish_secret'\] = ''|cfg['blowfish_secret'] = '$randomBlowfishSecret'|" /var/www/phpMyAdmin/config.sample.inc.php > /var/www/phpMyAdmin/config.inc.php cd /var/www/phpMyAdmin composer install --no-devapt install -y php7.2-cli php7.2-fpm php7.2-opcache php7.2-mysql php7.2-mbstring php7.2-xml php7.2-zip php7.2-bz2 php7.2-curl php7.2-gd apt install -y apache2 apt install -y mysql-server apt install -y git07. Install composer (From official installer)
apt install -y php7.2-cli php7.2-fpm php7.2-opcache php7.2-mysql php7.2-mbstring php7.2-xml php7.2-zip php7.2-bz2 php7.2-curl php7.2-gd apt install -y apache2 apt install -y mysql-server apt install -y git18. Start everything!
apt install -y php7.2-cli php7.2-fpm php7.2-opcache php7.2-mysql php7.2-mbstring php7.2-xml php7.2-zip php7.2-bz2 php7.2-curl php7.2-gd apt install -y apache2 apt install -y mysql-server apt install -y git2Yes, something unusual start appear from here.
Service under WSL do not start automatically, after installation or after reboot.
You may also encounter “apt install -y php7.2-cli php7.2-fpm php7.2-opcache php7.2-mysql php7.2-mbstring php7.2-xml php7.2-zip php7.2-bz2 php7.2-curl php7.2-gd
apt install -y apache2
apt install -y mysql-server
apt install -y git4” when starting Apache2.
It doesn’t harm anything, we will remove that later, however.
9. Basic installation complete
You now have PHP, Apache, MySQL working, and phpMyAdmin under //127.0.0.1/phpMyAdmin
All ports listened by applications inside WSL are accessible in Windows.
In next part we will go though the special attributes and gotchas of the Linux subsystem.
Make it share files and play nice with your favorite Windows tools and IDEs!