最新的稳定版本是1.8.0,官方网站推荐以下方法安装。(若是用ubuntu的源
,安装获得的版本是1.4.6)php
wget http://nginx.org/keys/nginx_signing.key sudo apt-key add nginx_signing.key
sudo vim /etc/apt/sources.list
在末尾加上:html
deb http://nginx.org/packages/ubuntu/ trusty nginx deb-src http://nginx.org/packages/ubuntu/ trusty nginx
而后更新源mysql
sudo apt-get update
由于以前安装过ubuntu的源的nginx1.4.6,因此用upgrade。linux
sudo apt-get upgrade nginx
参考文章How to install PHP 7…nginx
wget http://cn2.php.net/distributions/php-7.0.0.tar.bz2
sudo apt-get install libfcgi-dev libfcgi0ldbl libmcrypt-dev libssl-dev libc-client2007e libc-client2007e-dev libxml2-dev libbz2-dev libcurl4-openssl-dev libjpeg-dev libpng12-dev libfreetype6-dev libkrb5-dev libpq-dev libxml2-dev libxslt1-dev
解决configure错误:Cannot find imap library (libc-client.a). Please check your c-client installation.web
sudo ln -s /usr/lib/libc-client.a /usr/lib/x86_64-linux-gnu/libc-client.a
./configure --prefix=/opt/php-7.0.0 --with-pdo-pgsql --with-zlib-dir --with-freetype-dir --enable-mbstring --with-libxml-dir=/usr --enable-soap --enable-calendar --with-curl --with-mcrypt --with-zlib --with-gd --with-pgsql --disable-rpath --enable-inline-optimization --with-bz2 --with-zlib --enable-sockets --enable-sysvsem --enable-sysvshm --enable-pcntl --enable-mbregex --enable-exif --enable-bcmath --with-mhash --enable-zip --with-pcre-regex --with-mysqli --with-pdo-mysql --with-mysqli --with-jpeg-dir=/usr --with-png-dir=/usr --enable-gd-native-ttf --with-openssl --with-fpm-user=www-data --with-fpm-group=www-data --with-libdir=/lib/x86_64-linux-gnu --enable-ftp --with-imap --with-imap-ssl --with-kerberos --with-gettext --with-xmlrpc --with-xsl --enable-opcache --enable-fpm
makesql
sudo make install数据库
fengyh@vfyh-lab:~/tools/php-7.0.0$ sudo make install [sudo] password for fengyh: exit 0; -t /home/fengyh/tools/php-7.0.0/ext/json/php_json_scanner_defs.h --no-generation-date -bci -o /home/fengyh/tools/php-7.0.0/ext/json/json_scanner.c /home/fengyh/tools/php-7.0.0/ext/json/json_scanner.re Installing shared extensions: /opt/php-7.0.0/lib/php/extensions/no-debug-non-zts-20151012/ Installing PHP CLI binary: /opt/php-7.0.0/bin/ Installing PHP CLI man page: /opt/php-7.0.0/php/man/man1/ Installing PHP FPM binary: /opt/php-7.0.0/sbin/ Installing PHP FPM config: /opt/php-7.0.0/etc/ Installing PHP FPM man page: /opt/php-7.0.0/php/man/man8/ Installing PHP FPM status page: /opt/php-7.0.0/php/php/fpm/ Installing phpdbg binary: /opt/php-7.0.0/bin/ Installing phpdbg man page: /opt/php-7.0.0/php/man/man1/ Installing PHP CGI binary: /opt/php-7.0.0/bin/ Installing PHP CGI man page: /opt/php-7.0.0/php/man/man1/ Installing build environment: /opt/php-7.0.0/lib/php/build/ Installing header files: /opt/php-7.0.0/include/php/ Installing helper programs: /opt/php-7.0.0/bin/ program: phpize program: php-config Installing man pages: /opt/php-7.0.0/php/man/man1/ page: phpize.1 page: php-config.1 Installing PEAR environment: /opt/php-7.0.0/lib/php/ --2015-11-22 17:27:17-- https://pear.php.net/install-pear-nozlib.phar Resolving pear.php.net (pear.php.net)... 5.77.39.20 Connecting to pear.php.net (pear.php.net)|5.77.39.20|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 3579275 (3.4M) [text/plain] Saving to: ‘pear/install-pear-nozlib.phar’ 100%[=================================================>] 3,579,275 10.4KB/s in 8m 58s 2015-11-22 17:36:20 (6.50 KB/s) - ‘pear/install-pear-nozlib.phar’ saved [3579275/3579275] [PEAR] Archive_Tar - installed: 1.4.0 [PEAR] Console_Getopt - installed: 1.4.1 [PEAR] Structures_Graph- installed: 1.1.1 [PEAR] XML_Util - installed: 1.3.0 [PEAR] PEAR - installed: 1.10.1 Wrote PEAR system config file at: /opt/php-7.0.0/etc/pear.conf You may want to add: /opt/php-7.0.0/lib/php to your php.ini include_path /home/fengyh/tools/php-7.0.0/build/shtool install -c ext/phar/phar.phar /opt/php-7.0.0/bin ln -s -f phar.phar /opt/php-7.0.0/bin/phar Installing PDO headers: /opt/php-7.0.0/include/php/ext/pdo/
拷贝php.ini和php-fpm.conf到正确的目录。json
编译后,cd到源码跟目录,而后sudo cp php.ini-production /opt/php7.0.0/lib/php.ini
ubuntu
cd /opt/php-7.0.0/etc,而后sudo cp php-fpm.conf.default php-fpm.conf
cd /opt/php-7.0.0/etc/php-fpm.d,而后sudo cp www.conf.default www.conf
本地一样的系统,安装的目录是/opt/php7.0.0,打包拷贝到云端一样的目录
按照mysql官网的指南A Quick Guide to Using the MySQL APT Repository ,卸载 原来的旧版本的mysql,安装最新的5.7。 - 安装的时候配置mysql版本并apply,或者过后使用sudo dpkg-reconfigure mysql-apt-config配置
发现5.7.9还有问题
mysql.user缺字段,致使grant命令报错。 mysqldump也报错。 text字段长度不够,一样的长度在mysql5.5没有问题
因为从新安装5.6会有问题,启动不了Mysql5.6。因此从新恢复服务器快照到干净实例。
wget http://dev.mysql.com/get/mysql-apt-config_0.5.3-1_all.deb sudo dpkg -i mysql-apt-config_0.5.3-1_all.deb
sudo dpkg-reconfigure mysql-apt-config
sudo apt-get update sudo apt-get install mysql-server
发现刚安装完毕mysql服务器启动失败, 须要从新启动。
php-fpm.conf的pid
sudo vim /opt/php-7.0.0/etc/php-fpm.conf
去掉语句pid = run/php-fpm.pid
前的分号注释。
[global] ; Pid file ; Note: the default prefix is /opt/php-7.0.0/var ; Default Value: none pid = run/php-fpm.pid
www.conf中的listen端口,默认9000,能够修改
listen = 127.0.0.1:9000
写service启动php-fpm的脚本/etc/init.d/php-7.0.0-fpm
#! /bin/sh ### BEGIN INIT INFO # Provides: php-7.0.0-fpm # Required-Start: $all # Required-Stop: $all # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: starts php-7.0.0-fpm # Description: starts the PHP FastCGI Process Manager daemon ### END INIT INFO php_fpm_BIN=/opt/php-7.0.0/sbin/php-fpm php_fpm_CONF=/opt/php-7.0.0/etc/php-fpm.conf php_fpm_PID=/opt/php-7.0.0/var/run/php-fpm.pid php_opts="--fpm-config $php_fpm_CONF" wait_for_pid () { try=0 while test $try -lt 35 ; do case "$1" in 'created') if [ -f "$2" ] ; then try='' break fi ;; 'removed') if [ ! -f "$2" ] ; then try='' break fi ;; esac echo -n . try=`expr $try + 1` sleep 1 done } case "$1" in start) echo -n "Starting php-fpm " $php_fpm_BIN $php_opts if [ "$?" != 0 ] ; then echo " failed" exit 1 fi wait_for_pid created $php_fpm_PID if [ -n "$try" ] ; then echo " failed" exit 1 else echo " done" fi ;; stop) echo -n "Gracefully shutting down php-fpm " if [ ! -r $php_fpm_PID ] ; then echo "warning, no pid file found - php-fpm is not running ?" exit 1 fi kill -QUIT `cat $php_fpm_PID` wait_for_pid removed $php_fpm_PID if [ -n "$try" ] ; then echo " failed. Use force-exit" exit 1 else echo " done" echo " done" fi ;; force-quit) echo -n "Terminating php-fpm " if [ ! -r $php_fpm_PID ] ; then echo "warning, no pid file found - php-fpm is not running ?" exit 1 fi kill -TERM `cat $php_fpm_PID` wait_for_pid removed $php_fpm_PID if [ -n "$try" ] ; then echo " failed" exit 1 else echo " done" fi ;; restart) $0 stop $0 start ;; reload) echo -n "Reload service php-fpm " if [ ! -r $php_fpm_PID ] ; then echo "warning, no pid file found - php-fpm is not running ?" exit 1 fi kill -USR2 `cat $php_fpm_PID` echo " done" ;; *) echo "Usage: $0 {start|stop|force-quit|restart|reload}" exit 1 ;; esac
$ sudo chmod 755 /etc/init.d/php-7.0.0-fpm $ sudo update-rc.d php-7.0.0-fpm defaults Adding system startup for /etc/init.d/php-7.0.0-fpm ... /etc/rc0.d/K20php-7.0.0-fpm -> ../init.d/php-7.0.0-fpm /etc/rc1.d/K20php-7.0.0-fpm -> ../init.d/php-7.0.0-fpm /etc/rc6.d/K20php-7.0.0-fpm -> ../init.d/php-7.0.0-fpm /etc/rc2.d/S20php-7.0.0-fpm -> ../init.d/php-7.0.0-fpm /etc/rc3.d/S20php-7.0.0-fpm -> ../init.d/php-7.0.0-fpm /etc/rc4.d/S20php-7.0.0-fpm -> ../init.d/php-7.0.0-fpm /etc/rc5.d/S20php-7.0.0-fpm -> ../init.d/php-7.0.0-fpm $ sudo service php-7.0.0-fpm start
配置虚拟站点www.geiliedu.com: * cd /etc/nginx/conf.d
* cp default.conf www.geiliedu.com.conf
* 而后将www.geiliedu.com.conf配置成以下的样子
server { listen 80; server_name www.geiliedu.com; charset utf-8; access_log /var/log/nginx/log/www.geiliedu.com.access.log main; location / { root /home/fengyh/web/geiliedu/frontend/web; index index.php index.html index.htm; if (!-e $request_filename){ rewrite ^/(.*) /index.php last; } } error_page 404 /home/fengyh/web/geiliedu/404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /home/fengyh/web/geiliedu/50x.html; location = /50x.html { root /home/fengyh/web/geiliedu; } # proxy the PHP scripts to Apache listening on 127.0.0.1:80 # #location ~ \.php$ { # proxy_pass http://127.0.0.1; #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location ~ \.php$ { root html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /home/fengyh/web/geiliedu/frontend/web$fastcgi_script_name; include fastcgi_params; } # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # #location ~ /\.ht { # deny all; #} }
配置php.ini,指出pdo.mysql的socket位置
pdo_mysql.default_socket=/var/run/mysqld/mysqld.sock
init,选production
mysql -u root -p
,而后建立数据库geiliedu_docs
grant all privileges on geiliedu_docs.*to ‘geiliedu_docs’@’localhost’ identified by ‘…密码…’;
发现上述语句在5.7中有问题,须要在mysql.user表中添加这个字段:
alter table user add `password_expired` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N';
修改common/config/main-local.php的数据库配置
migrations
./yii migrate
- yii2模板自动的migrations
./yii migrate --migrationPath=@fengyh/mdmgr/migrations
- yii2-mdmgr的migrations
因为php5.六、php7对彻底有所增强,因此致使一些库出‘Bug’
:
stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
如下解决方法下策,添加红框内的语句。有替代方案仍是要尽可能改进: