我爱编程首页投稿(暂停使用,暂停投稿)

Bash On Ubuntu:PHP 多版本共存 + Nginx

2017-08-16  本文已影响0人  过往云技

启动 Bash:

方法一:win + R:bash 回车

方法二:win + R:cmd 回车

bash 回车

添加用户、用户组

groupadd www

useradd -s /sbin/nologin -M www www

groupadd nginx

useradd -s /sbin/nologin -M nginx nginx

安装普通依赖

apt install build-essentials

安装 PHP:

方法一:编译源码

PHP7.1.8:http://us1.php.net/distributions/php-7.1.8.tar.gz

tar -zxf php-7.1.8.tar.gz

cd php-7.1.8

ll

./confgure --help #查看编译可选参数

./confgure --prefix=(安装目录,可选)/mnt/g/BashOnUbuntu/php/php-7.1.8 --with-config-file-path=(配置文件存放路径,可选)/mnt/g/BashOnUbuntu/php/php-7.1.8/etc/ --with-curl --with-freetype-dir --with-gd --with-gettext --with-iconv-dir --with-kerberos --with-libdir=lib64 --with-libxml-dir --with-mysqli --with-openssl=(可选)/usr/local/ssl/ --with-pcre-regex --with-pdo-mysql --with-pdo-sqlite --with-pear --with-png-dir --with-jpeg-dir --with-xmlrpc --with-xsl --with-zlib --with-bz2 --with-mhash --enable-fpm --enable-bcmath --enable-libxml --enable-inline-optimization --enable-mbregex --enable-mbstring --enable-opcache --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvsem --enable-sysvshm --enable-xml --enable-zip 

如果出现:error: Cannot find OpenSSL's libraries

    执行:apt build-essential libexpat1-dev libgeoip-dev libpng-dev libpcre3-dev libssl-dev libxml2-dev rcs zlib1g-dev libmcrypt-dev libcurl4-openssl-dev libjpeg-dev libpng-dev libwebp-dev pkg-config

原链接

出现:error: Please reinstall the BZip2 distribution

    执行:apt install libbz2-dev libfreetype6-dev libxslt1-dev

坑:Openssl、gd

make && make install

ln -s php-7.1.8-path/bin/php /usr/sbin/php-7.1.8 #创建软链接

ln -s php-7.1.8-path/sbin/php-fpm /usr/sbin/php-fpm-7.1.8 #创建软链接

php7.2.b2:wget https://downloads.php.net/~pollita/php-7.2.0beta2.tar.gz

tar -zxf php-7.2.0beta2.tar.gz

cd php-7.2.0beta2

./confgure --prefix=(安装目录,可选)/mnt/g/BashOnUbuntu/php/php-7.2.b2 --with-config-file-path=(配置文件存放路径,可选)/mnt/g/BashOnUbuntu/php/php-7.2.b2/etc/ --with-curl --with-freetype-dir --with-gd --with-gettext --with-iconv-dir --with-kerberos --with-libdir=lib64 --with-libxml-dir --with-mysqli --with-openssl=(可选)/usr/local/ssl/ --with-pcre-regex --with-pdo-mysql --with-pdo-sqlite --with-pear --with-png-dir --with-jpeg-dir --with-xmlrpc --with-xsl --with-zlib --with-bz2 --with-mhash --enable-fpm --enable-bcmath --enable-libxml --enable-inline-optimization --enable-mbregex --enable-mbstring --enable-opcache --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvsem --enable-sysvshm --enable-xml --enable-zip

make && make install

ln -s php-7.2.b2-path/bin/php /usr/sbin/php-7.2.b2 #创建软链接

ln -s php-7.2.b2-path/sbin/php-fpm /usr/sbin/php-fpm-7.2.b2 #创建软链接

PHP 多版本共存,只需修改默认的监听端口:

vim php-path/etc/php-fpm.d/www.conf

方法二:添加 php 源进行安装

add-apt-repository ppa:ondrej/php

apt update

apt-cache search php7

apt install php-version …………

安装 Nginx:

wget http://nginx.org/download/nginx-1.13.4.tar.gz

pcre 下载地址:ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/

zlib 下载:wget http://zlib.net/zlib-1.2.11.tar.gz

tar -zxf nginx-version

cd nginx-path

./configure --prefix=/usr/local/nginx/nginx-1-13 --user=nginx --group=nginx --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_flv_module --with-http_mp4_module --with-http_gzip_static_module --with-pcre=/opt/down/pcre-8.41 --with-zlib=/opt/down/zlib-1.2.11 --with-openssl=/opt/down/openssl-1.0.2l/ --with-debug --with-ipv6

make && make install

ln -s nginx-path/sbin/nginx /usr/sbin/nginx-1-13

nginx-1-13 -t #检查配置

nginx-1-13

启动 Nginx + php-fpm

php-fpm-7.1.8


php-fpm-7.2.b2

编辑 hosts:vim /etc/hosts

       127.0.0.1 域名

nginx-1-13 回车

安装 Mysql 8.0:

Ubuntu 安装:https://dev.mysql.com/downloads/repo/apt/

wget https://repo.mysql.com//mysql-apt-config_0.8.7-1_all.deb

dpkg -i mysql-apt-config_0.8.7-1_all.deb

apt update

apt install mysql-server

service mysql start|stop|status

mysql -u 用户名 -p

上一篇下一篇

猜你喜欢

热点阅读