Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to install the new version of PHP7.0+ on macOS Sierra (10.12.1)

2025-03-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly gives you a brief description of how to install the new version of PHP7.0+, on macOS Sierra (10.12.1). You can check the relevant technical terms on the Internet or find some related books to supplement it. We will not dabble here, let's go straight to the topic, and hope that this article on macOS Sierra (10.12.1) on how to install the new version of PHP7.0+ can bring you some practical help.

Preparation before installation

1. Install or update Homebrew

Homebrew does not go into too much detail, and it is not the first time it has been mentioned in the blog, it is an indispensable package manager on Mac. The screenshot below shows the version of brew I use locally, which is, of course, the latest version. Before installing the above, make sure that your brew is up to date. There is no need to elaborate too much on the installation of Homebrew under Mac. Please Google yourself.

The brew update update operation is first carried out below, reminding me that the current brew is the latest version. We can use brew-v to see the current version of brew. If you are not familiar with brew, you can use brew-h to view the relevant command operations of brew. The details are as follows:

2.Xcode8.2

Make sure your Xcode is up-to-date. If your Xcode is prior to 8.2, you will be prompted to "update Xcode" when you compile PHP7.0+. Here is the error in compiling PHP7.0 Times under Xcode8.1.

So, make sure your Xcode is the latest version, and here is my updated version of Xcode8.2.

II. Installation of Apache2.4

Of course, it is relatively easy to install Apache2.4 using brew. Below is the command to install Apache2.4. First use brew's tap command to create Apache's repository, and then use the install command to install Apache. What is installed here is Apache2.4, so it is brew install httpd24. If you want to install Apache2.2, it is brew install httpd22.

Brew tap homebrew/apache

Brew install httpd24

The specific process is as follows:

After a successful installation, you can use brew info httpd24 to view the details of your installation of Apache2.4. There will be a command to start the Apache service. The following is the corresponding action for using brew to operate Apache CVM.

Start Apache:brew services start homebrew/apache/httpd24

Restart Apache:brew services restart homebrew/apache/httpd24

Close Apache:brew services stop homebrew/apache/httpd24

After installing PHP7.0 later, we will configure Apache uniformly, but we can start the service of Apache first and use its default configuration first. Below is the access to our Apache service after startup. Of course, the default is port 8080, so you need to access the address is: localhost:8080, visit this address you will see the information below. The page below can be accessed in the browser, indicating that your Apache has been successfully installed.

III. Installation of MySQL

The installation of MySQL is also relatively simple, which we used before when introducing Swift's Perfect server framework, which means that I have installed the MySQL database locally through brew. Of course, if you don't have it installed, it's easier to install MySQL using brew. Below is the command to install mysql. You need to wait a while before your MySQL is installed.

Brew install mysql

Following the previous pattern, after installing the MySQL database, you can use the brew info mysql command to view the corresponding mysql information. Below is the corresponding information of my local mysql. It is clear from info that after you install MySQL for the first time, there will be a root without a password for you to log in to the MySQL database. After logging in, you can set a password for the root user.

From the above information, we can also see the command to start the mysql cloud server. Of course, we still use brew to start and shut down the MySQL service, as follows:

Launch: brew services start mysql

Restart: brew services restart mysql

Stop: brew services stop mysql

The specific actions are as follows:

As mentioned in previous blogs, Sequel Pro on Mac is relatively easy to use for visual management of MySQL, as shown below:

IV. Installation of PHP7.0

Next, we will use brew to install PHP7.0. There were some problems in the process, first of all, the problem with the Xcode version. I didn't upgrade the latest Xcode8.2 before, then I reported an error when installing PHP 7.0, and then I upgraded Xcode. Then there are other problems, which will be covered later.

1. View PHP7.0 information

Before using Brew to install PHP7.0, we'd better take a look at the corresponding installation information, because there are also some options when installing PHP using brew. If you do not add some options, you may not be able to use them in Apache, so it is better to take a look at the relevant information about PHP before installation.

Below is to use brew info php70 to view the corresponding information, of course, you can also install PHP7.1. The conflicting PHP version is shown below. And the corresponding dependency package is given. Of course, we haven't installed PHP7.0 yet, so we mostly take the X number. There are some options below that need to be used when installing PHP7.0. As we can see clearly from below, if you want to use the PHP version on Apache2.4, you have to add the parameter-- with-httpd24. This parameter is indispensable, and if you don't add it, the PHP you installed will not work on the corresponding Apache, as shown below.

two。 Create PHP repository and install PHP7.0

Below is the command for PHP7.0 installation. -- with-httpd24 must be added, otherwise it cannot be used on Apache2.4.

Brew tap homebrew/php

Brew install php70-with-httpd24

Below is an error I encountered when installing PHP7.0, which can be successfully installed directly by using brew install php70, while adding-- with-http24 will report the error below. In the error prompt below, the corresponding connection to solve the problem is given, "https://github.com/Homebrew/homebrew-php/issues/3736"." The corresponding solution is found in this github connection. After the terminal executes xcode-select-install, reinstall will OK.

V. Apache configuration

Next, we will configure our Apache CVM. Of course, it is mainly the association between Apache2.4 and PHP7.0. As mentioned above, we mainly configure httpd.conf files in this blog. First open the / usr/local/etc/apache2/2.4/httpd.conf file, which is the relevant configuration file for Apache2.4.

First of all, let's configure the corresponding PHP version, that is, the configuration information from PHP,Info, and paste it into httpd.conf.

Then configure the document root directory of the CVM.

If necessary, add the index.php index file,

After restarting the Apache service, we can test it, add the info.php method to the wwwdoc, and print the corresponding php information in the file using the phpinfo () function.

MacOS Sierra (10.12.1) is how to install the new version of PHP7.0+ to tell you here, for other related issues you want to know can continue to follow our industry information. Our section will capture some industry news and professional knowledge to share with you every day.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report