Managing PHP versions on Arch Linux systems (including Manjaro, EndeavourOS, Garuda Linux, and ArcoLinux) can be challenging. This comprehensive tutorial introduces PHPV, a tool designed to simplify the process of installing, updating, and switching PHP versions efficiently. Follow these steps to streamline your PHP version management on Arch Linux.
For a quick and efficient installation, use the following command:
curl -sSL https://raw.githubusercontent.com/Its-Satyajit/phpv/main/install.sh | bashTip: Ensure you have curl installed on your system. If not, install it using sudo pacman -S curl.
Follow these steps for manual installation:
-
Clone the Repository:
git clone https://github.com/Its-Satyajit/phpv.git
Suggestion: Verify that
gitis installed. If not, install it withsudo pacman -S git. -
Navigate and Grant Permissions:
cd phpv chmod +x phpvTip: Always check the permissions of the script before executing it to ensure it’s safe to run.
-
Install PHPV:
mv phpv $HOME/bin/phpvSuggestion: If
$HOME/bindoes not exist, create it usingmkdir -p $HOME/bin. -
Update Shell Configuration:
Add the following line to your shell configuration file (e.g., ~/.bashrc, ~/.bash_profile):
export PATH="$HOME/bin:$PATH"
Tip: Use a text editor like
nanoorvimto edit your shell configuration file. For example,nano ~/.bashrc. -
Refresh Terminal:
source ~/.bashrc # Replace with your appropriate shell command
Suggestion: If you use a different shell, update the corresponding configuration file (e.g.,
~/.zshrcfor Zsh).
To install, update, or reinstall PHP versions, use the following command:
phpv -i <version>Replace <version> with the desired shorthand (e.g., 80 for 8.0, 74 for 7.4).
Tip: Always check for the latest PHP versions and their shorthand notations to keep your environment up to date.
Install
Update/Reinstall
By default, phpv tries to install prebuilt binaries using pacman (if available in your configured repositories, like Chaotic-AUR). This saves time by avoiding compilation.
If a prebuilt binary is not found, it automatically falls back to building from the AUR.
If you prefer to compile from source (skipping the binary check), use the --build (or -b) flag:
phpv -i <version> --buildExample: phpv -i 81 -b
If the installation fails during the testing phase (common with some extensions like imagick), you can skip tests using --nocheck:
phpv -e imagick 81 --nocheckTo install PHP extensions (e.g., imagick, redis) for a specific PHP version, use the -e flag:
phpv -e <extension> <version>Example: phpv -e imagick 81 will install php81-imagick from the AUR.
To switch PHP versions, use the following command:
phpv <version>Replace <version> with the desired shorthand.
Suggestion: After switching versions, verify the PHP version with php -v to ensure the correct version is active.
Switch
To switch back to the default PHP version installed by your system package manager (e.g., pacman):
phpv systemThis removes the overrides created by phpv.
To use a specific PHP version again, simply run:
phpv <version>To update phpv to the latest version from the repository:
phpv --self-updateTo check the current installed version of phpv:
phpv -v
# or
phpv --versionPHPV automatically detects if c-client is missing and attempts to install it for you using the prebuilt binary from this repository. You typically don't need to do anything.
However, if the automatic installation fails, you can follow the manual steps below.
Download the pre-built c-client binary from PHPV:
Verification (Optional):
Verify the binary's integrity using the following hash values:
- MD5: 96d92a8b98afd78d2f2c80f8b0d76473
- SHA1: 4451582984bf02b1b78425b75100ca20018c8557
- SHA256: c6c9a0a411f476be1357f5aad8db897ce4d47f3f78757acd2aade3e477e2fe4d
- SHA512: 9628031b0f0efe4024c515f0a882418d7665b3267644f3bf0f12adbc5f200a9cca3049ab218be176ae8562673edca46190ca44de1154a32e0bf828028470ef1e
For additional verification, use VirusTotal.
Disclaimer: Manual compilation can introduce conflicts with existing system packages. It is recommended to use the pre-built binary or your system's package manager (e.g., pacman) for a safer installation.
Manual Compilation Steps:
-
Gather Your Tools:
Ensure you have the necessary development tools installed:
make- A C compiler (e.g.,
gcc) - Development headers for system libraries (
pacman -S base-devel)
Suggestion: Use
sudo pacman -S base-develto install essential development tools. -
Download the Source Code:
Access the official c-client source code repository: https://gitweb.gentoo.org/repo/gentoo.git/tree/
Tip: Always download the latest stable version to ensure compatibility and security.
-
Unpack the Source:
Extract the source code archive:
tar -zxvf c-client-X.Y.Z.tar.gz
Replace
X.Y.Zwith the specific version number.Suggestion: Use the
lscommand to verify the contents of the extracted directory. -
Configure and Build:
Navigate into the extracted directory:
cd c-client-X.Y.ZConfigure and build with specific flags:
CFLAGS="-Wno-error=implicit-function-declaration -Wno-error=incompatible-pointer-types" ./configureWarning: Suppressing warnings can mask underlying issues. It is recommended to investigate the cause of these warnings and fix them if possible.
Tip: Use
./configure --helpto see all available configuration options. -
Dependency Management:
Ensure all necessary dependencies are installed. Use
pacmanto check for missing packages.Suggestion: Before starting the compilation, use
sudo pacman -Syuto update your system and installed packages. -
Installation:
If you choose to proceed with manual installation, use
sudo make install:sudo make install
Tip: Always review the
Makefilebefore runningmake installto understand the installation process.
By following these steps, you can manually compile the c-client library for PHPV. However, for most users, the pre-built binary or using the system's package manager is the recommended approach.


