Compiling and installing PHP7 on Mac _php tips for developing environments

Source: Internet
Author: User
Tags fpm gettext pear

Today saw the bird brother Hair Micro Bo said php7 beta1 beta release, so hurriedly go to preemptive download, the development of their own environment also upgraded to PHP7 go, words not much, the following on a start up ...

First you have to go to the website to download the PHP7 beta1 version.

Here because I am installed on the Mac, so download the Linux related version, the address is also directly attached

PHP7 Beta1

The Windows version of the official also has the details of the posting jab: here

Unpack the installation package and enter the source code directory

Copy Code code as follows:

TAR-ZXVF php-7.0.0beta1.tar.gz
CD php-7.0.0beta1

Set up a configuration

Copy Code code 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-libxml-dir=/usr--enable-xml--disable-rpath--enable-bcmath--enable-shmop--enable-sysvsem-- Enable-inline-optimization--with-curl--enable-mbregex--enable-mbstring--with-mcrypt--enable-ftp-- Enable-gd-native-ttf--with-openssl--with-mhash--enable-pcntl--enable-sockets--with-xmlrpc-- Enable-soap--without-pear--with-gettext--disable-fileinfo--enable-maintainer-zts

Here is a list of the following errors and resolutions I encountered during the compilation process:

Copy Code code as follows:

Configure:error:Cannot Locate header File Libintl.h

Install GetText

Copy Code code as follows:

sudo brew install GetText

Edit the Configure file to find the path $PHP _gettext/usr/local/usr followed by GETTEXT

Copy Code code as follows:
$PHP _gettext/usr/local/usr/usr/local/opt/gettext

Reconfigure it. "The following parameters are the same as above, where you omit the"

I may be here because the previous PHP7 Alpha version, so the error will be a little less, but we have any errors in the process, directly posted out together we studied.

Compile

Make

#
Generating phar.php
Generating Phar.phar
PEAR Package php_archive not installed:generated Phar'll 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 '.
#
There will be a period of time, there will be no mistake, unless you have a moral problem ...

Installation

Copy Code code as follows:

sudo make install

The above steps are smooth, this step is so easy to do, but the installation process of information to remember to pay attention to, the following configuration will need ...

Command-line Testing

Copy Code code as follows:

/usr/local/php7/bin7-v

#为了以后事业方便, replace the system default PHP command directly
#当人你也可以备份一下, I have directly covered here to find ...

Copy Code code as follows:

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

No sense of Shong, running so flow, haha!

Configure Apache

Open the Apache configuration file httpd.conf, find the original LoadModule php5_module here, directly commented out, the following add LoadModule php7_module/usr/libexec/apache2/ Libphp7.so, finally as follows:

Copy Code code 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 then test a look at

Surprised to find that the PHP file directly output to the browser ...

The feeling is Apache don't know to parse PHP file!!!

Here I checked for a long time, found that switching to PHP5 version of the problem, PHP7 can not be resolved???

Finally found that Apache in the parsing of PHP is the right to judge the module, such as Ifmodule php5_module this, in httpd.conf find this sentence: include/private/etc/apache2/other/*. conf, go into the directory and see, you know ...

There is a php5.conf file, that is not php7 on the corresponding to a PHP7 file, so hurriedly copied a copy, open this file, see similar to the word php5_module, directly replaced Php7_module can, the relevant content is as follows:

#httpd. conf change
...
<ifmodule php5_module>
include/private/etc/apache2/other/php5.conf
</IfModule>

< Ifmodule php7_module>
include/private/etc/apache2/other/php7.conf
</IfModule>

#Include/ Private/etc/apache2/other/*.conf ...

#php7. conf content
<ifmodule php7_module>
  addtype application/x-httpd-php. php
  AddType application/ X-httpd-php-source. Phps

  <ifmodule dir_module>
      directoryindex index.html index.php
  </ Ifmodule>
</IfModule>

Finally restart Apache again and test

Copy Code code as follows:

sudo apachectl restart

A long-lost picture appeared ...

The above mentioned is the entire content of this article, I hope you can enjoy.

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.