php/Python/Node.js快速建立开发用http服务器
1)python快速建立http服务器:
python -m SimpleHTTPServer
2)php也可以!一句话:
php -S localhost:8888
还可以解析php哦!(废话)
3)Node.js也可以快速建立,不过要装个包先:
npm install -g node-static
装好后运行:
static
就可以了!
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吧!
是的,你可以写:
var 变量 = 13
function 加(甲,乙){
return 甲 + 乙
}
var 丙 = 加(变量,9)
这样的内容
技术一,form
技术二,xhr也就是XMLHttpRequest也就是ajax技术,有js原生实现法和jquery ajax大法
技术三,formdata
技术四,fetch
上述技术越往后面越新
使用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
下次新打开一个终端就生效了
php7连接mysql的函数mysql_connect已经被弃用了!
大多数的php教程中还是用的mysql_connect,你会发现在php7中会报这个函数不存在。请用mysqli_connect替代。
php -a
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(); ?>
linux中shell变量$#,$@,$0,$1,$2的含义解释: 变量说明: $$ Shell本身的PID(ProcessID) $! Shell最后运行的后台Process的PID $? 最后运行的命令的结束代码(返回值) $- 使用Set命令设定的Flag一览 $* 所有参数列表。如"$*"用「"」括起来的情况、以"$1 $2 … $n"的形式输出所有参数。 $@ 所有参数列表。如"$@"用「"」括起来的情况、以"$1" "$2" … "$n" 的形式输出所有参数。 $# 添加到Shell的参数个数 $0 Shell本身的文件名 $1~$n 添加到Shell的各参数值。$1是第1参数、$2是第2参数…。 |
示例:
1 #!/bin/bash 2 # 3 printf "The complete list is %s\n" "$$" 4 printf "The complete list is %s\n" "$!" 5 printf "The complete list is %s\n" "$?" 6 printf "The complete list is %s\n" "$*" 7 printf "The complete list is %s\n" "$@" 8 printf "The complete list is %s\n" "$#" 9 printf "The complete list is %s\n" "$0" 10 printf "The complete list is %s\n" "$1" 11 printf "The complete list is %s\n" "$2 |
结果:
[Aric@localhost ~]$ bash params .sh 123456 QQ The complete list is 24249 The complete list is The complete list is 0 The complete list is 123456 QQ The complete list is 123456 The complete list is QQ The complete list is 2 The complete list is params .sh The complete list is 123456 The complete list is QQ |