Linux中zip压缩和unzip解压缩命令详解

1、把/home目录下面的mydata目录压缩为mydata.zip
zip -r mydata.zip mydata #压缩mydata目录
2、把/home目录下面的mydata.zip解压到mydatabak目录里面
unzip mydata.zip -d mydatabak
3、把/home目录下面的abc文件夹和123.txt压缩成为abc123.zip
zip -r abc123.zip abc 123.txt
4、把/home目录下面的wwwroot.zip直接解压到/home目录里面
unzip wwwroot.zip
5、把/home目录下面的abc12.zip、abc23.zip、abc34.zip同时解压到/home目录里面
unzip abc\*.zip
6、查看把/home目录下面的wwwroot.zip里面的内容
unzip -v wwwroot.zip
7、验证/home目录下面的wwwroot.zip是否完整
unzip -t wwwroot.zip
8、把/home目录下面wwwroot.zip里面的所有文件解压到第一级目录
unzip -j wwwroot.zip

主要参数

-c:将解压缩的结果
-l:显示压缩文件内所包含的文件
-p:与-c参数类似,会将解压缩的结果显示到屏幕上,但不会执行任何的转换
-t:检查压缩文件是否正确
-u:与-f参数类似,但是除了更新现有的文件外,也会将压缩文件中的其它文件解压缩到目录中
-v:执行是时显示详细的信息
-z:仅显示压缩文件的备注文字
-a:对文本文件进行必要的字符转换
-b:不要对文本文件进行字符转换
-C:压缩文件中的文件名称区分大小写
-j:不处理压缩文件中原有的目录路径
-L:将压缩文件中的全部文件名改为小写
-M:将输出结果送到more程序处理
-n:解压缩时不要覆盖原有的文件
-o:不必先询问用户,unzip执行后覆盖原有文件
-P:使用zip的密码选项
-q:执行时不显示任何信息
-s:将文件名中的空白字符转换为底线字符
-V:保留VMS的文件版本信息
-X:解压缩时同时回存文件原来的UID/GID

通过 Composer 安装 Yii 2.0

一、在 Windows 中,你需要下载并运行 Composer-Setup.exe

二、安装composer后,更新镜像为国内镜像

C:\Users\Administrator>d:

D:\>cd wamp

D:\wamp>cd www

D:\wamp\www>composer config -g repo.packagist composer https://packagist.phpcomp
oser.com(更新镜像为国内)
You are running composer with xdebug enabled. This has a major impact on runtime
performance. See https://getcomposer.org/xdebug(提示php.ini中xdebug需关闭)

三、更新composer为最新版本

D:\wamp\www>composer self-update(更新为最新)
You are already using composer version 1.1.0 (stable channel).

四、开始安装yii

D:\wamp\www>composer global require “fxp/composer-asset-plugin:~1.1.0”
Changed current directory to C:/Users/Administrator/AppData/Roaming/Composer
./composer.json has been created
Loading composer repositories with package information
Updating dependencies (including require-dev)
– Installing fxp/composer-asset-plugin (v1.1.4)
Downloading: 100%

Writing lock file
Generating autoload files

五、创建项目

D:\wamp\www>composer create-project –prefer-dist yiisoft/yii2-app-basic basic
Installing yiisoft/yii2-app-basic (2.0.8)
– Installing yiisoft/yii2-app-basic (2.0.8)
Downloading: 100%

Created project in basic
Loading composer repositories with package information
Updating dependencies (including require-dev)
Reading bower.json of bower-asset/jquery (2.1.0)
Could not fetch https://api.github.com/repos/jquery/jquery-dist/contents/bower.j
son?ref=9434e03193c45d51bbd063a0edd1a07a6178d33f, please create a GitHub OAuth t
oken to go over the API rate limit
Head to https://github.com/settings/tokens/new?scopes=repo&description=Composer+
on+7RBSGPCTR5ZQFHB+2016-05-13+0824
to retrieve a token. It will be stored in “C:/Users/Administrator/AppData/Roamin
g/Composer/auth.json” for future use by Composer.
Token (hidden):
Token stored successfully.
– Installing yiisoft/yii2-composer (2.0.4)
Downloading: 100%

– Installing swiftmailer/swiftmailer (v5.4.2)
Downloading: 100%

– Installing bower-asset/jquery (2.2.3)
Downloading: 100%

– Installing bower-asset/yii2-pjax (v2.0.6)
Downloading: 100%

– Installing bower-asset/punycode (v1.3.2)
Downloading: 100%

– Installing bower-asset/jquery.inputmask (3.2.7)
Downloading: 100%

– Installing cebe/markdown (1.1.0)
Downloading: 100%

– Installing ezyang/htmlpurifier (v4.7.0)
Downloading: 100%

– Installing yiisoft/yii2 (2.0.8)
Downloading: 100%

– Installing yiisoft/yii2-swiftmailer (2.0.5)
Downloading: 100%

– Installing yiisoft/yii2-codeception (2.0.5)
Downloading: 100%

– Installing bower-asset/bootstrap (v3.3.5)
Downloading: 100%

– Installing yiisoft/yii2-bootstrap (2.0.6)
Downloading: 100%

– Installing yiisoft/yii2-debug (2.0.6)
Downloading: 100%

– Installing bower-asset/typeahead.js (v0.11.1)
Downloading: 100%

– Installing phpspec/php-diff (v1.1.0)
Downloading: 100%

– Installing yiisoft/yii2-gii (2.0.5)
Downloading: 100%

– Installing fzaninotto/faker (v1.6.0)
Downloading: 100%

– Installing yiisoft/yii2-faker (2.0.3)
Downloading: 100%

Writing lock file
Generating autoload files
> yii\composer\Installer::postCreateProject
chmod(‘runtime’, 0777)…done.
chmod(‘web/assets’, 0777)…done.
chmod(‘yii’, 0755)…done.

D:\wamp\www>

svn 安装,建库全过程

yum -y install subversion
941  rpm -aq subversion
942  cd /
943  ls
944  mkdir -p /application/svndata
945  mkdir -p /application/svnpasswd
946  svnserve -d -r /application/svndata
947  svnserve –help
948  ps -ef|grep svn|grep -v grep
949  netstat -lnt|grep 3690
950  lsof -i :3690
951  cd /application/
952  ls
953  cd svndata/
954  ls
955  cd ..
956  cd svnpasswd/
957  ls
958  cd ../../
959  ls
960  svnadmin create /application/svndata/ningmengdou
961  ls -ld /application/svndata/ningmengdou/
962  cd /application/
963  ls
964  cd svndata/
965  ls
966  cd ningmengdou/
967  s
968  ls
969  cd conf/
970  ls
971  cd authz
972  vi authz
973  ls
974  vi svnserve.conf
975  ls
976  cp authz passwd /application/svnpasswd/
977  chmod 700 /application/svnpasswd/
978  ls -l /application/svnpasswd/
979  chmod 700 /application/svnpasswd/
980  ls -l /application/svnpasswd/
981  cd /application/
982  ;s
983  ls
984  cd svnpasswd/
985  ls
986  ll
987  chmod 700 /application/svnpasswd/
988  ll
989  chmod 700 -R  /application/svnpasswd/
990  ll
991  ls
992  vi passwd
993  vi authz
994  pkill svnserve
995  svnserve -d -r /application/svndata/

jquery语法–(function($){…})(jQuery)是什么意思

这里实际上是匿名函数

function(arg){…}
这就定义了一个匿名函数,参数为arg

而调用函数 时,是在函数后面写上括号和实参的,由于操作符的优先级,函数本身也需要用括号,即:
(function(arg){…})(param)
这 就相当于定义了一个参数为arg的匿名函数,并且将param作为参数来调用这个匿名函数

而(function($){…}) (jQuery)则是一样的,之所以只在形参使用$,是为了不与其他库冲突,所以实参用jQuery

**************************************************************************
其实就等于
var fn = function($){….};
fn(jQuery);

其实可以这么理解,不过要注意的是fn是不存在的
那个函数直接定义,然后就运行了。就“压缩”成下面的样子了
(function($){…})(jQuery)
**************************************************************************
简单理解是(function($){…})(jQuery)用来定义一些需要预先定义好的函数
$(function(){ })则是用来在DOM加载完成之后运行\执行那些预行定义好的函数.
**************************************************************************

开发jQuery插件时总结的一些经验分享一下。
一、先看

jQuery(function(){
});
全写为
jQuery(document).ready(function(){

});

意义为在DOM加载完毕后执行了ready()方法。
二、再看

(function(){

})(jQuery);
其实际上是执行()(para)匿名方法,只不过是传递了jQuery对象。

三、总结

jQuery(function(){ });用于存放操作DOM对象的代码,执行其中代码时DOM对象已存在。不可用于存放开发插件的代码,因 为jQuery对象没有得到传递,外部通过jQuery.method也调用不了其中的方法(函数)。
(function(){ })(jQuery);用于存放开发插件的代码,执行其中代码时DOM不一定存在,所以直接自动执行DOM操作的代码 请小心使用。

通过phpize为php在不重新编译php情况下安装模块openssl

假定:
php编译安装路径:/usr/local/php/
apache编译安装路径:/usr/local/apache/
php配置文件路径:/etc/php.ini
php安装源路径:/usr/source/php-5.3.9/

[root@localhost ~]# cd /usr/source/php-5.3.9/ext/openssl/

[root@localhost openssl]# /usr/local/php/bin/phpize
Cannot find config.m4.
Make sure that you run ‘/usr/local/php/bin/phpize’ in the top level source directory of the module

[root@localhost openssl]# cp ./config0.m4 ./config.m4

[root@localhost openssl]# /usr/local/php/bin/phpize
Configuring for:
PHP Api Version:         20090626
Zend Module Api No:      20090626
Zend Extension Api No:   220090626

[root@localhost openssl]# ./configure –with-openssl –with-php-config=/usr/local/php/bin/php-config
注:如果不想使用php自带的ext里的openssl的话 可使用参数“–with-openssl=DIR” Include OpenSSL support (requires OpenSSL >= 0.9.6)

[root@localhost openssl]# make

[root@localhost openssl]# make install

在php.ini中加载openssl.so
[root@localhost openssl]# vi /etc/php.ini
加入:
extension = “openssl.so”

重启apache:
[root@localhost ~]# /usr/local/apache/bin/apachectl -k restart

检验方法1:
通过phpinfo检验是否加载了openssl模块

<?php
echo phpinfo();
?>

检验方法2:

[root@localhost openssl]# cd ~
[root@localhost ~]# vi test.php
php code:

error_reporting(E_ALL);
$a = file_get_contents(‘https://id3check.gb.co.uk/gbportalinternational/aspx/id3check_1b.asmx?WSDL’);
var_dump($a);

[root@localhost ~]# /usr/local/php/bin/php ~/test.php
返回wsdl xml文件,表示安装成功

编译安装Php5.5.19(腾讯云论坛版)

1)下载Php5.5.19
http://php.net/releases/

2)源码安装的步骤
1、解压软件源码包,并进入解压后的目录
2、./configure  预编译,也叫配置操作,源码安装的第一步,主要的作用是对即将安装的软件进行配置,比如安装路径、开启或关闭哪些功能
3、make  编译操作,生成makefile文件,正式安装时以此为依据进行安装
4、make install  正式安装


3)正式安装php
# groupadd www
# useradd -g www -s /sbin/nologin -M www
# yum install gcc bison bison-devel zlib-devel libmcrypt-devel mcrypt mhash-devel openssl-devel libxml2-devel libcurl-devel bzip2-devel readline-devel libedit-devel –y      
# tar zxvf php-5.5.19.tar.gz
# cd php-5.5.19
# ./configure –prefix=/usr/local/php –enable-inline-optimization –disable-debug –disable-rpath –enable-shared –enable-opcache –enable-fpm –with-apxs2=/usr/local/apache/bin/apxs –with-mysql=/usr/local/mysql –with-fpm-user=www –with-fpm-group=www –with-mysql=mysqlnd –with-mysqli=mysqlnd –with-pdo-mysql=mysqlnd –with-gettext –enable-mbstring –with-iconv –with-mcrypt –with-mhash –with-openssl –enable-bcmath –enable-soap –with-libxml-dir –enable-pcntl –enable-shmop –enable-sysvmsg –enable-sysvsem –enable-sysvshm –enable-sockets –with-curl –with-zlib –enable-zip –with-bz2 –with-readline
config.status: creating sapi/cgi/php-cgi.1
config.status: creating ext/phar/phar.1
config.status: creating ext/phar/phar.phar.1
config.status: creating main/php_config.h
config.status: executing default commands
————预编译成功
# make
invertedregexiterator.inc
directorygraphiterator.inc
phar.inc
Build complete.
Don’t forget to run ‘make test’

————make无报错,成功。
# make install
Wrote PEAR system config file at: /usr/local/php/etc/pear.conf
You may want to add: /usr/local/php/lib/php to your php.ini include_path
/root/php-5.5.19/build/shtool install -c ext/phar/phar.phar /usr/local/php/bin
ln -s -f /usr/local/php/bin/phar.phar /usr/local/php/bin/phar
Installing PDO headers:          /usr/local/php/include/php/ext/pdo/

————make installl无报错,安装成功。
# cp php.ini-development /usr/local/php/lib/php.ini
————默认的php.ini没有自动生成,需要手动设置
# cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
————以服务形式管理脚本。
# chmod +x /etc/init.d/php-fpm
# service php-fpm start
# /usr/local/php/bin/php -v
PHP 5.5.19 (cli) (built: Nov 30 2014 20:19:31)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies

————查看php版本
# php -v
-bash: php: command not found
# export PATH=$PATH:/usr/local/php/bin
# php -v
PHP 5.5.19 (cli) (built: Nov 30 2014 20:19:31)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies

PHP搭建成功~

10.1.0.8服务器,安装php5.5.12过程(最终完成,但中间有先前的错误步骤)

1026  scp root@10.1.0.6:/home/bruce/tools/php-5.5.12.tar.gz /home/bruce/tools/
1027  ls
1028  tar zxvf php-5.5.12.tar.gz
1029  cd php-5.5.12
1030  ls
1031  cd /usr/local/
1032  ls
1033  cd –
1034  ls
1035  ./configure –prefix=/usr/local/php –enable-inline-optimization –disable-debug –disable-rpath –enable-shared –enable-opcache –enable-fpm –with-apxs2=/usr/local/httpd/bin/apxs
–with-mysql=/usr/local/mysql –with-mysqli=/usr/local/mysql/bin/mysql_config –with-gd –enable-gd-native-ttf –with-fpm-user=www –with-fpm-group=www –with-mysql=mysqlnd –with-mysqli=mysqlnd –with-pdo-mysql=mysqlnd –with-gettext –enable-mbstring –with-iconv –with-mcrypt –with-mhash –with-openssl –enable-bcmath –enable-soap –with-libxml-dir –enable-pcntl –enable-shmop –enable-sysvmsg –enable-sysvsem –enable-sysvshm –enable-sockets –with-curl –with-zlib –enable-zip –with-bz2 –with-readline –with-jpeg-dir=/usr/lib –with-png-dir=/usr/lib
1036  make
1037  ls
1038  vi Makefile
1039  make
1040  cd /usr/local/lib
1041  ls
1042  cd /etc/
1043  ls
1044  vi ld.so.conf
1045  ldconfig
1046  sudu ldconfig
1047  ldconfig
1048  cd /home/bruce/tools/php-5.5.12
1049  make
1050  make test
1051  make
1052  make clean
1053  make
1054  make install
1055  cd /usr/local/
1056  ls
1057  cd php/
1058  ls
1059  cd bin/
1060  ls
1061  cd ..
1062  ls
1063  cd php/
1064  ls
1065  cd –
1066  cd /home/bruce/tools/
1067  ls
1068  cd php-5.5.12
1069  ls
1070  cd /usr/local/httpd
1071  ls
1072  cd build/
1073  ls
1074  ll
1075  cd cd /home/bruce/tools/php-5.5.12
1076   cd /home/bruce/tools/php-5.5.12
1077  cdls
1078  ls
1079  cd libs/
1080  ls
1081  libtool –finish
1082  cd /usr/local/
1083  ls
1084  cd php/
1085  ls
1086  vi /etc/httpd2.4.18/httpd.conf
1087  cd /etc/php
1088  cd /etc/
1089  ls
1090  cd /home/bruce/tools/php-5.5.12
1091  ls
1092  cd /usr/local/php/lib/ls
1093  cd /usr/local/php/lib/
1094  ls
1095  cd php/
1096  ls
1097  cd –
1098  cd /home/bruce/tools/php-5.5.12
1099  ls
1100  cp php.ini-production /usr/local/php/lib/php.ini
1101  ls
1102  cd /usr/local/php/
1103  ls
1104  cd etc/
1105  ls
1106  cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
1107  ls
1108  cd –
1109  cd /home/bruce/tools/php-5.5.12
1110  ls
1111  cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
1112  chmod +x /etc/init.d/php-fpm
1113  service php-fpm start
1114  netstat -lnt
1115  top
1116  /usr/local/php/bin/php -v
1117  export PATH=$PATH:/usr/local/php/bin
1118  php -v
1119  service php-fpm stop
1120  cd /usr/local/httpd
1121  ls
1122  cd htdocs/
1123  ls
1124  vi index.php
1125  cd /etc/httpd2.4.18/
1126  vi httpd.conf
1127  cd /usr/local/php/lib/
1128  ls
1129  cd php
1130  ls
1131  cd /etc/httpd2.4.18/
1132  vi httpd.conf
1133  ls
1134  ll
1135  /usr/local/httpd/bin/apachectl -t
1136  /usr/local/httpd/bin/apachectl graceful
1137  scp root@10.1.0.6:/home/bruce/tools/www333.zip /usr/local/httpd/htdocs/

Linux下PHP扩展pdo_mysql和mysqli

问题见:http://www.thinkphp.cn/topic/28755.html

解决方案如下:

1.进入PHP源码包ext/pdo目录

cd ext/pdo

2.执行/usr/local/php/bin/phpize[假设PHP的安装目录为/usr/local/php]

/usr/local/php/bin/phpize

3.配置扩展pdo

./configure –with-php-config=/usr/local/php/bin/php-config –enable-pdo=shared

4.编译安装pdo

make && make install

成功则出现

Installing shared extensions: /usr/local/php//lib/php/extensions/no-debug-non-zts-20060613/

Installing header files: /usr/local/php//include/php/

Installing PDO headers: /usr/local/php//include/php/ext/pdo/

说明在/usr/local/php//lib/php/extensions/no-debug-non-zts-20060613/目录下生成了pdo.so文件

6.在php配置文件中加上

extension=”/usr/local/php//lib/php/extensions/no-debug-non-zts-20060613/pdo.so”

7.在PHP源码包中进入pdo_mysql

cd ext/pdo_mysql

8.执行/usr/local/php/bin/phpize

9.配置pdo_mysql[假设Mysql的安装目录为/usr/local/mysql]

./configure –with-php-config=/usr/local/php/bin/php-config –with-pdo-mysql=/usr/local/mysql

10.编译pdo_mysql 安装pdo_mysql

make && make install

成功则出现

Installing shared extensions: /usr/local/php//lib/php/extensions/no-debug-non-zts-20060613/

说明的/usr/local/php//lib/php/extensions/no-debug-non-zts-20060613/目录下生成了pdo_mysql.so文件

12.在php配置文件中加上

extension=”/usr/local/php//lib/php/extensions/no-debug-non-zts-20060613/pdo_mysql.so”

重启php和(nginx或Apache)即可!

错误解决:

make: *** [pdo_mysql.lo] Error 1

这是因为这是因为在编译时需要 MySQL 的头的文件。而它按默认搜索找不到头文件的位置,所以才出现这个问题。通过软连接把MySQL头文件对应到/usr/local/include/下就好

比如你的MySQL安装文件位于/usr/local/mysql,那么就执行以下命令:

# ln -s /usr/local/mysql/include/* /usr/local/include/

安装php扩展mysqli

1: cd 到mysqli文件目录下,执行 /usr/local/php/bin/phpize
2: ./configure –with-php-config=/usr/local/php/bin/php-config –with-mysqli=/usr/local/mysql/bin/mysql_config
3: make
4: make test
5: make install
6:修改php.ini
加入或者去掉注释 extension = “mysqli.so” (如果extension_dir 不对,此处需要写全路径)
然后重启web服务器