@gabe
2018-07-25T17:25:57.000000Z
字数 2363
阅读 1084
未分类
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
wget http://cn2.php.net/distributions/php-7.1.18.tar.gz
tar -xzvf php-7.1.18.tar.gz
安装
$ ./configure --prefix=/usr/local/php7.1 \
--with-mysql-sock --with-mysqli \
--enable-fpm --enable-soap \
--with-libxml-dir --with-openssl \
--with-mcrypt --with-mhash \
--with-pcre-regex --with-zlib \
--enable-bcmath --with-iconv \
--with-bz2 --enable-calendar \
--with-curl --with-cdb --enable-dom \
--enable-exif --enable-fileinfo \
--enable-filter --with-pcre-dir \
--enable-ftp --with-gd \
--with-openssl-dir --with-jpeg-dir \
--with-png-dir --with-zlib-dir \
--with-freetype-dir \
--enable-gd-native-ttf \
--enable-gd-jis-conv --with-gettext \
--with-gmp --with-mhash \
--enable-json --enable-mbstring \
--enable-mbregex \
--enable-mbregex-backtrack \
--with-libmbfl --with-onig \
--enable-pdo --with-pdo-mysql \
--with-zlib-dir --with-readline \
--enable-session --enable-shmop \
--enable-simplexml --enable-sockets \
--enable-sysvmsg --enable-sysvsem \
--enable-sysvshm --enable-wddx \
--with-libxml-dir --with-xsl \
--enable-zip \
--enable-mysqlnd-compression-support \
--with-pear --enable-intl
$ make
$ make install
$ ln -sf /usr/local/php7.1/bin/php /usr/local/bin/php
$ cp php.ini-development /usr/local/php7.1/lib/php.ini
添加php.ini,如果是生产环境则cp对应的php.ini-production
$ cp php.ini-production /usr/local/php7.1/lib/php.ini
$ cp /usr/local/php7.1/etc/php-fpm.conf.default /usr/local/php7.1/etc/php-fpm.conf
$ cp /usr/local/php7.1/etc/php-fpm.d/www.conf.default /usr/local/php7.1/etc/php-fpm.d/www.conf
[Unit]
Description=PHP FastCGI process manager
After=network.target
[Service]
Type=forking
PIDFile=/usr/local/php7.1/var/run/php-fpm.pid
ExecStart=/usr/local/php7.1/sbin/php-fpm
ExecStop=/usr/bin/pkill -9 php-fpm
ExecReload=/bin/kill -USR2 $MAINPID
PrivateTmp=true
[Install]
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
重新载入配置。
直接使用apt-get吧,简单快速
sudo apt-get install nginx
配置nginx,去掉下面几行的注释就可以
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass 127.0.0.1:9000;
}
隐藏index.php