[关闭]
@gabe 2018-07-25T17:25:57.000000Z 字数 2363 阅读 1084

ubuntu16安装php7.1

未分类


安装依赖

  1. sudo apt-get install libxml2-dev libssl-dev pkg-config libbz2-dev libcurl4-openssl-dev libjpeg-dev libpng12-dev libfreetype6-dev libicu-dev build-essential libmcrypt-dev libreadline-dev libxslt1-dev libgmp3-dev -y

下载,解压

  1. wget http://cn2.php.net/distributions/php-7.1.18.tar.gz
  2. tar -xzvf php-7.1.18.tar.gz

安装

  1. $ ./configure --prefix=/usr/local/php7.1 \
  2. --with-mysql-sock --with-mysqli \
  3. --enable-fpm --enable-soap \
  4. --with-libxml-dir --with-openssl \
  5. --with-mcrypt --with-mhash \
  6. --with-pcre-regex --with-zlib \
  7. --enable-bcmath --with-iconv \
  8. --with-bz2 --enable-calendar \
  9. --with-curl --with-cdb --enable-dom \
  10. --enable-exif --enable-fileinfo \
  11. --enable-filter --with-pcre-dir \
  12. --enable-ftp --with-gd \
  13. --with-openssl-dir --with-jpeg-dir \
  14. --with-png-dir --with-zlib-dir \
  15. --with-freetype-dir \
  16. --enable-gd-native-ttf \
  17. --enable-gd-jis-conv --with-gettext \
  18. --with-gmp --with-mhash \
  19. --enable-json --enable-mbstring \
  20. --enable-mbregex \
  21. --enable-mbregex-backtrack \
  22. --with-libmbfl --with-onig \
  23. --enable-pdo --with-pdo-mysql \
  24. --with-zlib-dir --with-readline \
  25. --enable-session --enable-shmop \
  26. --enable-simplexml --enable-sockets \
  27. --enable-sysvmsg --enable-sysvsem \
  28. --enable-sysvshm --enable-wddx \
  29. --with-libxml-dir --with-xsl \
  30. --enable-zip \
  31. --enable-mysqlnd-compression-support \
  32. --with-pear --enable-intl
  33. $ make
  34. $ make install
  1. $ ln -sf /usr/local/php7.1/bin/php /usr/local/bin/php
  2. $ cp php.ini-development /usr/local/php7.1/lib/php.ini

添加php.ini,如果是生产环境则cp对应的php.ini-production

  1. $ cp php.ini-production /usr/local/php7.1/lib/php.ini
  1. $ cp /usr/local/php7.1/etc/php-fpm.conf.default /usr/local/php7.1/etc/php-fpm.conf
  2. $ cp /usr/local/php7.1/etc/php-fpm.d/www.conf.default /usr/local/php7.1/etc/php-fpm.d/www.conf
  1. [Unit]
  2. Description=PHP FastCGI process manager
  3. After=network.target
  4. [Service]
  5. Type=forking
  6. PIDFile=/usr/local/php7.1/var/run/php-fpm.pid
  7. ExecStart=/usr/local/php7.1/sbin/php-fpm
  8. ExecStop=/usr/bin/pkill -9 php-fpm
  9. ExecReload=/bin/kill -USR2 $MAINPID
  10. PrivateTmp=true
  11. [Install]
  12. WantedBy=multi-user.target

接下来就可以使用systemctl启动php-fpm了
启动sudo systemctl start php7-fpm
停止sudo systemctl stop php7-fpm
重载配置sudo systemctl daemon-reload
查看服务状态sudo systemctl status php7-fpm.service
如果修改了/etc/systemd/system/下面的文件,必须使用sudo systemctl daemon-reload重新载入配置。

安装nginx

直接使用apt-get吧,简单快速

  1. sudo apt-get install nginx

配置nginx,去掉下面几行的注释就可以

  1. location ~ \.php$ {
  2. include snippets/fastcgi-php.conf;
  3. fastcgi_pass 127.0.0.1:9000;
  4. }

隐藏index.php

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注