كيفية تثبيت أحدث إصدار من PHP على نظام MacOS عبر Homebrew؟
نشرت: 2022-01-31
كيفية تثبيت PHP على نظام MacOS؟
في هذا البرنامج التعليمي ، سنتطرق إلى خطوات حول كيفية تثبيت PHP على نظام MacOS. سنستخدم Homebrew لتثبيت PHP على نظام MacOS.
PHP
هي لغة برمجة نصية للأغراض العامة مستخدمة على نطاق واسع وهي مناسبة بشكل خاص لتطوير الويب ويمكن تضمينها في HTML.
هيا بنا نبدأ:
- قم بإضافة PHP وتثبيته على macOS Monterey 12 مع Homebrew.
- التحديث إلى الإصدارين 7.4 و 8 من PHP على نظام macOS.
- تحديث إصدار PHP في نظام Mac
الخطوة 1
قم بتثبيت Homebrew على نظام MacOS بنجاح. يرجى اتباع هذا البرنامج التعليمي بالكامل.
الخطوة 2
بمجرد تثبيت Homebrew بنجاح ، قم بتثبيت PHP باستخدام الأمر أدناه.
1 2 |
bash - 3.2 $ brew install php |
فيما يلي نتيجة وحدة التحكم المفصلة لـ "brew install php":
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
bash - 3.2 $ bash - 3.2 $ bash - 3.2 $ brew install php == > Downloading https : //ghcr.io/v2/homebrew/core/apr/manifests/1.7.0_2 Already downloaded : / Users / app / Library / Caches / Homebrew / downloads / bea860ee12694d9b28c54323f66a2ed14e5b7b44c7fd2568ddd179b86f27829e -- apr - 1.7.0_2.bottle_manifest.json == > Downloading https : //ghcr.io/v2/homebrew/core/apr/blobs/sha256:706df15280f05bc3ab057bd5dd856746f02c4fcc7356cccd5babd92a6362f132 Already downloaded : / Users / app / Library / Caches / Homebrew / downloads / 3beab76299c09a6d05b8ddb53711803844ff70c996e04daf8188953e2d8e9dc3 -- apr -- 1.7.0_2.monterey.bottle.tar.gz == > Downloading https : //ghcr.io/v2/homebrew/core/php/manifests/8.1.2 Already downloaded : / Users / app / Library / Caches / Homebrew / downloads / bb615e3f8d0140a0e40ab9ada2f73189ec03af655631c39f30d78a02b2887ac4 -- php - 8.1.2.bottle_manifest.json == > Downloading https : //ghcr.io/v2/homebrew/core/php/blobs/sha256:08fc122518eca5e578ff4cd791c2ced0e4a10f707ec48f1938791473e38fceb5 Already downloaded : / Users / app / Library / Caches / Homebrew / downloads / f7d51e966f2f708d28d0888ffd9e830c1cb4212293ef8408e610be33024e4521 -- php -- 8.1.2.monterey.bottle.tar.gz == > Downloading https : //ghcr.io/v2/homebrew/core/php/blobs/sha256:08fc122518eca5e578ff4cd791c2ced0e4a10f707ec48f1938791473e38fceb5 Already downloaded : / Users / app / Library / Caches / Homebrew / downloads / f7d51e966f2f708d28d0888ffd9e830c1cb4212293ef8408e610be33024e4521 -- php -- 8.1.2.monterey.bottle.tar.gz == > Installing dependencies for php : apr , ca - certificates , openssl @ 1.1 , argon2 , aspell , m4 , autoconf , brotli , libunistring , libidn2 , libnghttp2 , libssh2 , openldap , rtmpdump , zstd , curl , libtool , unixodbc , freetds , libpng , freetype , fontconfig , jpeg , libtiff , giflib , webp , gd , gmp , icu4c , krb5 , libpq , libsodium , libzip , oniguruma , pcre2 , readline , sqlite and tidy - html5 == > Installing php dependency : apr == > Pouring apr -- 1.7.0_2.monterey.bottle.tar.gz / usr / local / Cellar / apr / 1.7.0_2 : 59 files , 1.4MB == > Installing php dependency : ca - certificates == > Pouring ca - certificates -- 2021 - 10 - 26.all.bottle.tar.gz == > Regenerating CA certificate bundle from keychain , this may take a while . . . / usr / local / Cellar / ca - certificates / 2021 - 10 - 26 : 3 files , 208.5KB == > Installing php dependency : openssl @ 1.1 == > Pouring openssl @ 1.1 -- 1.1.1m.monterey.bottle.tar.gz / usr / local / Cellar / openssl @ 1.1 / 1.1.1m : 8 , 081 files , 18.5MB == > Installing php dependency : argon2 == > Pouring php -- 8.1.2.monterey.bottle.tar.gz == > / usr / local / Cellar / php / 8.1.2 / bin / pear config - set php_ini / usr / local / etc / php / 8.1 / php . ini system == > / usr / local / Cellar / php / 8.1.2 / bin / pear config - set php_dir / usr / local / share / pear system == > / usr / local / Cellar / php / 8.1.2 / bin / pear config - set doc_dir / usr / local / share / pear / doc system == > / usr / local / Cellar / php / 8.1.2 / bin / pear config - set ext_dir / usr / local / lib / php / pecl / 20210902 system == > / usr / local / Cellar / php / 8.1.2 / bin / pear config - set bin_dir / usr / local / opt / php / bin system == > / usr / local / Cellar / php / 8.1.2 / bin / pear config - set data_dir / usr / local / share / pear / data system == > / usr / local / Cellar / php / 8.1.2 / bin / pear config - set cfg_dir / usr / local / share / pear / cfg system == > / usr / local / Cellar / php / 8.1.2 / bin / pear config - set www_dir / usr / local / share / pear / htdocs system == > / usr / local / Cellar / php / 8.1.2 / bin / pear config - set man_dir / usr / local / share / man system == > / usr / local / Cellar / php / 8.1.2 / bin / pear config - set test_dir / usr / local / share / pear / test system == > / usr / local / Cellar / php / 8.1.2 / bin / pear config - set php_bin / usr / local / opt / php / bin / php system == > / usr / local / Cellar / php / 8.1.2 / bin / pear update - channels == > Caveats To enable PHP in Apache add the following to httpd . conf and restart Apache : LoadModule php_module / usr / local / opt / php / lib / httpd / modules / libphp . so < FilesMatch \ . php $ > SetHandler application / x - httpd - php < / FilesMatch > Finally , check DirectoryIndex includes index . php DirectoryIndex index . php index . html The php . ini and php - fpm . ini file can be found in : / usr / local / etc / php / 8.1 / To restart php after an upgrade : brew services restart php Or , if you don ' t want / need a background service you can just run : / usr / local / opt / php / sbin / php - fpm -- nodaemonize == > Summary / usr / local / Cellar / php / 8.1.2 : 513 files , 80.0MB == > Running ` brew cleanup php ` . . . Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP . Hide these hints with HOMEBREW_NO_ENV_HINTS ( see ` man brew ` ) . bash - 3.2 $ bash - 3.2 $ |
فيما يلي بعض نتائج وحدة تحكم MacOS:



الخطوه 3
دعنا نتحقق من تفاصيل إصدار PHP ومكان تثبيته.
1 2 3 4 5 6 7 8 9 |
bash - 3.2 $ which php / usr / local / bin / php bash - 3.2 $ php - version PHP 8.1.2 ( cli ) ( built : Jan 21 2022 04 : 47 : 46 ) ( NTS ) Copyright ( c ) The PHP Group Zend Engine v4 . 1.2 , Copyright ( c ) Zend Technologies with Zend OPcache v8 . 1.2 , Copyright ( c ) , by Zend Technologies |
وأنت على أتم استعداد. اسمحوا لي أن أعرف إذا كنت تواجه أي مشكلة في تثبيت PHP على جهاز MacOS الخاص بك.
أين يوجد ملف apache.ini؟
1 |
bash - 3.2 $ vi / usr / local / etc / php / 8.1 / php . ini |
ترميز سعيد.