laravel5、php7、mongodb学习

使用laravel-mongodb

mongodb php driver

php7需要mongodb1.1x

PHP Driver PHP 5.3 PHP 5.4 PHP 5.5 PHP 5.6 PHP 7.0 HHVM 3.9
mongodb-1.1  
mongodb-1.0    
mongo-1.6    
mongo-1.5    

下载mongodb之后使用phpize安装

phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make
make install
#php.ini加
extension =mongodb.so
php composer.phar require jenssegers/mongodb  

提示错误,php扩展mbstring错误,用phpize编译安装mbstring

Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - danielstjules/stringy 1.10.0 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
    - danielstjules/stringy 1.10.0 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
    - danielstjules/stringy 1.10.0 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
    - Installation request for danielstjules/stringy == 1.10.0.0 -> satisfiable by danielstjules/stringy[1.10.0].


Installation failed, reverting ./composer.json to its original content.

npm install kerberos error

In file included from ../lib/kerberos.cc:1:0:
../lib/kerberos.h:5:27: fatal error: gssapi/gssapi.h: 没有那个文件或目录
compilation terminated.
kerberos.target.mk:88: recipe for target 'Release/obj.target/kerberos/lib/kerberos.o' failed
make: *** [Release/obj.target/kerberos/lib/kerberos.o] Error 1
make: Leaving directory '/home/liuman/paipaijian/node_modules/connect-mongo/node_modules/mongodb/node_modules/kerberos/build'

安装libkrb

 sudo apt-get install libkrb5-dev

Laravel错误

5.1在php7环境上运行出现的错误

Fatal error: Uncaught ReflectionException: Class log does not exist in /home/liuman/jlcloud2/vendor/laravel/framework/src/Illuminate/Container/Container.php:736 Stack trace: #0 /home/liuman/jlcloud2/vendor/laravel/framework/src/Illuminate/Container/Container.php(736): ReflectionClass->__construct(‘log’) #1 /home/liuman/jlcloud2/vendor/laravel/framework/src/Illuminate/Container/Container.php(626): Illuminate\Container\Container->build(‘log’, Array) #2 /home/liuman/jlcloud2/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(674): Illuminate\Container\Container->make(‘log’, Array) #3 /home/liuman/jlcloud2/vendor/laravel/framework/src/Illuminate/Container/Container.php(837): Illuminate\Foundation\Application->make(‘log’) #4 /home/liuman/jlcloud2/vendor/laravel/framework/src/Illuminate/Container/Container.php(800): Illuminate\Container\Container->resolveClass(Object(ReflectionParameter)) #5 /home/liuman/jlcloud2/vendor/laravel/framework/src/Illuminate/Container/Container.php(769): Illuminate\Container\Container in /home/liuman/jlcloud2/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 736

解决方案:

删除vendor文件夹和composer.lock

composer install

laravel 500错误是storage没有权限

解决方案:chmod -R 777 storage

cache错误

file_put_contents(/..cache/services.json): failed to open stream: Permission denied

解决方案:sudo php artisan cache:clear

php composer.phar install报错

先安装composer,然后运行php composer.phar install –no-scripts

PDO错误,已安装PDO还提示

[PDOException]
SQLSTATE[HY000] [2002] No such file or directory

解决方案:将.env下的DB_HOST=localhost改为DB_HOST=127.0.0.1

SQLSTATE[HY000] [1045]

解决方案:
php artisan cache:clear
php artisan config:clear

php artisan 没反应

composer dumpautoload

The only supported ciphers are AES-128-CBC and AES-256-CBC with the correct key lengths.

php artisan key:generate

[Dotenv\Exception\InvalidFileException]
Dotenv values containing spaces must be surrounded by quotes.

.env文件中文或者空格必须加引号

OpenSSL extension is required

打开php.ini启用php_openssl

Key path “file://storage\oauth-public.key” does not exist or is not readable

php artisan passport:install

[Composer\Downloader\TransportException] The “https://packagist.phpcomposer.com/p/provider-2017-07%24c3e8d929d5d06fa b76cef9c5b5e4305dbe89c1599b79e63eee70490a6b8df914.json” file could not be d ownloaded (HTTP/1.1 404 Not Found)

composer diagnose

[ErrorException] proc_open(): fork failed – Cannot allocate memory

/bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=1024

/sbin/mkswap /var/swap.1

/sbin/swapon /var/swap.1

LogicException Key path “file:///storage/oauth-public.key” does not exist or is not readable

chown www-data:www-data storage/oauth-*.key

chmod 600 storage/oauth-*.key

[Illuminate\Database\QueryException] SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes (SQL: alter table users add unique users_email_unique(email))

AppServiceProvider.php

use Illuminate\Support\Facades\Schema;

public function boot()
{
    Schema::defaultStringLength(191);
}

Illuminate\Database\QueryException : SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client

C:\ProgramData\MySQL\MySQL Server 8.0\my.ini里default_authentication_plugin=caching_sha2_password改default_authentication_plugin=mysql_native_password

exception:”InvalidArgumentException”
file:”C:\web\jinguan\vendor\laravel\framework\src\Illuminate\Http\JsonResponse.php”
line:75
message:”Malformed UTF-8 characters, possibly incorrectly encoded”

Event::fire错误是redis没开

Class session does not exist

chmod -R 777 bootstrap/cache

Unable to guess the mime type as no guessers are available (Did you enable the php_fileinfo extension?)

php.ini打开扩展

extension=fileinfo

vim基本命令

鼠标停留在命令上可以看到解释,解释摘自于vim帮助文档

#先将vi的兼容模式改为vim的方式
cp /usr/local/vim/share/vim/vim74/vimrc_example.vim /usr/local/vim/share/vim/vim74/vimrc

文件名 :f
文件路径 :pwd
放弃修改并退出:q!
写入:w
写入并退出:wq
上下左右:kjhl
插入:i
添加:a
删除:x
删除:d/c
删除一行:dd
删除个单词:daw
拷贝:y
拷贝一行:yy
粘贴到光标后:p
粘贴到光标前:P
合并两行:J
撤销:u
撤销行:U
重做:Ctrl+R
下插一行:o
上插一行:O
指定计数:数字+命令
重新装载原来的文件:e!
交换字符:xp
向后移动一个到词首:w
向前移动一个到词尾:ge
向前移动当前词词首:b
向后移动当前词词尾:e
行尾:$
行首:^
文件首:gg
文件尾:G
删除全部:ggdG
全选:ggvG
增加缩进:>
减少缩进:<
下移半屏:Ctrl+D
上移半屏:Ctrl+U
上滚一行:Ctrl+E
下滚一行:Ctrl+Y
下滚一页:Ctrl+F
上滚一页:Ctrl+B
查找文件:/
查找时忽略大小写:set ignorecase
查找时恢复大小写:set noignorecase
向下查找单词:*/n
向上查找单词:#
精确查找:/\<内容\>
关闭查找高亮:set nohlsearch
开启查找高亮:set nohlsearch
开启查找时边输便找:set incsearch
关闭查找时边输便找:set nowrapscan
标记:ma,mb,mc
查看所有标记:marks
重复命令:.
可视模式:v
替换大小写:~
设置文件编码 :set encoding=utf-8

vim的帮助文档写的很好,使用:help,Vim 的作者在帮助系统方面使用了一个很聪明的方案 (也许可以说是很懒惰的方案):他们用一个普通的编辑
窗口来显示帮助。你可以在帮助窗口中使用任何普通的 Vim 命令移动光标。所以,h,j,k 和 l 还是表示左,下,上和右。
要退出帮助窗口,用退出一个普通窗口的命令:”ZZ”。这只会退出帮助窗口,而不会退出 Vim。
当你阅读帮助的时候,你会发现有一些文字被一对竖线括起来了(例如 |help|)。这表示一个超级链接。如果你把光标移到这两个竖线之间并按 CTRL+](标签跳转命令),帮助系统会把你引向这个超级链接指向的主题。(Vim对超级链接的术语是 “标签”(tag),所以CTRL+]实际是跳转到光标所在单词为名的标签所在的位置。)
跳转几次以后,你可能想回到原来的地方。CTRL+t(标签退栈)把你送回前一个跳转点。CTRL+o(跳转到前一个位置)也能完成相同的功能。

linux下安装FileZilla

filezilla客户端安装

filezilla客户端下载

将文件夹放到/usr/local/下,或者其他位置也可。

默认启动在 FileZilla3/bin/filezilla

快捷方式创建:

在桌面创建一个文档,更名filezilla.desktop

内容

[Desktop Entry]
Name = FileZilla
Type = Application
Exec = /usr/local/FileZilla3/bin/filezilla

保存之后右键文件-属性-权限-允许作为程序执行文件

ubuntu系统filezilla桌面快捷方式

linux学习三(ubuntu系统)

ubuntu下使用root登陆

设置root

sudo passwd root

输入设置密码

vi /etc/lightdm/lightdm.conf
[SeatDefaults]
greeter-session=unity-greeter
user-session=ubuntu
greeter-show-manual-login=true #手工输入登陆系统的用户名和密码
allow-guest=false #不允许guest登录

用root权限打开窗口

sudo nautilus

创建桌面快捷方式

以woekbench为例,默认启动命令mysql-workbench

在桌面创建一个文档,更名workbench.desktop

内容

[Desktop Entry]
Name = Workbench
Type = Application
Exec = mysql-workbench

保存之后右键文件-属性-权限-允许作为程序执行文件

ubuntu系统workbench桌面快捷方式

linux系统mysql

grant 权限1,权限2,…权限n on 数据库名称.表名称 to 用户名@用户地址 identified by ‘密码’;

权限:select,insert,update,delete,create,drop,index,alter,grant,references,reload,shutdown,process,file

所有权限:all privileges或者all

所有数据库所有表:*.*

所有地址:’%’

grant all privileges on *.* to root@'%' identified by 'password'

linux学习二(apache)

源码编译安装

apache安装

官网下载apache

apache文件目录下编译

./configure --prefix=/usr/local/apache --enable-mods-shared=all

动态加载所有模块:–enable-mods-shared=all
-shared动态加载,去掉则静态加载,推荐–enable-mods-shared=all简单方便,只不过据说动态加载性能要比静态慢5%。

关于加载模块详情推荐一篇博文apache 静态编译和动态编译参考

提示:APR not found. Please read the documentation

apr和apr-util下载 pcre下载

apr编译安装

./configure --prefix=/usr/local/apr
make
make install

apr-util编译安装

./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
make
make install

pcre编译安装

./configure --prefix=/usr/local/pcre
make
make install

编译apache

./configure --prefix=/usr/local/apache --enable-mods-shared=all

提示:APR-util not found. Please read the documentation

添加apr和apr-util以及pcre参数路径

./configure --prefix=/usr/local/apache --enable-mods-shared=all --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-pcre=/usr/local/pcre

apache 启动/停止/重启:apache目录下./httpd -k start/stop/restart
或者:sudo /usr/local/apache/bin/httpd -k start/stop/restart
非root用户启动需要给httpd权限:sudo chmod u+s httpd

php安装

xml2-config下载

python-dev安装

sudo apt-get update
sudo apt-get install python-dev

xml2-config编译安装

./configure --prefix=/usr/local/xml2-config
make
make install

php编译安装

./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-libxml-dir=/usr/local/xml2-config
make
make install

配置apache支持php

sudo vi /usr/local/apache/conf/httpd.conf
#查找字符串AddType,并增加
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
#查找字符串
DirectoryIndex
#并修改为
DirectoryIndex index.html index.php default.php

配置php

#查看ini目录
./php --ini
sudo cp /home/liuman/下载/php-7.0.4/php.ini-development  /usr/local/php/lib/php.ini

php编译扩展

phpize

m4下载 autoconf下载

先编译安装m4然后编译安装autoconf

./configure
make
make install

开启openssl

sudo apt-get install libssl-dev
#进入到目录etc/openssl
phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make
make install

php.ini加extension =openssl.so

yum安装

apache安装

yum install httpd -y

apache自启动

chkconfig httpd on

apache服务操作

service httpd start
service httpd stop
service httpd restart

安装php和mysql

yum install php
yum install mariadb

php版本如果太旧,先删除自带的php版本再安装,如果版本够用则直接安装php组件。

yum remove php*

安装第三方源和新版本php

rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm 
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.1-1.el5.rf.x86_64.rpm  
rpm -ivh rpmforge-release-0.5.1-1.el5.rf.x86_64.rpm
yum install php56w

安装php组件

yum install php-mysql php-gd libjpeg* php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-bcmath php-mhash

重启apache