ubuntu下php7+nginx+swoole+yaf

前端之家收集整理的这篇文章主要介绍了ubuntu下php7+nginx+swoole+yaf前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

环境

  1. ubuntu: 14.04
  2. PHP: 7.0.10
  3. Nginx: 1.10.1
  4. swoole:1.8.9
  5. MysqL: 5.7.13
  6. redis: 3.2.1
  7. yaf: 3.0.2

编译环境

  1. 更新ubuntu:
  2. apt-get update
  3. apt-get upgrade
  4. 编译PHP所需编译工具以及依赖包:
  5. sudo apt-get install build-essential gcc g++ autoconf libiconv-hook-dev libmcrypt-dev libxml2-dev libMysqLclient-dev libcurl4-openssl-dev libjpeg8-dev libpng12-dev libfreetype6-dev libXpm-dev libpcre3 libpcre3-dev

安装PHP 7.0.10

  1. 1. wget http://cn2.PHP.net/distributions/PHP-7.0.10.tar.gz
  2. 2. tar -zxvf PHP-7.0.10.tar.gz
  3. 4. cd PHP-7.0.10
  4. 5. ./configure --prefix=/usr/local/PHP \
  5. --with-config-file-path=/etc/PHP \
  6. --enable-fpm \
  7. --enable-pcntl \
  8. --enable-MysqLnd \
  9. --enable-opcache \
  10. --enable-sockets \
  11. --enable-sysvmsg \
  12. --enable-sysvsem \
  13. --enable-sysvshm \
  14. --enable-shmop \
  15. --enable-zip \
  16. --enable-soap \
  17. --enable-xml \
  18. --enable-mbstring \
  19. --disable-rpath \
  20. --disable-debug \
  21. --disable-fileinfo \
  22. --with-MysqLi=MysqLnd \
  23. --with-pdo-MysqL=MysqLnd \
  24. --with-pcre-regex \
  25. --with-iconv \
  26. --with-zlib \
  27. --with-mcrypt \
  28. --with-gd \
  29. --enable-gd-native-ttf \
  30. --with-png \
  31. --with-zlib-dir \
  32. --with-ttf \
  33. --with-jpeg-dir \
  34. --with-freetype-dir \
  35. --with-xpm-dir \
  36. --with-openssl \
  37. --with-mhash \
  38. --with-xmlrpc \
  39. --with-curl \
  40. --with-imap-ssl
  41. 6. sudo make
  42. 7. sudo make install
  43. 8. sudo mkdir /etc/PHP
  44. 9. sudo cp PHP.ini-development /etc/PHP/PHP.ini
  45. 10. vim ~/.bashrc 在末尾加上两行
  46. export PATH=/usr/local/PHP/bin:$PATH
  47. export PATH=/usr/local/PHP/sbin:$PATH
  48. 保存后执行
  49. source ~/.bashrc
  50. 10. PHP -v 即可看到版本
  1. mac:
  2. ./configure --prefix=/usr/local/PHP --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 --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 --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext=/usr/local/opt/gettext/ --disable-fileinfo --enable-maintainer-zts

安装 swoole1.8.9

  1. 1. wget https://github.com/swoole/swoole-src/archive/1.8.9-stable.tar.gz
  2. 2. tar -zxvf 1.8.9-stable.tar.gz
  3. 3. cd swoole-src-1.8.9-stable/
  4. 4. PHPize
  5. 5. ./configure --with-PHP-config=/usr/local/PHP/bin/PHP-config
  6. ./configure --with-PHP-config=/usr/local/PHP/bin/PHP-config --enable-swoole-debug --enable-sockets --enable-http2 --enable-async-redis --enable-jemalloc --enable-openssl --with-openssl=/usr/local/openssl
  7. ./configure --with-PHP-config=/usr/local/PHP/bin/PHP-config --enable-sockets --enable-http2 --enable-async-redis --enable-jemalloc --enable-openssl --with-openssl=/usr/local/openssl
  8. 6. sudo make && make install
  9. 5. sudo vim /etc/PHP/PHP.ini 最后添加
  10. extension=swoole.so
  11.  
  12. PHP.ini开启 proc_open
  13. 配置PHP.ini
  14.  
  15. 编译安装成功后,修改PHP.ini加入
  16.  
  17. extension=swoole.so
  18.  
  19. 通过PHP -mPHPinfo()来查看是否成功加载了swoole,如果没有可能是PHP.ini的路径不对,可以使用PHP -i |grep PHP.ini来定位到PHP.ini绝对路径

安装 Nginx 1.10.1

  1. 1. wget http://Nginx.org/download/Nginx-1.10.1.tar.gz
  2. 2. tar -zxvf Nginx-1.10.1.tar.gz
  3. 3. cd Nginx-1.10.1/
  4. 4 . /configure make && make install
  5. 5. cp /usr/local/Nginx/sbin/Nginx /usr/local/bin/Nginx
  6. 2. vim /etc/Nginx/sites-enabled/default
  7. index index.html index.htm index.PHP;
  8. location ~ \.PHP$ {
  9. try_files $uri =404;
  10. fastcgi_param SCRIPT_FILENAME /path$fastcgi_script_name;
  11. fastcgi_pass 127.0.0.1:9000;
  12. fastcgi_index index.PHP;
  13. include fastcgi_params;
  14. }
  15. 3. sudo Nginx 启动
  16. sudo Nginx -s reload

配置PHP-fpm

  1. 1. cd /usr/local/PHP/etc/
  2. sudo cp PHP-fpm.conf.default PHP-fpm.conf
  3. 2. cd /usr/local/PHP/etc/PHP-fpm.d/
  4. sudo mv www.conf.default www.conf
  5. 3. cd /usr/local/PHP/var/log/
  6. sudo chmod -R 777 PHP-fpm.log
  7.  
  8. sudo /usr/local/PHP/sbin/PHP-fmp 启动PHP-fpm

安装MysqL 5.7.13

  1. 1. wget http://dev.MysqL.com/get/MysqL-apt-config_0.6.0-1_all.debsudo
  2. 2. dpkg -i MysqL-apt-config_0.6.0-1_all.deb
  3. 3. sudo apt-get update
  4. 4. sudo apt-get install MysqL-server-5.7

安装 Redis 3.2.1

  1. 1. wget http://download.redis.io/releases/redis-3.2.1.tar.gz
  2. 2. tar xzf redis-3.2.1.tar.gz
  3. 3. cd redis-3.2.1
  4. 4. make
  5. 5. make install

PHP7 安装redis扩展

  1. 1. wget -c https://github.com/PHPredis/PHPredis/archive/PHP7.zip
  2. 2. unzip PHP7.zip
  3. 3. cd PHPredis-PHP7
  4. 4. /usr/local/PHP/bin/PHPize
  5. 5. ./configure --with-PHP-config=/usr/local/PHP7/bin/PHP-config
  6. 6. make
  7. 7. make install
  8. 8. sudo vim /usr/local/PHP7/etc/PHP.ini
  9. 中加入extension=redis.so并重启PHP-fpm

yaf 安装

  1. 1. wget http://pecl.PHP.net/get/yaf-3.0.2.tgz
  2. 2. tar -zxvf yaf-3.0.2.tgz
  3. 3. cd yaf-3.0.2/
  4. 4. /usr/local/PHP/bin/PHPize
  5. 5. ./configure --with-PHP-config=/usr/local/PHP/bin/PHP-config
  6. 6. make
  7. 7. make test
  8. 8. sudo make install
  9. 9. sudo vim /usr/local/PHP7/etc/PHP.ini
  10. 中加入extension=yaf.so并重启PHP-fpm

猜你在找的Ubuntu相关文章