Home Backend Development PHP Tutorial Detailed explanation of installing php7 under mac

Detailed explanation of installing php7 under mac

Mar 28, 2018 am 10:30 AM
php php7 Detailed explanation

本文主要为大家介绍一下mac 下安装php7全过程。具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧,希望能帮助到大家。

更新系统库


yum -y install gcc gcc-c++ automake autoconf libtool make lrzsz expect asciidoc xmlto expat-devel.x86_64 texinfo
yum -y install gcc gcc-c++ glibc libmcrypt-devel mhash-devel libxslt-devel libjpeg libjpeg-devel libpng libpng-devel freetype 
freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel 
curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel
Copy after login

安装pcre 正则表达式库


cd /usr/local/src
//wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.38.tar.gz
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.40.tar.gz
tar -zxvf pcre-8.40.tar.gz
cd pcre-8.40
./configure
make && make install
Copy after login

安装Zlib库


cd /usr/local/src
//wget http://zlib.net/zlib-1.2.8.tar.gz
wget http://zlib.net/zlib-1.2.11.tar.gz
tar -zxvf zlib-1.2.11.tar.gz
cd zlib-1.2.11
./configure
make && make install
Copy after login

安装SSL库


cd /usr/local/src
//wget https://www.openssl.org/source/openssl-1.0.2h.tar.gz
wget https://www.openssl.org/source/openssl-1.1.0e.tar.gz
tar -zxvf openssl-1.1.0e.tar.gz
Copy after login

安装nginx


cd /usr/local/src
wget http://nginx.org/download/nginx-1.10.3.tar.gz
tar -zxvf nginx-1.10.3.tar.gz
cd nginx-1.10.3
./configure --sbin-path=/usr/local/nginx/nginx --conf-path=/usr/local/nginx/nginx.conf --pid-path=/usr/local/nginx/nginx.pid --with-http_ssl_module --with-pcre=/usr/local/src/pcre-8.40 --with-zlib=/usr/local/src/zlib-1.2.11 --with-openssl=/usr/local/src/openssl-1.1.0e
make && make install
Copy after login

出现报错,要重新安装mcrypt

error: mcrypt.h not found. Please reinstall libmcrypt.


 wget ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/attic/libmcrypt/libmcrypt-2.5.7.tar.gz 
tar -zxvf libmcrypt-2.5.7.tar.gz 
cd libmcrypt-2.5.7 
./configure 
make && make install
Copy after login

安装库


echo "/usr/local/lib">> /etc/ld.so.conf.d/local.conf
ldconfig -v
Copy after login

安装php7


cd /usr/local/src
wget http://cn2.php.net/distributions/php-7.1.3.tar.gz
tar -zxvf php-7.1.3.tar.gz
cd php-7.1.3
./configure --prefix=/usr/local/php \
--with-mcrypt \
 --with-curl \
 --with-jpeg-dir \
--with-freetype-dir \
 --with-gd \
 --with-gettext \
 --with-iconv-dir \
 --with-kerberos \
 --with-libdir=lib64 \
 --with-libxml-dir \
 --with-mysqli \
 --with-openssl \
 --with-pcre-regex \
 --with-pdo-mysql \
 --with-pdo-sqlite \
 --with-pear \
 --with-png-dir \
 --with-xmlrpc \
 --with-xsl \
 --with-zlib \
 --enable-fpm \
 --enable-bcmath \
 --enable-libxml \
 --enable-inline-optimization \
 --enable-gd-native-ttf \
 --enable-mbregex \
 --enable-mbstring \
 --enable-opcache \
 --enable-pcntl \
 --enable-shmop \
 --enable-soap \
 --enable-sockets \
 --enable-sysvsem \
 --enable-xml \
 --enable-zip
make && make install
cp php.ini-production /usr/local/php/lib/php.ini
Copy after login

修改php用户


 cd /usr/local/php/
 cp etc/php-fpm.conf.default etc/php-fpm.conf
 cp etc/php-fpm.d/www.conf.default etc/php-fpm.d/www.conf
 groupadd www
 useradd -g www www
 vim etc/php-fpm.d/www.conf
    修改配置中的user和group改为www
 vim /usr/local/nginx/nginx.conf
Copy after login

修改nginx配置


cd /usr/local/nginx/
vim nginx.conf
   include conf.d/*.conf;
mkdir conf.d
vim conf.d/www.conf
server {
  listen 80;
  server_name xxxxx;
  root /var/www/xxxxx;
  location / {
    index index.php;
  }
  location ~ \.php {
      fastcgi_pass 127.0.0.1:9000;
      fastcgi_index index.php;
      fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
      client_max_body_size 60m;
      include fastcgi_params;
  }
  if (!-e $request_filename) {
    rewrite ^/(.*) /index.php/$1 last;
  }
}
Copy after login

安装mysql5.6

下载mysql5.6


cd /usr/local/src/
wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.30.tar.gz
Copy after login

安装cmake


cd /usr/local/src/
     wget https://cmake.org/files/v3.5/cmake-3.5.2.tar.gz
     tar xzvf cmake-3.5.2.tar.gz
     cd cmake-3.5.2
     ./bootstrap
     gmake
     gmake install
Copy after login

安装mysql


cd /usr/local/src/
groupadd mysql
useradd -g mysql mysql
tar xzvf mysql-5.6.30.tar.gz
cd mysql-5.6.30
cmake .
make && make install
chown -R mysql:mysql /usr/local/mysql
cd /usr/local/mysql/
rm -rf /etc/my.cnf
scripts/mysql_install_db --user=mysql
cp support-files/my-default.cnf /etc/my.cnf

vi /etc/profile
 PATH=/usr/local/mysql/bin:$PATH
 export PATH
source /etc/profile

cp support-files/mysql.server /etc/init.d/mysql
chmod +x /etc/init.d/mysql
chkconfig mysql on
service mysql start
Copy after login

修改授权


mysql -uroot -p
use mysql
select host,user,password from user;
delete from user where user = '';
update user set password = PASSWORD('1234qwer') where user = 'root';
//update user set host = '%' where user = 'root';
flush privileges;
Copy after login

安装git


yum -y install lrzsz
 yum -y install openjade texinfo perl perl-XML-SAX.noarch
 rpm -ivh http://mirror.nl.leaseweb.net/epel/6Server/x86_64/docbook2X-0.8.8-1.el6.x86_64.rpm (centos6)
 rpm -ivh http://dl.fedoraproject.org/pub/epel/7/x86_64/d/docbook2X-0.8.8-17.el7.x86_64.rpm (centos7)
 cd /usr/bin/
 ln -s db2x_docbook2texi docbook2x-texi
 cd /usr/local/src
 wget https://codeload.github.com/git/git/zip/v2.8.3
 unzip v2.8.3
 cd git-2.8.3
 make prefix=/usr install install-doc install-html install-info
(yum install perl-ExtUtils-CBuilder perl-ExtUtils-MakeMaker)
 make install
Copy after login

安装php的yaf、redis扩展


cd /usr/local/src
wget https://pecl.php.net/get/yaf-3.0.4.tgz
 tar -zxvf yaf-3.0.4.tgz
 cd yaf-3.0.4
 /usr/local/php/bin/phpize
 ./configure --with-php-config=/usr/local/php/bin/php-config
 make && make install

 cd /usr/local/src
 wget https://codeload.github.com/phpredis/phpredis/zip/php7
 unzip phpredis-php7.zip
 cd phpredis-php7
 /usr/local/php/bin/phpize
 ./configure --with-php-config=/usr/local/php/bin/php-config
 make && make install

 vim /usr/local/php/lib/php.ini
 extension=/usr/local/php/lib/php/extensions/no-debug-non-zts-20151012/yaf.so
 extension=/usr/local/php/lib/php/extensions/no-debug-non-zts-20151012/redis.so

 extension=/usr/local/php/lib/php/extensions/no-debug-non-zts-20160303/yaf.so
 extension=/usr/local/php/lib/php/extensions/no-debug-non-zts-20160303/redis.so
Copy after login

安装redis


 cd /usr/local/src/
 //wget http://download.redis.io/releases/redis-3.2.80.tar.gz
 wget http://download.redis.io/redis-stable.tar.gz
 //tar xzf redis-3.2.8.tar.gz
 tar xzf redis-stable.tar.gz
 cd redis-3.2.8
 cd redis-stable
 make

 cp src/redis-server /etc/init.d/redis
 cp redis.conf /etc/redis.conf
 chmod +x /etc/init.d/redis
 service redis /etc/redis.conf &
Copy after login


The above is the detailed content of Detailed explanation of installing php7 under mac. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian Dec 24, 2024 pm 04:42 PM

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

How To Set Up Visual Studio Code (VS Code) for PHP Development How To Set Up Visual Studio Code (VS Code) for PHP Development Dec 20, 2024 am 11:31 AM

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Apr 05, 2025 am 12:04 AM

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

How to automatically set permissions of unixsocket after system restart? How to automatically set permissions of unixsocket after system restart? Mar 31, 2025 pm 11:54 PM

How to automatically set the permissions of unixsocket after the system restarts. Every time the system restarts, we need to execute the following command to modify the permissions of unixsocket: sudo...

PHP Program to Count Vowels in a String PHP Program to Count Vowels in a String Feb 07, 2025 pm 12:12 PM

A string is a sequence of characters, including letters, numbers, and symbols. This tutorial will learn how to calculate the number of vowels in a given string in PHP using different methods. The vowels in English are a, e, i, o, u, and they can be uppercase or lowercase. What is a vowel? Vowels are alphabetic characters that represent a specific pronunciation. There are five vowels in English, including uppercase and lowercase: a, e, i, o, u Example 1 Input: String = "Tutorialspoint" Output: 6 explain The vowels in the string "Tutorialspoint" are u, o, i, a, o, i. There are 6 yuan in total

How do you parse and process HTML/XML in PHP? How do you parse and process HTML/XML in PHP? Feb 07, 2025 am 11:57 AM

This tutorial demonstrates how to efficiently process XML documents using PHP. XML (eXtensible Markup Language) is a versatile text-based markup language designed for both human readability and machine parsing. It's commonly used for data storage an

Explain late static binding in PHP (static::). Explain late static binding in PHP (static::). Apr 03, 2025 am 12:04 AM

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

Why does an error occur when installing an extension using PECL in a Docker environment? How to solve it? Why does an error occur when installing an extension using PECL in a Docker environment? How to solve it? Apr 01, 2025 pm 03:06 PM

Causes and solutions for errors when using PECL to install extensions in Docker environment When using Docker environment, we often encounter some headaches...

See all articles