php7连接mysql的函数mysql_connect已经被弃用了!
php7连接mysql的函数mysql_connect已经被弃用了!
大多数的php教程中还是用的mysql_connect,你会发现在php7中会报这个函数不存在。请用mysqli_connect替代。
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 QQThe complete list is 24249The complete list isThe complete list is 0The complete list is 123456 QQThe complete list is 123456The complete list is QQThe complete list is 2The complete list is params.shThe complete list is 123456The complete list is QQ |
很多时间管理致力于提高工作效率,减少打扰,番茄工作法是其中及其简便的一种。
一个番茄时段25分钟,计时开始后,排除一切干扰开始专一的一项工作。这项工作应该是简单的可以在25分钟内完成的。然后休息5分钟,继续下一个番茄时段。
这种方式蛮有效率,我想了一下可能的原因:
* 工作时段容易计算,工作+休息是半个小时,看着一个时钟就很清楚过去了多久还有多久,不需要特意的工具。
* 排除干扰,集中一项事务。人能高度集中注意力的时间不长。学校里面上课40分钟是有道理的。
* 一件简单能完成的工作。这督促人们去分解庞大的工作,不积跬步无以至千里。一步步都能完成一些工作,避免了一个庞大工作总是无法完成的挫败感。这与项目管理的WBS(Work breakdown structure)任务拆分、敏捷开发的sprint->user story->task的拆分思想都是一样的。
* 要集中注意力,就要休息好。中间一小段时间的休息更有利于集中注意力工作。
1. 找出占用的端口,如8080:
netstat -apn | grep 8080
如果还找不出来,上面的命令可能需要sudo一下。
输出列表形式是:
协议、原地址:端口、目的地地址:端口、状态、PID/程序名称
PID是其标识,可以用来杀掉它。后面的程序名称有时候比较短,可以用ps再确认一下。
2. 用进程管理再确认一下
ps -aux | grep python
输出是:
用户、PID、CPU、内存、VSZ、RSS、TTY、状态、开始时间、运行时间、命令路径名称
这里面命令路径名称要详细一些,可以用来加以确认;
3. 杀了
温柔的送个终止信号,请其自杀:
Kill -3 PID
不管了,强制杀掉:
kill -9 PID
想快速共享当前目录?忽然发现SMB失效怎么都用不起来,FTP我麻烦对方也麻烦,还是HTTP好啊。进入你要共享的目录,下面一句话搞定:
python -m SimpleHTTPServer &
当然前提是你装了Python。。。