分类 未分类 下的文章

使用mysqli_connect,在/var/log/nginx/error.log中,总是出现mysqli_connect找不到。。。按照数个解决此问题的方法,修改php.ini中下面一行去掉前面的注释分号:

extension=php_mysqli.dll

并重启nginx和php-fpm服务。

我在deepin里面有三个php.ini,位于/etc/php/7.0/下面的apache2, fpm, cli目录,全改了,还是不行。

搜索了一下,找不到和mysqli相关的文件,纳闷了,难道没有装?
看到网上还真有人说这个没在默认安装里面的。。。

用下面的命令安装:

sudo aptitude install php-mysqli

搞定!

1)python快速建立http服务器:
python -m SimpleHTTPServer

2)php也可以!一句话:

php -S localhost:8888

还可以解析php哦!(废话)

3)Node.js也可以快速建立,不过要装个包先:

npm install -g node-static

装好后运行:

static

就可以了!

linux的ftp好难得配置。。。
用python就好了:

Python版FTP服务器

Python没有内置一个直接可以用的FTP服务器,所以需要第三方组件的支持,我找到的这个组件叫pyftpdlib,首先安装:

pip install pyftpdlib

安装完后,和HTTP服器类似,执行以下命令就可以启动一个FTP服务器了:

python -m pyftpdlib -p 21

后面的21端口依然是可选的,不填会随机一个,被占用的端口将跳过。在浏览器敲入本机地址:

ftp://localhost:21

默认ftp用户名anonymous是只读权限,如果要可写,加上-w, 改为:

python -m pyftpdlib -w -p 21

更多帮助,输入:

python -m pyftpdlib -h

display:flex感觉让布局容易了很多,作为初学者,发现有个坑,就是子元素对空间的分配,实际上是对父元素剩下的空间的分配,而不是对父元素所有空间的分配。
什么是剩余空间?如果父元素1000px,子元素a中写了几个字,占了100px,剩余空间就是900px。子元素b又写几个字,占了200px,就只剩下700px了。
涉及子元素几个属性:
flex-grow,后面带个数字,数字表明对剩余空间占得比例。
其他元素待查。

无论如何,vue.js都是坑很少的了,并且大多数坑是js本身所导致的,并且cn.vuejs.org上也说明了,不过如果你没注意看这些坑边的警告,就可能掉进去半天找不到问题出口。
举例是:
new Vue({ el:'body', data: { obj: {x:1}, arr: [1,2,3,{y:2}], } })
1. data中的数据,如果是对象{},再次给它赋值会破坏数据-视图绑定。如:
this.obj = {} //破坏绑定
所以别这么做,需要增加新的属性,直接:
this.obj.newkey = 'newvalue'
删除属性可以:
delete this.obj.x

2. 如果是数组,则千万不能直接对索引值赋值,这也会破坏绑定。
this.arr[1] = 9 //破坏绑定
要这么做:
this.arr.$set(1,9)
如果要增加新的,用push或者unshift
this.arr[4] = 7 //破坏绑定
this.arr.push(7) //这样是OK的

3. 只要不是直接对数组索引值,对索引值下面的属性是可以这么做的:
this.arr[3].x = 11 //不会破坏绑定

4. 貌似与对象不同,数组可以赋值为空数组而不会破坏把绑定
this.arr = [] //没有问题

php7支持mongodb
使用sudo pecl install mongodb安装的时候报错
configure: error: Cannot find OpenSSL's libraries

找到这篇文章:
http://languor.us/mongodb-linux-pecl-configure-error-cannot-find-openssls-libraries
改良一下:
apt-get install openssl apt-get install libsasl2-dev

mkdir -p /usr/local/openssl/include/
ln -s /usr/include/openssl /usr/local/openssl/include/openssl
ln -s /usr/lib/x86_64-linux-gnu /usr/local/openssl/lib

其中“x86_64-linux-gnu”目录在我的电脑里面是“i386-linux-gnu”,你的电脑里面可能不一样,找一下libssl.a或libssl.so在的个目录就行了。

下载 https://www.adminer.org/#download
adminer是单个php文件,不需要什么配置什么的乱七八糟的东西,
放到服务器上就能用,
mysql远程连接总是不知道被什么挡下来,总是返回10061错误,那就有adminer吧!

使用watch命令

watch -c -d -n 1 tail /var/log/nginx/error.log -n 5

上面命令的意思是查看tail命令的输出,-c彩色,-d显示差异,-n 1每秒钟更新一次。

linux定时任务通过cron和at运行。

cron只能运行循环任务,如果是一次性任务,则要用at。

at语法灵活,如2分钟后运行一个脚本:

$at now + 2 minutes

>python t1.py

>ctrl+D

如果要运行一个文件的任务,使用:

at now -f filename

linux的PATH要立刻生效,需要修改:

~/.bashrc

在里面增加一条:

BATH="/路径:/路径:"$PATH

下次新打开一个终端就生效了

1. 安装

我是懒人,不习惯make/make install, 直接用aptitude安装了

$ sudo aptitude install nginx

$ sudo aptitude install php

$ sudo aptitude install php-fpm

目前是直接安装了最新版的php7、php-fpm7

2. 配置

php-fpm默认不需要配置,并且安装好后自动就启动了,可以使用

ps -aux | grep fpm

查看有没有启动。

安装的位置是:

/usr/sbin/php-fpm7.0

不过和旧版本的使用 fastcgi://127.0.0.1:9000的网络接口相比,新版本使用了Unix域套接字(Unix domain socket),是在文件系统里的文件,php-fpm的unix域套接字是:

unix:/run/php/php7.0-fpm.sock

因此配置nginx.conf的时候,要使用这个。

Unix域套接字同样可以用netstat -apn | grep fpm查看。

重要的是配置nginx.conf

我的位置是在 /etc/nginx/nginx.conf

deepin安装的nginx.conf中,包含了配置/etc/nginx/sites-enabled/default,默认的配置文件其实在这,可以配置这个default文件。

sudo vim /etc/nginx/sites-enabled/default

在default中,默认包含了nginx的配置,所做的是取消井号#,修改一下就好了。

默认default中去掉无关说明,剩下的所有配置如下,需要修改的以粗体表示:

server {
 listen 80 default_server;
 listen [::]:80 default_server;
 root /var/www/html;
# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html;
server_name _; location / { # First attempt to serve request as file, then # as directory, then fall back to displaying a 404. try_files $uri $uri/ =404; } # pass the PHP scripts to FastCGI server # listening on 127.0.0.1:9000 # #location ~ \.php$ { #include snippets/fastcgi-php.conf; # # # With php5-cgi alone: # fastcgi_pass 127.0.0.1:9000; # # With php5-fpm: #fastcgi_pass unix:/var/run/php5-fpm.sock; #} }

 

修改为:

server {
 listen 80 default_server;
 listen [::]:80 default_server;
# 这儿是你自定义的www根目录
 root /home/deepin/docs/wwwdir;
 # Add index.php to the list if you are using PHP
 index index.html index.htm index.nginx-debian.html index.php; #增加index.php

 server_name _;

 location / {
 # First attempt to serve request as file, then
 # as directory, then fall back to displaying a 404.
 try_files $uri $uri/ =404;
 }
 # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#去掉下面两行井号
location ~ \.php$ {
include snippets/fastcgi-php.conf;
# # # With php5-cgi alone: # fastcgi_pass 127.0.0.1:9000; # # With php5-fpm: # 去掉下面这行井号,并修改为正确的unix套接字,可在shell中用sudo netstat -apn|grep php查看 fastcgi_pass unix:/run/php/php7.0-fpm.sock; #} }

 

3. 启动

/etc/init.d/php7.0-fpm restart

/etc/init.d/nginx restart

4. 测试

在配置的root目录下建一个index.php

内容是:

<?php phpinfo(); ?>