|
| 1 | +--- |
| 2 | +isChild: true |
| 3 | +anchor: linux_setup |
| 4 | +--- |
| 5 | + |
| 6 | +## Linux Setup {#linux_setup_title} |
| 7 | + |
| 8 | +Most GNU/Linux distributions come with PHP available from the official repositories, but those packages usually are a little behind the current stable version. There are multiple ways to get newer PHP versions on such distributions. On Ubuntu and Debian-based GNU/Linux distributions, for instance, the best alternatives for native packages are provided and maintened by [Ondřej Surý][Ondrej Sury Blog], through his Personal Package Archive (PPA) on Ubuntu and DPA/bikeshed on Debian. Find instructions for each of these below. All that said, you can always use containers, compile the PHP Source code, etc. |
| 9 | + |
| 10 | +### Ubuntu-based distributions |
| 11 | + |
| 12 | +For Ubuntu distributions, the [PPA by Ondřej Surý][Ondrej Sury PPA] provides supported PHP versions along with many PECL extensions. To add this PPA to your system, perform the following steps in your terminal: |
| 13 | + |
| 14 | +1. First, add the PPA to your system's software sources using the command: |
| 15 | + |
| 16 | + ```bash |
| 17 | + sudo add-apt-repository ppa:ondrej/php |
| 18 | + ``` |
| 19 | + |
| 20 | +2. After adding the PPA, update your system's package list: |
| 21 | + |
| 22 | + ```bash |
| 23 | + sudo apt update |
| 24 | + ``` |
| 25 | + |
| 26 | +This will ensure that your system can access and install the latest PHP packages available in the PPA. |
| 27 | + |
| 28 | +#### Debian-based distributions |
| 29 | + |
| 30 | +For Debian-based distributions, Ondřej Surý also provides a [bikeshed][bikeshed] (Debian equivalent of a PPA). To add the bikeshed to your system and update it, follow these steps: |
| 31 | + |
| 32 | +1. Ensure that you have root access. If not, you might need to use `sudo` for the following commands. |
| 33 | + |
| 34 | +2. Update your system's package list: |
| 35 | + |
| 36 | + ```bash |
| 37 | + sudo apt-get update |
| 38 | + ``` |
| 39 | + |
| 40 | +3. Install `lsb-release`, `ca-certificates`, and `curl`: |
| 41 | + |
| 42 | + ```bash |
| 43 | + sudo apt-get -y install lsb-release ca-certificates curl |
| 44 | + ``` |
| 45 | + |
| 46 | +4. Download the signing key for the repository: |
| 47 | + |
| 48 | + ```bash |
| 49 | + sudo curl -sSLo /usr/share/keyrings/deb.sury.org-php.gpg https://packages.sury.org/php/apt.gpg |
| 50 | + ``` |
| 51 | + |
| 52 | +5. Add the repository to your system's software sources: |
| 53 | + |
| 54 | + ```bash |
| 55 | + sudo sh -c 'echo "deb [signed-by=/usr/share/keyrings/deb.sury.org-php.gpg] https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list' |
| 56 | + ``` |
| 57 | + |
| 58 | +6. Finally, update your system's package list again: |
| 59 | + |
| 60 | + ```bash |
| 61 | + sudo apt-get update |
| 62 | + ``` |
| 63 | + |
| 64 | +With these steps, your system will be able to install the latest PHP packages from the bikeshed. |
| 65 | + |
| 66 | +[Ondrej Sury Blog]: https://deb.sury.org/ |
| 67 | +[Ondrej Sury PPA]: https://launchpad.net/~ondrej/+archive/ubuntu/php |
| 68 | +[bikeshed]: https://packages.sury.org/php/ |
0 commit comments