Install php7.2+ and composer on Mac

Install php7.2+

Steps

  1. Install HomeBrew
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
  1. Install Php with Brew
brew install [email protected]   
// Error: [email protected] has been disabled because it is deprecated upstream!   
// 提示官方已不再维护 
  1. Use a third-party repository
// 将第三方仓库加入brew
brew tap shivammathur/php
// 安装PHP
brew install shivammathur/php/[email protected]
  1. Prompt to write environment variables

  • Go to the folder ~/, modify .bash_profilethe file
export LDFLAGS="-L/usr/local/opt/[email protected]/lib"
export CPPFLAGS="-I/usr/local/opt/[email protected]/include"
  • Go to the folder ~/, modify . zshrcthe file
source ~/.bash_profile
  1. link php version
brew link --overwrite [email protected]
  • Restart the terminal or executebrew services restart php
  • check php versionphp -V
  1. other configuration

Modify the file /usr/local/etc/php/7.2/php-fpm.conf, remove the semicolon in front of the 17th and 24th lines

other instructions


install composer

  1. Download composer (eg. 2.4.4): https://getcomposer.org/download/
  2. Move composer.pharthe file to /usr/local/binthe next: open the terminal to execute the commandmv composer.phar /usr/local/bin/composer
  3. Give composer execution permission:chmod +x /usr/local/bin/composer
  4. testcomposer


Install multiple versions of php --2023.01.14 update

Steps

  1. View warehousebrew search php

  1. Install php5.6

brew install shivammathur/php/[email protected]

  1. Add PHP environment variables
# 终端
vim ~/.bash_profile  
 
# 新增
export PATH="/opt/homebrew/opt/[email protected]/bin:$PATH"
export PATH="/opt/homebrew/opt/[email protected]/sbin:$PATH"  
 
# 终端 刷新 ~/.bash_profile
source ~/.bash_profile
  1. Install the PHP version switching tool brew-php-swither
brew install brew-php-switcher
  1. Switch and use different versions of php
# 切换版本
brew-php-switcher 5.6
brew-php-switcher 7.2

php -v

# 其他命令
brew services start [email protected] # 启动 php5.6
brew services stop [email protected] #关闭 php5.6

Digression

In this first year of fast-growing technology, programming is like a ticket to a world of infinite possibilities for many people. In the star lineup of programming languages, Python is like the leading superstar. With its concise and easy-to-understand syntax and powerful functions, it stands out and becomes one of the most popular programming languages ​​in the world.


The rapid rise of Python is extremely beneficial to the entire industry , but " 人红是非多" has caused it to add a lot of criticism, but it still cannot stop its hot development momentum.

Will Python remain relevant and intact for the rest of the next decade? Today, we're going to analyze the facts and dispel some misconceptions.

If you are interested in Python and want to get a higher salary by learning Python, then the following set of Python learning materials must be useful to you!

Materials include: Python installation package + activation code, Python web development, Python crawler, Python data analysis, artificial intelligence, machine learning and other learning tutorials. Even beginners with 0 basics can understand and understand. Follow the tutorial and take you to learn Python systematically from zero basics!

1. Learning routes in all directions of Python

The route of all directions in Python is to organize the commonly used technical points of Python to form a summary of knowledge points in various fields. Its usefulness lies in that you can find corresponding learning resources according to the above knowledge points to ensure that you learn more comprehensively.
insert image description here
2. Python learning software

If a worker wants to do a good job, he must first sharpen his tools. The commonly used development software for learning Python is here!
insert image description here
3. Python introductory learning video

There are also many learning videos suitable for getting started with 0 basics. With these videos, you can easily get started with Python~insert image description here

4. Python exercises

After each video lesson, there are corresponding practice questions, you can test the learning results haha!
insert image description here

Five, Python actual combat case

Optical theory is useless. You have to learn to type codes along with it, and then you can apply what you have learned in practice. At this time, you can learn from some practical cases. This information is also included~insert image description here

6. Python interview materials

After we have learned Python, we can go out and find a job with the skills! The following interview questions are all from first-line Internet companies such as Alibaba, Tencent, and Byte, and some Alibaba bosses have given authoritative answers. After reading this set of interview materials, I believe everyone can find a satisfactory job.
insert image description here
insert image description here
7. Information collection

The full set of learning materials for the above-mentioned full version of Python has been uploaded to the CSDN official website. Those who need it can scan the QR code of the CSDN official certification below on WeChat to receive it for free.

Guess you like

Origin blog.csdn.net/pythonhy/article/details/132239556