PHP 7 installation for Mac systems: detailed tutorial and macphp7 tutorial
After PHP version 5.6 was released, it has been waiting for a long time. When the PHP 7 version advances, the question is, where is version 6? According to the official statement, PHP7 is twice faster than PHP5.6, and some friends say it is ten times faster. I am used to the Mac system, therefore, the Mac system explains how to install PHP7 in detail!
There are usually several ways to install it.
I. We can compile the source code on the official website. I tried this method too, but at last compiled and installed make test, an error was reported during this step, so try the second method!
Second, it is very quick and effective to use a third-party package homebrew for installation!
Installation Tutorial:
1. First we need to install Homebrew
A command perfectly installs: http://brew.sh/index_zh-cn.html
2. Enter the following command on the terminal:
// Create a directory. If you have not created the sudo mkdir/usr/local/varsudo chmod 777/usr/local/var // directory, change it to your username and group, if you have not created the sudo mkdir/usr/local/sbin/sudo chown-R directory, <username>: <group>/usr/local/sbin // because I have been using version 5.6, the above steps are omitted, next, go to the topic // Add the PHP database brew tap homebrew/dupesbrew tap homebrew/versionsbrew tap homebrew/homebrew-php // close the process brew unlink PHP56 or 55 or earlier of the old version/ /start PHP7brew install php70 // start the PHP70 process brew link php70 // enter the command, check whether php-v is successful. // The following information is displayed: PHP 7.0.8 (cli) (built: Jul 13 2016 15:19:21) (ETS) Copyright (c) 1997-2016 The PHP GroupZend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
3. Modify the Apache configuration file
Sudo vim/etc/apache2/httpd. conf // locate about 168 rows. After blocking this statement, add the php7 statement according to your own path. so file # LoadModule php5_module libexec/apache2/libphp5.soLoadModule php7_module/usr/libexec/apache2/libphp7.so
This is the directory of my libphp7.so file. It seems to be the result of the default installation.
LoadModule php7_module/usr/local/Cellar/php70/7.0.0-rc.4/libexec/apache2/libphp7.so
4. Restart Apache
sudo apachectl restart
5. If the PHP file is output directly to the browser, You need to modify the following Configuration:
sudo vim /etc/apache2/httpd.conf
Find Include/private/etc/apache2/other/*. conf.
Enter this file
Modify the file content to the following code:
<IfModule php7_module>AddType application/x-httpd-php .phpAddType application/x-httpd-php-source .phps<IfModule dir_module>DirectoryIndex index.html index.php</IfModule></IfModule>
6. Restart apache again. Repeat Step 1.
Add an info. php file under the default directory/Library/WebServer/Documents of your Apache.
<?phpphpinfo();?>
Http: // localhost/info. php long-time illegal image, should already be in sight!
You can try the experiment from qianfeng PHP multiple times. The problem arises. After the installation, the previous project may be inaccessible. Check that there is a problem with MySQL, restart your mysql instance!
sudo /Library/StartupItems/MySQLCOM/MySQLCOM restart
Last
How can I add a mysql path to an environment variable on Mac?
1. Open the terminal and enter: cd ~
Will enter ~ Folder
2. Enter touch. bash_profile.
After you press enter to execute,
3. Enter open-e. bash_profile.
This file will be opened in TextEdit (if environment variables have not been configured before, this should be a blank document ). If there is content, enter it before the Terminator. If there is no content, enter the following statement:
export PATH=${PATH}:/usr/local/mysql/bin
The above is a detailed tutorial on the perfect installation of PHP7 for Mac systems. I hope it will be helpful to you. If you have any questions, please leave a message and I will reply to you in a timely manner. Thank you very much for your support for the help House website!