mac 下安装php7全过程介绍

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

更新系统库

  1. yum -y install gcc gcc-c++ automake autoconf libtool make lrzsz expect asciidoc xmlto expat-devel.x86_64 texinfo
  2. 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

安装pcre 正则表达式库

  1. cd /usr/local/src
  2. //wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.38.tar.gz
  3. wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.40.tar.gz
  4. tar -zxvf pcre-8.40.tar.gz
  5. cd pcre-8.40
  6. ./configure
  7. make && make install

安装Zlib库

  1. cd /usr/local/src
  2. //wget http://zlib.net/zlib-1.2.8.tar.gz
  3. wget http://zlib.net/zlib-1.2.11.tar.gz
  4. tar -zxvf zlib-1.2.11.tar.gz
  5. cd zlib-1.2.11
  6. ./configure
  7. make && make install

安装SSL库

  1. cd /usr/local/src
  2. //wget https://www.openssl.org/source/openssl-1.0.2h.tar.gz
  3. wget https://www.openssl.org/source/openssl-1.1.0e.tar.gz
  4. tar -zxvf openssl-1.1.0e.tar.gz

安装nginx

  1. cd /usr/local/src
  2. wget http://nginx.org/download/nginx-1.10.3.tar.gz
  3. tar -zxvf nginx-1.10.3.tar.gz
  4. cd nginx-1.10.3
  5. ./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
  6. make && make install

出现报错,要重新安装mcrypt

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

  1. wget ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/attic/libmcrypt/libmcrypt-2.5.7.tar.gz
  2. tar -zxvf libmcrypt-2.5.7.tar.gz
  3. cd libmcrypt-2.5.7
  4. ./configure
  5. make && make install

安装库

echo "/usr/local/lib">> /etc/ld.so.conf.d/local.conf

ldconfig -v

安装php7

  1. cd /usr/local/src
  2. wget http://cn2.php.net/distributions/php-7.1.3.tar.gz
  3. tar -zxvf php-7.1.3.tar.gz
  4. cd php-7.1.3
  5. ./configure --prefix=/usr/local/php \
  6. --with-mcrypt \
  7. --with-curl \
  8. --with-jpeg-dir \
  9. --with-freetype-dir \
  10. --with-gd \
  11. --with-gettext \
  12. --with-iconv-dir \
  13. --with-kerberos \
  14. --with-libdir=lib64 \
  15. --with-libxml-dir \
  16. --with-mysqli \
  17. --with-openssl \
  18. --with-pcre-regex \
  19. --with-pdo-mysql \
  20. --with-pdo-sqlite \
  21. --with-pear \
  22. --with-png-dir \
  23. --with-xmlrpc \
  24. --with-xsl \
  25. --with-zlib \
  26. --enable-fpm \
  27. --enable-bcmath \
  28. --enable-libxml \
  29. --enable-inline-optimization \
  30. --enable-gd-native-ttf \
  31. --enable-mbregex \
  32. --enable-mbstring \
  33. --enable-opcache \
  34. --enable-pcntl \
  35. --enable-shmop \
  36. --enable-soap \
  37. --enable-sockets \
  38. --enable-sysvsem \
  39. --enable-xml \
  40. --enable-zip
  41. make && make install
  42. cp php.ini-production /usr/local/php/lib/php.ini

修改php用户

  1. cd /usr/local/php/
  2. cp etc/php-fpm.conf.default etc/php-fpm.conf
  3. cp etc/php-fpm.d/www.conf.default etc/php-fpm.d/www.conf
  4. groupadd www
  5. useradd -g www www
  6. vim etc/php-fpm.d/www.conf
  7. 修改配置中的user和group改为www
  8. vim /usr/local/nginx/nginx.conf

修改nginx配置

  1. cd /usr/local/nginx/
  2. vim nginx.conf
  3. include conf.d/*.conf;
  4. mkdir conf.d
  5. vim conf.d/www.conf
  6. server {
  7. listen 80;
  8. server_name xxxxx;
  9. root /var/www/xxxxx;
  10. location / {
  11. index index.php;
  12. }
  13. location ~ \.php {
  14. fastcgi_pass 127.0.0.1:9000;
  15. fastcgi_index index.php;
  16. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  17. client_max_body_size 60m;
  18. include fastcgi_params;
  19. }
  20. if (!-e $request_filename) {
  21. rewrite ^/(.*) /index.php/$1 last;
  22. }
  23. }

安装mysql5.6

下载mysql5.6

cd /usr/local/src/

wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.30.tar.gz

安装cmake

  1. cd /usr/local/src/
  2. wget https://cmake.org/files/v3.5/cmake-3.5.2.tar.gz
  3. tar xzvf cmake-3.5.2.tar.gz
  4. cd cmake-3.5.2
  5. ./bootstrap
  6. gmake
  7. gmake install

安装mysql

  1. cd /usr/local/src/
  2. groupadd mysql
  3. useradd -g mysql mysql
  4. tar xzvf mysql-5.6.30.tar.gz
  5. cd mysql-5.6.30
  6. cmake .
  7. make && make install
  8. chown -R mysql:mysql /usr/local/mysql
  9. cd /usr/local/mysql/
  10. rm -rf /etc/my.cnf
  11. scripts/mysql_install_db --user=mysql
  12. cp support-files/my-default.cnf /etc/my.cnf
  13. vi /etc/profile
  14. PATH=/usr/local/mysql/bin:$PATH
  15. export PATH
  16. source /etc/profile
  17. cp support-files/mysql.server /etc/init.d/mysql
  18. chmod +x /etc/init.d/mysql
  19. chkconfig mysql on
  20. service mysql start

修改授权

  1. mysql -uroot -p
  2. use mysql
  3. select host,user,password from user;
  4. delete from user where user = '';
  5. update user set password = PASSWORD('1234qwer') where user = 'root';
  6. //update user set host = '%' where user = 'root';
  7. flush privileges;

安装git

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

安装php的yaf、redis扩展

  1. cd /usr/local/src
  2. wget https://pecl.php.net/get/yaf-3.0.4.tgz
  3. tar -zxvf yaf-3.0.4.tgz
  4. cd yaf-3.0.4
  5. /usr/local/php/bin/phpize
  6. ./configure --with-php-config=/usr/local/php/bin/php-config
  7. make && make install
  8. cd /usr/local/src
  9. wget https://codeload.github.com/phpredis/phpredis/zip/php7
  10. unzip phpredis-php7.zip
  11. cd phpredis-php7
  12. /usr/local/php/bin/phpize
  13. ./configure --with-php-config=/usr/local/php/bin/php-config
  14. make && make install
  15. vim /usr/local/php/lib/php.ini
  16. extension=/usr/local/php/lib/php/extensions/no-debug-non-zts-20151012/yaf.so
  17. extension=/usr/local/php/lib/php/extensions/no-debug-non-zts-20151012/redis.so
  18. extension=/usr/local/php/lib/php/extensions/no-debug-non-zts-20160303/yaf.so
  19. extension=/usr/local/php/lib/php/extensions/no-debug-non-zts-20160303/redis.so

安装redis

  1. cd /usr/local/src/
  2. //wget http://download.redis.io/releases/redis-3.2.80.tar.gz
  3. wget http://download.redis.io/redis-stable.tar.gz
  4. //tar xzf redis-3.2.8.tar.gz
  5. tar xzf redis-stable.tar.gz
  6. cd redis-3.2.8
  7. cd redis-stable
  8. make
  9. cp src/redis-server /etc/init.d/redis
  10. cp redis.conf /etc/redis.conf
  11. chmod +x /etc/init.d/redis
  12. service redis /etc/redis.conf &