However#
So, should wsl be capitalized or not...
"Small Goal" earns an average of 1 yuan per article/Git Repository_Miscellaneous_Ice and Water:
[https://www.wdssmq.com/post/20210723266.html](https://www.wdssmq.com/post/20210723266.html "Small Goal" earns an average of 1 yuan per article/Git Repository_Miscellaneous_Ice and Water")
Related Recommendations#
["VSCode" Remote CentOS php.validate.executablePath Setting_Computer Networking_Ice and Water](https://www.wdssmq.com/post/20211004556.html "VSCode" Remote CentOS php.validate.executablePath Setting_Computer Networking_Ice and Water")
["Tinkering" with VSCode + wsl2 + Docker_Computer Networking_Ice and Water](https://www.wdssmq.com/post/20220211184.html "Tinkering" with VSCode + wsl2 + Docker_Computer Networking_Ice and Water")
Installing PHP 7.4 on Ubuntu#
# sudo apt-get upgrade
sudo apt-get install -y software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install -y php7.4
# Check version
php -v
# PHP 7.4.29 (cli) (built: Apr 21 2022 10:16:17) ( NTS )
# Check installation path
whereis php
# php: /usr/bin/php7.4 /usr/bin/php ……
· Configuring VSCode for PHP validation:
{
"php.validate.executablePath": "/usr/bin/php"
}
Unable to validate because PHP installation cannot be found. Use the "php.validate.executablePath" setting to configure the PHP executable.
"See illustration"
Main Content#
For now, I can write various Z-BlogPHP plugins, and my main development (tinkering) environment is WSL2
+ Ubuntu-18.04
+ Docker
;
Installing PHP in the Docker host environment is mainly for VSCode syntax validation; "Installation method has been supplemented above"
Then some plugins use Composer to install dependencies;
Complete code for direct use:
# Add write permissions
sudo chown -R `whoami`:admin /usr/local/bin
# Enter directory
cd /usr/local/bin
# Download and install
sudo curl -sS https://getcomposer.org/installer | php
# All settings correct for using Composer
# Downloading...
# Composer (version 2.3.3) successfully installed to: /usr/local/bin/composer.phar
# Use it: php composer.phar
# Rename and set alias
mv composer.phar /usr/local/bin/composer
alias composer='/usr/local/bin/composer'
composer -V
# Composer version 2.3.3 2022-04-01 22:15:35
If it prompts that there are no write permissions, you need to execute chown -R
with write permissions first;
cd /usr/local/bin
sudo curl -sS https://getcomposer.org/installer | php
# All settings correct for using Composer
# The installation directory "/usr/local/bin" is not writable
sudo chown -R `whoami`:admin /usr/local/bin
# sudo chmod a+x /usr/local/bin
# Then execute the installation command again
Online tutorials install or move to /usr/local/bin
, but executing it will prompt that the path does not exist, and the location is /usr/bin
;
composer -V
# bash: /usr/bin/composer: No such file or directory
alias composer='/usr/local/bin/composer'
composer -V
# Composer version 2.3.3 2022-04-01 22:15:35
Other Issues Encountered and How to Use#
Enter the path where composer.json
already exists and execute composer install
, but my project reports errors because the required PHP components are not enabled;
Because the actual code runs in Docker, it doesn't matter if it's not enabled externally, just follow the prompts to enable the corresponding components;
composer install
# Install or enable PHP's curl extension
# Ignore missing dependencies and install directly
composer install --ignore-platform-req=ext-curl