Where is PHP ini in WSL?

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.ini

Please, 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 packagesLet’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-upgrade

2. 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 git

3. Configure PHP

Enable PHP FPM for Apache

a2enconf php7.2-fpm
a2enmod proxy_fcgi

Increase PHP resources limits for development

sed -i 's|post_max_size = [0-9]\+M|post_max_size = 128M|g' /etc/php/7.2/fpm/php.ini
sed -i 's|upload_max_filesize = [0-9]\+M|upload_max_filesize = 128M|g' /etc/php/7.2/fpm/php.ini
sed -i 's|memory_limit = [0-9]\+M|memory_limit = 512M|g' /etc/php/7.2/fpm/php.ini
sed -i 's|max_execution_time = [0-9]\+|max_execution_time = 300|g' /etc/php/7.2/fpm/php.ini
sed -i 's|gc_maxlifetime = [0-9]\+|gc_maxlifetime = 86400|g' /etc/php/7.2/fpm/php.ini

sed -i 's|pm.max_children = [0-9]\+|pm.max_children = 25|g' /etc/php/7.2/fpm/pool.d/www.conf
sed -i 's|pm.start_servers = [0-9]\+|pm.start_servers = 5|g' /etc/php/7.2/fpm/pool.d/www.conf
sed -i 's|pm.min_spare_servers = [0-9]\+|pm.min_spare_servers = 5|g' /etc/php/7.2/fpm/pool.d/www.conf
sed -i 's|pm.max_spare_servers = [0-9]\+|pm.max_spare_servers = 10|g' /etc/php/7.2/fpm/pool.d/www.conf

4. Configure Apache2

Enable rewrite module

a2enmod rewrite

Enable .htaccess in all directories

sed -i ':a;N;$!ba;s/AllowOverride None/AllowOverride All/3' /etc/apache2/apache2.conf

5. Configure MySQL

Remove test user and databases

mysql_secure_installation

It 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.

mysql
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'some_strong_password';
FLUSH PRIVILEGES;
exit

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-dev
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 git
0

7.  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 git
1

8. 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 git
2

Yes, 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 git
4” 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 http://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!

 

 

 

Where do I find my PHP ini file?

ini file is the default configuration file for running applications that require PHP. It is used to control variables such as upload sizes, file timeouts, and resource limits. This file is located on your server in the /public_html folder.

Where is my PHP ini file in Windows?

In Windows Explorer, open your PHP installation folder, for example C:\PHP . In a text editor, open the php. ini file.

Where do I find PHP ini on Linux?

The default location for the php. ini file is: Ubuntu 16.04: /etc/php/7.0/apache2. CentOS 7: /etc/php.

How to run PHP file in WSL?

Configure WSL.
Download and install a WSL distribution (for instance, Ubuntu) from Microsoft Store. ... .
Run the Linux distribution. ... .
Inside the Linux installation, make sure PHP is installed. ... .
Configure a WSL-based remote interpreter as described in Configure remote PHP interpreters..