Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rapidwebltd/php-switch-scripts
π Scripts to aid in the setup of and switching between multiple PHP versions in Ubuntu 14.04 LTS or newer
https://github.com/rapidwebltd/php-switch-scripts
development-tools php php-versions php5 php7
Last synced: 2 months ago
JSON representation
π Scripts to aid in the setup of and switching between multiple PHP versions in Ubuntu 14.04 LTS or newer
- Host: GitHub
- URL: https://github.com/rapidwebltd/php-switch-scripts
- Owner: rapidwebltd
- License: lgpl-3.0
- Created: 2017-08-04T11:14:32.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2024-03-05T11:02:33.000Z (10 months ago)
- Last Synced: 2024-09-29T19:21:22.523Z (3 months ago)
- Topics: development-tools, php, php-versions, php5, php7
- Language: Shell
- Homepage:
- Size: 56.6 KB
- Stars: 69
- Watchers: 10
- Forks: 50
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# π PHP Switch Scripts
These scripts are designed to aid in the setup of and switching between multiple PHP versions in Ubuntu 14.04 LTS or newer.
Please note that these scripts install packages from a third-party repository, provided by [OndΕej SurΓ½](https://twitter.com/oerdnj). More details are available at the repository's [website](https://deb.sury.org/), [PPA page on Launchpad](https://launchpad.net/~ondrej/+archive/ubuntu/php/) and [Twitter account](https://twitter.com/debsuryorg).
## Requirements
* Ubuntu 14.04.* LTS or newer
* Apache 2.4.*You can check you have the required versions by running the following command.
```
lsb_release -a | grep Ubuntu && apache2 -v | grep Apache
```You should see something similar to the below.
```
Description: Ubuntu 14.04.5 LTS
Server version: Apache/2.4.18 (Ubuntu)
```## Setup
First, clone the repository, and change directory if you have not already done so.
```
git clone https://github.com/rapidwebltd/php-switch-scripts.git
cd php-switch-scripts
```Next, to setup all the supported PHP versions and common PHP extensions for them, you just need to run the `setup.sh` script. This is shown below.
```
./setup.sh
```This may take some time depending on your system and connection speed. It will also require you to enter your password to install new packages.
When you see a message similar to the following, setup is complete and you are ready to switch between PHP versions at will.
```
* Setup complete. You may now use the 'switch-to-php-*.*.sh' scripts.`
```## Usage
Once setup is complete, you can easily switch between different PHP versions using the appropriately named scripts. Examples are shown below.
```
./switch-to-php-5.6.sh
./switch-to-php-7.0.sh
./switch-to-php-7.1.sh
./switch-to-php-7.2.sh
./switch-to-php-7.3.sh
./switch-to-php-7.4.sh
```This will alter the versions of PHP running in Apache and the command line. Your password will be required to enable/disable Apache modules, restart the web server and alter the default PHP CLI version.
## Verification
If you wish, you can check that the switch was completed successfully.
You can verify the command line version of PHP has changed with the following command.
```
php -v | grep PHP
```You can check the version of PHP running in Apache by creating a new PHP file, that calls the `phpinfo()` method, then accessing it via a web browser. An example is shown below.
```php
```