Compile and install PHP7 development environment on Mac

Source: Internet
Author: User
This article describes how to compile and install the PHP7 development environment on Mac. if you need more information, refer to the following: Today, the beta version of php7 beta1 is released, so hurry up and take the lead to download and upgrade your development environment to PHP7. let's get started with it...

First, you have to go to the official website to download the php7 beta1 version.

Here, because I installed it on mac, I downloaded the linux-related version. The address is also directly attached.

Php7 beta1

Windows official release details are also pushed: here

Decompress the installation package and go to the source code directory.

The code is as follows:


Tar-zxvf php-7.0.0beta1.tar.gz
Cd php-7.0.0beta1

Configure

The code is as follows:


./Buildconf -- force
. /Configure -- prefix =/usr/local/php7 -- with-apxs2 =/usr/sbin/apxs -- enable-fpm -- with-fpm-user = www -- with-fpm-group = www -- with-mysqli -- with-pdo-mysql -- with-iconv-dir -- with-freetype-dir -- with-jpeg-dir -- with-png-dir -- with-zlib -- -libxml-dir =/usr -- enable-xml -- disable-rpath -- enable-bcmath -- enable-shmop -- enable-sysvsem -- enable-inline-optimization -- with-curl -- enable-xml- mbregex -- enable-mbstring -- with-mcrypt -- enable-ftp -- with-gd -- enable-gd-native-ttf -- with-openssl -- with-mhash -- enable-pcntl -- enable- sockets -- with-xmlrpc -- enable-zip -- enable-soap -- without-pear -- with-gettext -- disable-fileinfo -- enable-maintainer-zts

The following are the compilation errors and solutions:

The code is as follows:


Configure: error: Cannot locate header file libintl. h

Install gettext

The code is as follows:


Sudo brew install gettext

Edit The configure file and find the path $ PHP_GETTEXT/usr/local/usr followed by gettext.

The code is as follows:

$ PHP_GETTEXT/usr/local/opt/gettext

You can reconfigure it. the following parameters are the same as above, and are omitted here]

I may have installed php7 alpha before, so there will be fewer errors. However, if there are any errors in the process, I will post them for further research.

Compile

Make

#
Generating phar. php
Generating phar. phar
PEAR package PHP_Archive not installed: generated phar will require PHP's phar extension be enabled.
Clicommand. inc
Directorygraphiterator. inc
Directorytreeiterator. inc
Invertedregexiterator. inc
Pharcommand. inc
Phar. inc

Build complete.
Don't forget to run 'Make test '.
#
It will last for a period of time. Generally, there will be no errors unless your character is wrong...

Install

The code is as follows:


Sudo make install

If the above steps are successful, this step is so simple to do, but remember to pay attention to the installation process information, which will be required later...

Command line test

The code is as follows:


/Usr/local/php7/bin7-v

# Directly replace the default php command for future convenience
# If you want to back up your data, I will directly overwrite it here...

The code is as follows:


Sudo cp/usr/local/php7/bin/ph */usr/bin/

No sense of violation, such a process, haha!

Configure apache

Open the apache configuration file httpd. conf, find the original LoadModule php5_module, and comment out it directly. add LoadModule php7_module/usr/libexec/apache2/libphp7.so to the following code. The final result is as follows:

The code is as follows:


Sudo vim/etc/apache2/httpd. conf
...
# LoadModule php5_module libexec/apache2/libphp5.so
LoadModule php7_module/usr/libexec/apache2/libphp7.so
...

Restart apache and test it.

Surprised to find that the php file is directly output to the browser...

Apache does not know how to parse the php file !!!

After troubleshooting for a long time, I found that switching to php5 is okay, and php7 cannot be parsed ???

Finally, we found that apache is suitable for parsing php to determine the module, such as ifModule php5_module, in httpd. in conf, find this sentence: Include/private/etc/apache2/other /*. conf. after entering this directory, you will understand...

There is a php5.conf file in it. should php7 correspond to a php7 file? copy it and open the file to see the words similar to php5_module, replace it with php7_module. the related content is as follows:

# Httpd. conf changes...
 
  
Include/private/etc/apache2/other/php5.conf
 
 
  
Include/private/etc/apache2/other/php7.conf
 # Include/private/etc/apache2/other/*. conf... # php7.conf content
 
  
AddType application/x-httpd-php. php AddType application/x-httpd-php-source. phps
  
   
DirectoryIndex index.html index. php
  
 

Restart apache again and test it.

The code is as follows:


Sudo apachectl restart

A long-time illegal image appeared...

The above is all the content of this article. I hope you will like it.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.