安装php7.1

安装php源

  1. rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
  2. rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

检查源是否安装成功

  1. yum repolist enabled | grep "webtatic*"

安装php扩展源

  1. yum -y install php71w php71w-fpm
  2. yum -y install php71w-mbstring php71w-common php71w-gd php71w-mcrypt
  3. yum -y install php71w-mysql php71w-xml php71w-cli php71w-devel
  4. yum -y install php71w-pecl-memcached php71w-pecl-redis php71w-opcache

验证php7.1.x和扩展是否安装成功
验证php是否安装成功

  1. php -v

验证对应的扩展是否安装成功

  1. php -m

设置php-fpm并检测php-fpm的运行状态
启动php-fpm

  1. service php-fpm start

检查启动是否成功

  1. service php-fpm status

设置开机自启动

  1. systemctl enable php-fpm.service

检查开机自启动是否设置成功

  1. systemctl list-dependencies | grep php-fpm
  2. ps -ef | grep php-fpm

nginx配置如下:

  1. server{
  2. listen 80;
  3. server_name youserver;
  4. index index.html index.php;
  5. root /home/public;
  6. #charset koi8-r;
  7. #access_log logs/host.access.log main;
  8. location / {
  9. index index.html index.htm index.php;
  10. try_files $uri $uri/ /index.php?$query_string;
  11. }
  12. error_page 404 /404.html;
  13. # redirect server error pages to the static page /50x.html
  14. #
  15. error_page 500 502 503 504 /50x.html;
  16. location = /50x.html {
  17. root html;
  18. }
  19. # proxy the PHP scripts to Apache listening on 127.0.0.1:80
  20. #
  21. #location ~ .php$ {
  22. # proxy_pass http://127.0.0.1;
  23. #}
  24. # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
  25. #
  26. location ~ .php$ {

https://segmentfault.com/a/1190000011907263