备注:
Ubuntu 16.04 Server 版安装过程图文详解
Ubuntu16镜像地址: 链接:https://pan.baidu.com/s/1XTVS6BdwPPmSsF-cYF6B7Q 密码:9ecm
php-7.0.9:链接:https://pan.baidu.com/s/1Sf5QA9gDZhD5JcZmXhlWvw 密码:ketc
nghttp2:链接:https://pan.baidu.com/s/10FQ_YqBWvPqiUL0aU4U9Yw 密码:f3n2
swoole-4.1.2:链接:https://pan.baidu.com/s/16qgFf54gM4jfz9Ok3_ivYQ 密码:px3c
hiredis-0.13.3:链接:https://pan.baidu.com/s/1VfopPRcQLXUA-s14htNNpA 密码:ml6l
ubuntu 16.04配置静态ip
sudo vim /etc/network/interfaces auto ens33 iface ens33 inet static address 192.168.8.100 netmask 255.255.255.0 gateway 192.168.8.2 dns-nameservers 218.2.135.1 8.8.8.8
Mac链接linux系统 直接在终端 ssh -p 22 root@101.200.86.233 root是用户名
一、下载PHP7的最新版源码
https://pan.baidu.com/s/19-fkSSuqnNoJ4-eMJH-QGQ
二、解压
tar -zxf php-7.0.9.tar.gz
三、安装相关依赖库
sudo apt-get update sudo apt-get install libxml2-dev #安装gcc sudo apt-get install build-essential sudo apt-get install openssl sudo apt-get install libssl-dev sudo apt-get install make sudo apt-get install curl sudo apt-get install libcurl4-gnutls-dev sudo apt-get install libjpeg-dev sudo apt-get install libpng-dev sudo apt-get install libmcrypt-dev sudo apt-get install libreadline6 libreadline6-dev sudo apt-get install libreadline-dev 或者一次性安装: sudo apt-get -y install build-essential openssl libssl-dev make curl libcurl4-gnutls-dev libjpeg-dev libpng-dev libmcrypt-dev libreadline6 libreadline6-dev libreadline-dev
四、编译:(编译参数2个中选择一个,第一段大部分机器即可编译,第二段参数推荐64位x86系统编译)
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --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 --disable-fileinfo --enable-maintainer-zts
./configure --prefix=/usr/local/php --enable-fpm --enable-inline-optimization --disable-debug --disable-rpath --enable-shared --enable-opcache --with-mysql --with-mysqli --with-mysql-sock --enable-pdo --with-pdo-mysql --with-gettext --enable-mbstring --with-iconv --with-mcrypt --with-mhash --with-openssl --enable-bcmath --enable-soap --with-libxml-dir --enable-pcntl --enable-shmop --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-sockets --with-curl --with-zlib --enable-zip --enable-bz2 --with-readline --without-sqlite3 --without-pdo-sqlite --with-pear --with-libdir=/lib/x86_64-linux-gnu --with-gd --with-jpeg-dir=/usr/lib --enable-gd-native-ttf --enable-xml
本系统采用第二种编译方式
如果报错请运行:
apt-get install 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
五、执行make 和 sudo make install 安装
make && sudo make install
六、配置php-fpm
cd /usr/local/php/etc sudo cp php-fpm.conf.default php-fpm.conf cd /usr/local/php/etc/php-fpm.d sudo cp www.conf.default www.conf user = www group = www 如果www用户不存在,那么先添加www用户 sudo groupadd www sudo useradd -g www www
七、验证PHP
/usr/local/php/bin/php -v
八、启动php-fpm
sudo /usr/local/php/sbin/php-fpm
九、将php加入到全局配置中
sudo vim /etc/profile 末尾加入2行 PATH=$PATH:/usr/local/php/bin export PATH 最后执行 source /etc/profile
十、安装swoole
wget https://pecl.php.net/get/swoole-4.1.2.tgz tar xzf swoole-4.1.2.tgz cd swoole-4.1.2 sudo phpize (ubuntu 没有安装phpize可执行命令:sudo apt-get install php-dev来安装phpize) ./configure --enable-coroutine --enable-openssl --enable-http2 --enable-async-redis --enable-sockets --enable-mysqlnd make && sudo make install
备注: 如果安装http2需要安装nghttp2 wget https://github.com/nghttp2/nghttp2/releases/download/v1.30.0/nghttp2-1.30.0.tar.bz2 tar -jxvf nghttp2-1.30.0.tar.bz2 cd nghttp2-1.30.0 ./configure make && sudo make install 如果安装--enable-async-redis需要安装hiredis wget https://github.com/redis/hiredis/archive/v0.13.3.tar.gz tar xzf v0.13.3.tar.gz cd hiredis-0.13.3/ make && sudo make install
配置hiredis
sudo mkdir /usr/lib/hiredis sudo cp /usr/local/lib/libhiredis.so /usr/lib/hiredis sudo mkdir /usr/include/hiredis sudo cp /usr/local/include/hiredis/hiredis.h /usr/include/hiredis sudo vim /etc/ld.so.conf 文件末尾添加 /usr/local/lib sudo ldconfig
查询php.ini的位置
php -i |grep php.ini
安装mbstring扩展
sudo apt-get install php7.0-mbstring php.ini中加入mbstring.so
安装composer
curl -sS https://getcomposer.org/installer | php mv composer.phar /usr/local/bin/composer
安装swoft
composer create-project swoft/swoft swoft cd swoft composer update