<p dir="rtl" align="center">بسم الله الرحمن الرحیم</p>

# <p align="right" dir="rtl">نصب PHP </p> 

<p align="right" dir="rtl">
 گزینه (--dry-run) نصب حداقلی  را انجام می دهد:
</p>

```r
sudo apt-get install --dry-run php
```

<p align="right" dir="rtl">
 حال PHP را نصب می کنیم:
</p>

```r
sodu apt-get update && apt-get upgrade
```
<p align="right" dir="rtl">
گام 1: به روزرسانی سیستم اوبونتو
</p>

```r
sudo apt update && sudo apt -y upgrade
```

<p align="right" dir="rtl">
پس از ارتقا، کش APT را پاک کنید.
</p>

```r
sudo apt autoremove
```

<p align="right" dir="rtl">
بررسی کنید که آیا نیاز به راه اندازی مجدد است یا خیر و مطابق با آن عمل کنید.
</p>

```r
[ -f /var/run/reboot-required ] && sudo reboot -f
```

<p align="right" dir="rtl">
جزئیات انتشار سیستم عامل را می توان با استفاده از دستورات داده شده در اینجا بررسی کرد.
</p>

```r
cat /etc/os-release
```

<p style="background-color:black;color:white;">
<code>
PRETTY_NAME="Ubuntu 22.04.1 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04.1 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=jammy
</code>
</p>

<p align="right" dir="rtl">
گام 2: مخزن APT را اضافه کنید
</p>
sudo apt update
sudo apt install -y lsb-release gnupg2 ca-certificates apt-transport-https software-properties-common
sudo add-apt-repository ppa:ondrej/php

<p style="background-color:black;color:white;">
<code>
Expected successful command execution.
...
<br>
# LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php
More info: https://launchpad.net/~ondrej/+archive/ubuntu/php
Adding repository.
Press [ENTER] to continue or Ctrl-c to cancel.
Adding deb entry to /etc/apt/sources.list.d/ondrej-ubuntu-php-jammy.list
Adding disabled deb-src entry to /etc/apt/sources.list.d/ondrej-ubuntu-php-jammy.list
Adding key to /etc/apt/trusted.gpg.d/ondrej-ubuntu-php.gpg with fingerprint 14AA40EC0831756756D7F66C4F4EA0AAE5267A6C
Hit:1 https://mirror.hetzner.com/ubuntu/packages jammy InRelease
Hit:2 https://mirror.hetzner.com/ubuntu/packages jammy-updates InRelease
Hit:3 https://mirror.hetzner.com/ubuntu/packages jammy-backports InRelease
Hit:4 https://mirror.hetzner.com/ubuntu/security jammy-security InRelease
Get:5 https://ppa.launchpadcontent.net/ondrej/php/ubuntu jammy InRelease [23.9 kB]
Get:6 https://ppa.launchpadcontent.net/ondrej/php/ubuntu jammy/main amd64 Packages [108 kB]
Get:7 https://ppa.launchpadcontent.net/ondrej/php/ubuntu jammy/main Translation-en [33.3 kB]
Fetched 166 kB in 1s (120 kB/s)
Reading package lists... Done
</code>
</p>

<p align="right" dir="rtl">
با اجرای دستور apt update می توانید به صورت دستی تأیید کنید که مخزن کار می کند.

```r
sudo apt update
```

<p style="background-color:black;color:white;">
<code>
Hit:1 https://mirror.hetzner.com/ubuntu/packages jammy InRelease
Hit:2 https://mirror.hetzner.com/ubuntu/packages jammy-updates InRelease
Hit:3 https://mirror.hetzner.com/ubuntu/packages jammy-backports InRelease
Hit:4 https://mirror.hetzner.com/ubuntu/security jammy-security InRelease
Hit:5 https://ppa.launchpadcontent.net/ondrej/php/ubuntu jammy InRelease
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
</code>
</p>

<p align="right" dir="rtl">
گام 3: نصب PHP 8.2 در Ubuntu
</p>

```r
sudo apt install php8.2
```

<p style="background-color:black;color:white;">
<code>
Accept package installation as requested via prompt.

The following additional packages will be installed:
  apache2 apache2-bin apache2-data apache2-utils bzip2 file libapache2-mod-php8.2 libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap liblua5.3-0 mailcap mime-support php-common
  php8.2-cli php8.2-common php8.2-opcache php8.2-readline ssl-cert
Suggested packages:
  apache2-doc apache2-suexec-pristine | apache2-suexec-custom www-browser bzip2-doc php-pear
The following NEW packages will be installed:
  apache2 apache2-bin apache2-data apache2-utils bzip2 file libapache2-mod-php8.2 libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap liblua5.3-0 mailcap mime-support php-common php8.2
  php8.2-cli php8.2-common php8.2-opcache php8.2-readline ssl-cert
0 upgraded, 21 newly installed, 0 to remove and 2 not upgraded.
Need to get 6,990 kB of archives.
After this operation, 29.8 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
..
</code>
</p>

<p align="right" dir="rtl">
بررسی نسخه PHP:
</p>

```r
php -v
```

یا

```r
php --version
```

<p style="background-color:black;color:white;">
<code>
PHP 8.2.7 (cli) (built: Jun  8 2023 15:27:40) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.2.7, Copyright (c) Zend Technologies
     with Zend OPcache v8.2.7, Copyright (c), by Zend Technologies
</code>
</p>

<p dir="rtl" align="center">صلوات</p>
