From 9bb29e7ee16cd92f085e65f1b431077d84f0a607 Mon Sep 17 00:00:00 2001 From: WANG-YongTao Date: Fri, 13 May 2016 16:45:36 +0800 Subject: [PATCH] ADD --- ...23\347\263\273\347\273\223\346\236\204.md" | 51 ++++ ...72\347\241\200\347\237\245\350\257\206.md" | 13 + .../PHP7_\345\256\211\350\243\205.md" | 208 +++++++++++++ chapter1_basic/README.md | 2 + ...nx\346\234\215\345\212\241\345\231\250.md" | 93 ++++++ ...00\345\217\221\347\216\257\345\242\203.md" | 279 ++++++++++++++++++ ...31\350\241\250\350\276\276\345\274\217.md" | 0 ...16\346\225\260\346\215\256\345\272\223.md" | 18 ++ ...HP\345\255\227\347\254\246\344\270\262.md" | 19 ++ "chapter2_php/PHP\346\225\260\347\273\204.md" | 19 ++ ...07\344\273\266\347\256\241\347\220\206.md" | 20 ++ "chapter2_php/PHP\347\256\200\344\273\213.md" | 19 ++ chapter2_php/README.md | 93 ++++++ chapter3_js_html/README.md | 24 ++ chapter4_database/README.md | 29 ++ ...77\347\224\250\346\225\231\347\250\213.md" | 184 ++++++++++++ chapter5_linux/README.md | 16 + ...43\347\240\201\351\243\216\346\240\274.md" | 0 ...61\347\240\201\351\227\256\351\242\230.md" | 73 +++++ chapter6_practice/README.md | 5 + ...64\345\212\240\345\256\211\345\205\250.md" | 67 +++++ 21 files changed, 1232 insertions(+) create mode 100644 "PHP-\347\237\245\350\257\206\344\275\223\347\263\273\347\273\223\346\236\204.md" create mode 100644 "chapter1_basic/HTTP\345\237\272\347\241\200\347\237\245\350\257\206.md" create mode 100644 "chapter1_basic/PHP7_\345\256\211\350\243\205.md" create mode 100644 chapter1_basic/README.md create mode 100644 "chapter1_basic/\345\256\211\350\243\205Nginx\346\234\215\345\212\241\345\231\250.md" create mode 100644 "chapter1_basic/\345\256\211\350\243\205PHP\345\274\200\345\217\221\347\216\257\345\242\203.md" create mode 100644 "chapter1_basic/\346\255\243\345\210\231\350\241\250\350\276\276\345\274\217.md" create mode 100644 "chapter2_php/PHP\344\270\216\346\225\260\346\215\256\345\272\223.md" create mode 100644 "chapter2_php/PHP\345\255\227\347\254\246\344\270\262.md" create mode 100644 "chapter2_php/PHP\346\225\260\347\273\204.md" create mode 100644 "chapter2_php/PHP\346\226\207\344\273\266\347\256\241\347\220\206.md" create mode 100644 "chapter2_php/PHP\347\256\200\344\273\213.md" create mode 100644 chapter2_php/README.md create mode 100644 chapter3_js_html/README.md create mode 100644 chapter4_database/README.md create mode 100644 "chapter5_linux/Git\344\275\277\347\224\250\346\225\231\347\250\213.md" create mode 100644 chapter5_linux/README.md create mode 100644 "chapter6_practice/PHP\344\273\243\347\240\201\351\243\216\346\240\274.md" create mode 100644 "chapter6_practice/PHP\345\274\200\345\217\221\344\270\255\347\274\226\347\240\201\344\271\261\347\240\201\351\227\256\351\242\230.md" create mode 100644 chapter6_practice/README.md create mode 100644 "chapter6_practice/\345\246\202\344\275\225\350\256\251PHP\347\250\213\345\272\217\346\233\264\345\212\240\345\256\211\345\205\250.md" diff --git "a/PHP-\347\237\245\350\257\206\344\275\223\347\263\273\347\273\223\346\236\204.md" "b/PHP-\347\237\245\350\257\206\344\275\223\347\263\273\347\273\223\346\236\204.md" new file mode 100644 index 0000000..02c76db --- /dev/null +++ "b/PHP-\347\237\245\350\257\206\344\275\223\347\263\273\347\273\223\346\236\204.md" @@ -0,0 +1,51 @@ + +1. 服务器与部署 +2. PHP基础知识 +3. JavaScript与HTML基础知识 +4. 数据库基础知识 +5. Linux基础知识 +6. 编程实践 + + + +# 计算机基础 + +网站系统的结构: +操作系统: Linux +后端: PHP/Python/Ruby/Java +前端: JavaScript、HTML、CSS + iOS(OC、Swift), Android(Java), HTML5 +数据库: MySQL、Redis、MongoDB + + +# PHP基础知识 + +### 字符串与编码 + +### 正则表达式 + +### PHP数组 + +### PHP文件系统 + +### PHP安全 + + + +# Linux基础知识 + + +# 深入JavaScript与HTML/CSS + + +# 综合项目实战、大规模网站开发技术 + + +# 其他知识: + +NodeJS + +Docker + +Vagrant + + diff --git "a/chapter1_basic/HTTP\345\237\272\347\241\200\347\237\245\350\257\206.md" "b/chapter1_basic/HTTP\345\237\272\347\241\200\347\237\245\350\257\206.md" new file mode 100644 index 0000000..adf4bf0 --- /dev/null +++ "b/chapter1_basic/HTTP\345\237\272\347\241\200\347\237\245\350\257\206.md" @@ -0,0 +1,13 @@ +# 深入HTTP协议 + +HTTP协议和W3C组织 + +用开发者工具分析HTTP数据包 + +HTTP请求行、消息头、实体内容 + +HTTP响应状态行、消息头和实体内容 + +HTTP响应状态码详解 + +HTTP协议的应用和实战 \ No newline at end of file diff --git "a/chapter1_basic/PHP7_\345\256\211\350\243\205.md" "b/chapter1_basic/PHP7_\345\256\211\350\243\205.md" new file mode 100644 index 0000000..cc21402 --- /dev/null +++ "b/chapter1_basic/PHP7_\345\256\211\350\243\205.md" @@ -0,0 +1,208 @@ +php7-install.md + +使用源码编译安装PHP7 + +2015年6月11日,PHP官网发布消息,正式公开发布PHP7第一版的alpha版本. + +### PHP7特性: + +PHP 7.0.0 Alpha 1使用新版的ZendEngine引擎,带来了许多新的特性,以下是不完全列表: +(1)性能提升:PHP7比PHP5.6性能提升了两倍。 Improved performance: PHP 7 is up to twice as fast as PHP 5.6 +(2)全面一致的64位支持。 Consistent 64-bit support +(3)以前的许多致命错误,现在改成抛出异常。Many fatal errors are now Exceptions +(4)移除了一些老的不在支持的SAPI(服务器端应用编程端口)和扩展。Removal of old and unsupported SAPIs and extensions +(5)新增了空接合操作符。The null coalescing operator (??) +(6)新增加了结合比较运算符。Combined comparison Operator (<=>) +(7)新增加了函数的返回类型声明。Return Type Declarations +(8)新增加了标量类型声明。Scalar Type Declarations +(9)新增加匿名类。Anonymous Classes + +### 系统环境: +``` +Mac-mini:~ WangTom$ uname -mnprs +Darwin Mac-mini.local 14.3.0 x86_64 i386 + +Mac-mini:~ WangTom$ sw_vers +ProductName: Mac OS X +ProductVersion: 10.10.3 +BuildVersion: 14D136 +``` + +### 源码安装PHP7: + +PHP7下载地址:https://downloads.php.net/~ab/ + +``` +$ wget https://downloads.php.net/~ab/php-7.0.0alpha1.tar.bz2 +$ tar jxf php-7.0.0alpha1.tar.bz2 +$ cd php-7.0.0alpha1 + +$ ./configure +... ... +checking size of long... (cached) 8 +checking size of long long... (cached) 8 +checking for iconv support... yes +checking for iconv... no +checking for libiconv... no +configure: error: Please specify the install prefix of iconv with --with-iconv= + +``` + +安装 libiconv (字符编码转换库) +网站地址: http://www.gnu.org/software/libiconv/ +当前版本: http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz + +``` +$ wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz +$ tar zxf libiconv-1.14.tar.gz +$ cd libiconv-1.14 +$ ./configure --prefix=/usr/local/lib/libiconv +$ make +$ sudo make install +``` + + +配置参数 +``` +$ ./configure --prefix=/usr/local/php7 \ +--enable-fpm \ +--with-config-file-path=/usr/local/php7/etc \ +--with-iconv=/usr/local/lib/libiconv \ + +执行configure配置后,可以看到有如下结果: +... ... +Thank you for using PHP. + +config.status: creating php7.spec +config.status: creating main/build-defs.h +config.status: creating scripts/phpize +config.status: creating scripts/man1/phpize.1 +config.status: creating scripts/php-config +config.status: creating scripts/man1/php-config.1 +config.status: creating sapi/cli/php.1 +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 +WangTomdeMacBook-Pro:php-7.0.0alpha1 wangtom$ +``` +$ make +$ make test +$ sudo make install + +查看PHP7是否安装成功 +```` +WangTomdeMacBook-Pro:php-7.0.0alpha1 wangtom$ /usr/local/php7/bin/php -v +PHP 7.0.0alpha1 (cli) (built: Jun 20 2015 00:04:19) +Copyright (c) 1997-2015 The PHP Group +Zend Engine v3.0.0-dev, Copyright (c) 1998-2015 Zend Technologies + +Mac-mini:~ WangTom$ sudo ln -s /usr/local/php7/bin/php /usr/bin/php7 + +Mac-mini:~ WangTom$ php -v +PHP 5.5.20 (cli) (built: Feb 25 2015 23:30:53) +Copyright (c) 1997-2014 The PHP Group +Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies + +Mac-mini:~ WangTom$ php7 -v +PHP 7.0.0alpha1 (cli) (built: Jun 23 2015 17:24:34) +Copyright (c) 1997-2015 The PHP Group +Zend Engine v3.0.0-dev, Copyright (c) 1998-2015 Zend Technologies + +Mac-mini:php-fpm.d WangTom$ which php +/usr/bin/php +Mac-mini:php-fpm.d WangTom$ which php7 +/usr/bin/php7 +``` + +### 配置PHP-FPM: + +Nginx不支持对外部程序的直接调用或者解析,所有的外部程序(包括PHP)必须通过FastCGI接口来调用。 +PHP-FPM是一个PHP FastCGI管理器,新版的PHP已经集成了php-fpm,在./configure的时候带 –enable-fpm参数即可开启PHP-FPM. +FPM (FastCGI Process Manager) is an alternative PHP FastCGI implementation with some additional features (mostly) useful for heavy-loaded sites. + +启动 PHP-FPM: +``` +Mac-mini:php7 WangTom$ /usr/local/php7/sbin/php-fpm +[23-Jun-2015 15:33:01] WARNING: Nothing matches the include pattern '/usr/local/php7/etc/php-fpm.d/*.conf' from /usr/local/php7/etc/php-fpm.conf at line 125. +[23-Jun-2015 15:33:01] ERROR: failed to open error_log (/usr/local/php7/var/log/php-fpm.log): Permission denied (13) +[23-Jun-2015 15:33:01] ERROR: failed to post process the configuration +[23-Jun-2015 15:33:01] ERROR: FPM initialization failed +``` +提示错误说/usr/local/php7/var/log/php-fpm.log 没权限,就给777权限: +$ chmod 777 /usr/local/php7/var/log/ + +修改 php-fpm 配置文件: +$ cd /usr/local/php7/etc/ +$ cp php-fpm.conf.default php-fpm.conf +$ vim php-fpm.conf + > 打开 error_log这一行的注释,默认该项被注释掉,若不修改会出现提示log文件路径不存在 + > error_log = /usr/local/php7/var/log/php-fpm.log + > 打开inclue这一行的注释 + > include=/usr/local/php7/etc/php-fpm.d/*.conf + +修改 /usr/local/php7/etc/php-fpm.d/www.conf 文件: +如果这个文件不存在,就从default复制一份: +$ cd /usr/local/php7/etc/php-fpm.d/ +$ cp www.conf.default www.conf +将配置文件中的 user 和 group 部分的 nobody 改成 www: +$ vim /usr/local/php7/etc/php-fpm.d/www.conf + > user = www + > group = www + +开始启动 php-fpm: +``` +Mac-mini:php-7.0.0alpha1 WangTom$ /usr/local/php7/sbin/php-fpm +[23-Jun-2015 18:30:48] NOTICE: [pool www] 'user' directive is ignored when FPM is not running as root +[23-Jun-2015 18:30:48] NOTICE: [pool www] 'group' directive is ignored when FPM is not running as root +[23-Jun-2015 18:30:48] ERROR: unable to bind listening socket for address '127.0.0.1:9000': Address already in use (48) +[23-Jun-2015 18:30:48] ERROR: FPM initialization failed +``` +这个错误问题有两个:(1)没有使用root账户执行启动命令 (2)端口9000被占用 +解决方法: +使用root账户执行php-fpm启动,或 sudo /usr/local/php7/sbin/php-fpm +关闭 PHP-fpm, 并重新启动: +``` +Mac-mini:~ WangTom$ lsof -P | grep ':9000' | awk '{print $2}' | xargs kill -9 +Mac-mini:php-7.0.0alpha1 WangTom$ /usr/local/php7/sbin/php-fpm -t +[23-Jun-2015 18:30:25] NOTICE: configuration file /usr/local/php7/etc/php-fpm.conf test is successful +Mac-mini:~ WangTom$ sudo /usr/local/php7/sbin/php-fpm +Mac-mini:~ WangTom$ +``` + +修改Nginx 配置: +在 nginx.conf 配置文件server 部分增加fastcgi配置,并重新加载配置文件: +``` +Mac-mini:~ WangTom$ sudo vim /usr/local/nginx/conf/nginx.conf + +> location ~ \.php$ { +> root html; +> fastcgi_pass 127.0.0.1:9000; +> fastcgi_index index.php; +> fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; +> include fastcgi_params; +> } + +Mac-mini:~ WangTom$ sudo /usr/local/nginx/sbin/nginx -t +nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok +nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful +Mac-mini:~ WangTom$ sudo /usr/local/nginx/sbin/nginx -s reload +Mac-mini:~ WangTom$ +``` + +用到的一些命令: + +uname: 用来获取电脑和操作系统的相关信息 +sw_vers: Mac下查看系统版本信息 +lsof: 列出当前系统打开文件(list open files) +which: 指令会在环境变量$PATH设置的目录里查找符合条件的文件 + + +参考链接: + +- http://php.net/archive/2015.php#id2015-06-11-3 +- http://www.hashbangcode.com/blog/compiling-and-installing-php7-ubuntu + + +[END] diff --git a/chapter1_basic/README.md b/chapter1_basic/README.md new file mode 100644 index 0000000..de36aa5 --- /dev/null +++ b/chapter1_basic/README.md @@ -0,0 +1,2 @@ +README.md +服务器与部署 \ No newline at end of file diff --git "a/chapter1_basic/\345\256\211\350\243\205Nginx\346\234\215\345\212\241\345\231\250.md" "b/chapter1_basic/\345\256\211\350\243\205Nginx\346\234\215\345\212\241\345\231\250.md" new file mode 100644 index 0000000..5d77f55 --- /dev/null +++ "b/chapter1_basic/\345\256\211\350\243\205Nginx\346\234\215\345\212\241\345\231\250.md" @@ -0,0 +1,93 @@ +02-如何源码安装Nginx服务器 + +# 02-如何源码安装Nginx服务器 + +##### 安装 PCRE : +> 网站:http://pcre.org/ +> 下载: +> - ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/ +> - ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.36.tar.bz2 + +##### 安装 Nginx : +> + 网站地址:http://nginx.org/en/docs/ +> + 下载地址:http://nginx.org/download/nginx-1.8.0.tar.gz + +##### 安装命令: +``` +下载: +wget http://nginx.org/download/nginx-1.8.0.tar.gz + +tar zxf nginx-1.8.0.tar.gz +cd nginx-1.8.0 +./configure --prefix=/usr/local/nginx +make +sudo make install + +./configure --prefix=/usr/local/nginx \ + --sbin-path=/usr/local/nginx/nginx \ + --conf-path=/usr/local/nginx/nginx.conf \ + --pid-path=/usr/local/nginx/nginx.pid \ + --with-http_ssl_module \ + + + + +ps -ef |grep nginx + +启动Nginx: +sudo /usr/local/nginx/sbin/nginx + +重新加载配置文件: +sudo /usr/local/nginx/sbin/nginx -t +sudo /usr/local/nginx/sbin/nginx -s reload + +``` + +##### 检查是否安装成功: + +[1] 命令行查看Nginx版本: +``` +/usr/local/nginx/sbin/nginx -V +Mac-mini:nginx-1.8.0 WangTom$ /usr/local/nginx/sbin/nginx -V +nginx version: nginx/1.8.0 +built by clang 6.1.0 (clang-602.0.53) (based on LLVM 3.6.0svn) +configure arguments: --prefix=/usr/local/nginx + +Mac-mini:nginx-1.8.0 WangTom$ /usr/local/nginx/sbin/nginx -v +nginx version: nginx/1.8.0 +``` + +[2] 浏览器中查看页面 +在浏览器中访问: http://localhost/ 安装成功则页面出现: +``` +Welcome to nginx! +If you see this page, the nginx web server is successfully installed and working. +Further configuration is required. +For online documentation and support please refer to nginx.org. +Commercial support is available at nginx.com. +Thank you for using nginx. +``` +查看 Nginx 版本: +Mac-mini:html WangTom$ sudo /usr/local/nginx/sbin/nginx -v +nginx version: nginx/1.8.0 + +检测 Nginx 配置文件 +Mac-mini:html WangTom$ sudo /usr/local/nginx/sbin/nginx -t +nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok +nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful + + +To apply the new configuration, start nginx if it is not yet started or send the reload signal to the nginx’s master process, by executing: +Mac-mini:html WangTom$ sudo /usr/local/nginx/sbin/nginx -s reload +Mac-mini:html WangTom$ + + + +##### 参考地址: + +Building nginx from Sources: +http://nginx.org/en/docs/configure.html + + + +[END] diff --git "a/chapter1_basic/\345\256\211\350\243\205PHP\345\274\200\345\217\221\347\216\257\345\242\203.md" "b/chapter1_basic/\345\256\211\350\243\205PHP\345\274\200\345\217\221\347\216\257\345\242\203.md" new file mode 100644 index 0000000..ccbde71 --- /dev/null +++ "b/chapter1_basic/\345\256\211\350\243\205PHP\345\274\200\345\217\221\347\216\257\345\242\203.md" @@ -0,0 +1,279 @@ + +- 如何安装PHP开发环境 + +-- PHP官网: http://php.net/manual/zh/install.php + +在 Unix/Linux 平台下安装 PHP 有几种方法:使用配置和编译过程,或是使用各种预编译的包。 +本文主要针对配置和编译 PHP 的过程。 +很多 Unix 类系统都有包安装系统,可以用它来设置一个有着标准配置的 PHP。 +但是若需要与标准配置不同的功能(例如一个安全服务器,或者不同的数据库驱动扩展模块),可能需要编译 PHP 和/或 web 服务器。 +如果不熟悉编译软件,可以考虑搜索一下是否有人已经编译了包含所需要功能的预编译包。 + +### PHP开发环境包括什么? + + + +### 如何安装PHP开发环境? + +1 使用一键安装包: + +Windows系统: + +PHPStudy: +http://www.phpstudy.net/ + +AppServ: +http://www.appservnetwork.com/en/ + +WampServer: +http://www.wampserver.com/ + +UPUPW: +http://www.upupw.net/ + +XAMPP:支持Windows/Linux/MacOS平台 +https://www.apachefriends.org/zh_cn/index.html + +Linux系统: + +http://lnmp.org/ +http://www.lanmps.com/ +XAMPP:支持Windows/Linux/MacOS平台 +https://www.apachefriends.org/zh_cn/index.html + +2 使用源码编译安装: + + + +### 如何使用源码编译安装PHP环境? +> + OpenSSl +> + Mcrypt +> + zlib +> + freetype +> + jpeg +> + 安装libpng +> + MySQL: + + + +##### 安装 OpenSSl : + +官网:http://www.openssl.org/ +简介:OpenSSL 是一个强大的安全套接字层密码库,囊括主要的密码算法、常用的密钥和证书封装管理功能及SSL协议,并提供丰富的应用程序供测试或其它目的使用。 +下载:http://www.openssl.org/source/openssl-1.0.2a.tar.gz + +参见: +Mac-64-bit: http://wiki.openssl.org/index.php/Compilation_and_Installation#Mac + +``` +- wget http://www.openssl.org/source/openssl-1.0.2a.tar.gz +- cd openssl-1.0.2a +- ./Configure darwin64-x86_64-cc enable-ec_nistp_64_gcc_128 no-ssl2 no-ssl3 no-comp --openssldir=/usr/local/ssl/macos-x86_64 +- make +- sudo make install +``` + + +### 安装 Mcrypt: +> # 官网: +> http://mcrypt.hellug.gr/ +> # 下载: +> ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt +> wget ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt/libmcrypt-2.5.7.tar.gz + + +### 安装 zlib: + +> # 官网: +> http://www.zlib.net/ +> #简介: +> zlib是提供数据压缩用的函式库,由Jean-loup Gailly与Mark Adler所开发,初版0.9版在1995年5月1日发表。zlib使用DEFLATE算法,最初是为libpng函式库所写的,后来普遍为许多软件所使用。此函式库为自由软件,使用zlib授权。 + +``` +$ wget http://zlib.net/zlib-1.2.8.tar.gz +$ ./configure --prefix=/usr/local/lib/zlib +$ make +$ make install +``` + +### 安装 libiconv (字符编码转换库) + +# 网站: http://www.gnu.org/software/libiconv/ +# 当前版本: http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz + +$ wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz +$ tar zxvf libiconv-1.14.tar.gz +$ cd libiconv-1.14 +$ ./configure --prefix=/usr/local/lib/libiconv +$ make +$ sudo make install + + + +### 安装freetype +- tar xzvf freetype-2.1.5.tar.gz (http://freetype.sourceforge.net/download.html#stable) +- cd freetype-2.1.5 +- ./configure --prefix=/usr/local/modules/freetype +- make +- make install + +# 安装 jpeg: +> http://www.ijg.org/ +> http://www.ijg.org/files/ +> wget http://www.ijg.org/files/jpegsrc.v9.tar.gz +> +> - $ wget http://www.ijg.org/files/jpegsrc.v9.tar.gz +> - $ tar zxf jpegsrc.v9.tar.gz +> - $ cd jpeg-9/ +> - $ ./configure --prefix=/usr/local/lib/jpeg9 +> - $ make +> - $ sudo make install + +### 安装libpng: +> # 网站: +> http://libmng.com/pub/png/libpng.html +> #下载: +> http://sourceforge.net/projects/libpng/ +> ftp://ftp.simplesystems.org/pub/libpng/png/src/libpng16/libpng-1.6.17.tar.gz +> +> +> +> +> + +### 安装 MySQL: +> http://dev.mysql.com/downloads/ +> +> +> +> +> + +libevent +https://sourceforge.net/projects/levent/files/libevent/libevent-2.0/libevent-2.0.22-stable.tar.gz + +http://pecl.php.net/get/xhprof-0.9.4.tgz + + + + +``` + ./configure \ + --prefix=/usr/local/php \ + --with-config-file-path=/usr/local/php \ + --with-mysql \ + --with-mysqli \ + --enable-pdo \ + --with-pdo-mysql \ + --with-mysql-sock=/tmp/mysql.sock \ + --enable-opcache \ + --enable-cgi \ + --enable-fpm \ + --enable-sockets \ + --enable-mbstring \ + --enable-mbregex \ + --enable-bcmath \ + --enable-xml \ + --enable-zip \ + --with-zlib=/usr/local/lib/zlib \ + --with-gd \ + --with-png-dir=/usr/local/lib/libpng \ + --with-jpeg-dir=/usr/local/lib/libjpeg \ + --with-openssl=/usr/local/ssl/macos-x86_64/ \ + --with-curl=/usr/local/curl \ + --with-mhash=/usr/local/lib/libmhash \ + --with-mcrypt=/usr/local/lib/libmcrypt \ + --with-iconv=/usr/local/lib/libiconv \ +``` + +``` +# 报错:OpenSSL +... ... +checking for DSA_get_default_method in -lssl... no +checking for X509_free in -lcrypto... yes +checking for RAND_egd... no +checking for pkg-config... no +configure: error: Cannot find OpenSSL's +Mac-mini:php-5.6.9 WangTom$ +``` + + +Mac-mini:php-5.6.9 WangTom$ which openssl +/usr/bin/openssl + + +修改openssl参数地址: +--with-openssl=/usr/local/ssl/macos-x86_64/ + +``` +# 报错:zlib +... ... +checking bundled sqlite3 library... yes +checking for ZLIB support... yes +checking if the location of ZLIB install directory is defined... no +configure: error: Cannot find libz +Mac-mini:php-5.6.9 WangTom$ +``` +修改openssl参数地址: +--with-openssl=/usr/local/lib/zlib + + +``` +# 报错: curl +... ... +checking whether to enable ctype functions... yes +checking for cURL support... yes +checking for cURL in default path... not found +configure: error: Please reinstall the libcurl distribution - + easy.h should be in /include/curl/ +Mac-mini:php-5.6.9 WangTom$ +``` + + + + +``` +# 报错: cURL +checking whether to enable ctype functions... yes +checking for cURL support... yes +checking for cURL in default path... not found +configure: error: Please reinstall the libcurl distribution - + easy.h should be in /include/curl/ +``` + + +Mac-mini:php-5.6.9 WangTom$ brew --config +HOMEBREW_VERSION: 0.9.5 +ORIGIN: https://github.com/Homebrew/homebrew +HEAD: 5b151e438b20f68afadbc9a6df2a01a0cc52b383 +Last commit: 3 weeks ago +HOMEBREW_PREFIX: /usr/local +HOMEBREW_CELLAR: /usr/local/Cellar +CPU: 8-core 64-bit ivybridge +OS X: 10.10.3-x86_64 +Xcode: 6.3.2 +CLT: N/A +Clang: 6.1 build 602 +X11: N/A +System Ruby: 2.0.0-p481 +Perl: /usr/bin/perl +Python: /usr/bin/python +Ruby: /usr/bin/ruby +Java: 1.8.0 + +Mac-mini:~ WangTom$ sudo ln -s /Applications/Xcode6-Beta4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include /usr/include + +Mac-mini:~ WangTom$ ls -l /usr/include +lrwxr-xr-x 1 root wheel 118 6 19 14:18 /usr/include -> /Applications/Xcode6-Beta4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include + + + + + + + + + + + + diff --git "a/chapter1_basic/\346\255\243\345\210\231\350\241\250\350\276\276\345\274\217.md" "b/chapter1_basic/\346\255\243\345\210\231\350\241\250\350\276\276\345\274\217.md" new file mode 100644 index 0000000..e69de29 diff --git "a/chapter2_php/PHP\344\270\216\346\225\260\346\215\256\345\272\223.md" "b/chapter2_php/PHP\344\270\216\346\225\260\346\215\256\345\272\223.md" new file mode 100644 index 0000000..58329fc --- /dev/null +++ "b/chapter2_php/PHP\344\270\216\346\225\260\346\215\256\345\272\223.md" @@ -0,0 +1,18 @@ + +# PHP与数据库 + +关系型数据库MySQL + + +NoSQL数据库 + +键值存储型数据库Memcache + +支持数据结构特性的Redis + + + + + + + diff --git "a/chapter2_php/PHP\345\255\227\347\254\246\344\270\262.md" "b/chapter2_php/PHP\345\255\227\347\254\246\344\270\262.md" new file mode 100644 index 0000000..e727b53 --- /dev/null +++ "b/chapter2_php/PHP\345\255\227\347\254\246\344\270\262.md" @@ -0,0 +1,19 @@ +PHP学习参考指南 + +Chapter-01 PHP是什么? + +- PHP是神马东东? +PHP(“PHP: Hypertext Preprocessor”,超文本预处理器的字母缩写)是一种被广泛应用的开放源代码的多用途脚本语言,它可嵌入到 HTML中,尤其适合 web 开发。 + +- PHP能干什么? + +使用 PHP 的一大好处是它对于初学者来说极其简单。 + +PHP 主要是用于服务端的脚本程序。 + + + + + + + diff --git "a/chapter2_php/PHP\346\225\260\347\273\204.md" "b/chapter2_php/PHP\346\225\260\347\273\204.md" new file mode 100644 index 0000000..e727b53 --- /dev/null +++ "b/chapter2_php/PHP\346\225\260\347\273\204.md" @@ -0,0 +1,19 @@ +PHP学习参考指南 + +Chapter-01 PHP是什么? + +- PHP是神马东东? +PHP(“PHP: Hypertext Preprocessor”,超文本预处理器的字母缩写)是一种被广泛应用的开放源代码的多用途脚本语言,它可嵌入到 HTML中,尤其适合 web 开发。 + +- PHP能干什么? + +使用 PHP 的一大好处是它对于初学者来说极其简单。 + +PHP 主要是用于服务端的脚本程序。 + + + + + + + diff --git "a/chapter2_php/PHP\346\226\207\344\273\266\347\256\241\347\220\206.md" "b/chapter2_php/PHP\346\226\207\344\273\266\347\256\241\347\220\206.md" new file mode 100644 index 0000000..36246c8 --- /dev/null +++ "b/chapter2_php/PHP\346\226\207\344\273\266\347\256\241\347\220\206.md" @@ -0,0 +1,20 @@ +# PHP文件系统 + +文件和文件系统 + +文本文件和二进制文件 + +文件的打开方式 + +文件的顺序存取和随机存取 + +XML和JSON操作要点 + +文件的存储和磁盘阵列 + +大文件上传和断点续传 + + + + + diff --git "a/chapter2_php/PHP\347\256\200\344\273\213.md" "b/chapter2_php/PHP\347\256\200\344\273\213.md" new file mode 100644 index 0000000..e727b53 --- /dev/null +++ "b/chapter2_php/PHP\347\256\200\344\273\213.md" @@ -0,0 +1,19 @@ +PHP学习参考指南 + +Chapter-01 PHP是什么? + +- PHP是神马东东? +PHP(“PHP: Hypertext Preprocessor”,超文本预处理器的字母缩写)是一种被广泛应用的开放源代码的多用途脚本语言,它可嵌入到 HTML中,尤其适合 web 开发。 + +- PHP能干什么? + +使用 PHP 的一大好处是它对于初学者来说极其简单。 + +PHP 主要是用于服务端的脚本程序。 + + + + + + + diff --git a/chapter2_php/README.md b/chapter2_php/README.md new file mode 100644 index 0000000..6ad8faa --- /dev/null +++ b/chapter2_php/README.md @@ -0,0 +1,93 @@ +chapter2/README.md + + +# PHP选项和运行原理 + +PHP运行模式 + +PHP的Thread Safe和Non Thread Safe + +CGI、FastCGI、 ISAPI、SAPI + +Apache下的work和prefork模式 + +Nginx下PHP的FastCGI模式 + +比较I/O模型select和epoll + +PHP的运行机制与原理 + +PHP的垃圾回收机制 + +PHP选项相关的问题 + + + + +# PHP数据结构 + +数据结构基本概念 + +算法和算法的时间复杂度 + +常见结构:链表、线性表、 队列和堆栈 + +递归和循环的相互转化 + +PHP查找和排序算法详解 + +分解法和“剥洋葱”法的算法设计技巧 + + +# PHP高级特性 + +PHP的Callback函数 + +PHP的魔术方法 + +自动加载对象的应用 + +PHP的反射机制 + +PHP的异常处理 + + +# PHP设计模式 + +设计模式简介 + +工厂模式详解 + +策略模式详解 + +观察者模式详解 + +装饰模式详解 + +单例模式详解 + +适配器模式详解 + +设计模式综合应用 + + +# PHP开发框架 + + +# PHP安全 + +WEB安全入门 + +常用测试漏洞工具 + +点击劫持与任意重定向漏洞 + +XSS与CSRF漏洞详解 + +注入漏洞原理分析 + +访问控制与命令执行漏洞 + +文件上传下载与敏感信息泄露漏洞 + +各种漏洞修复和防范技巧 \ No newline at end of file diff --git a/chapter3_js_html/README.md b/chapter3_js_html/README.md new file mode 100644 index 0000000..1e32da8 --- /dev/null +++ b/chapter3_js_html/README.md @@ -0,0 +1,24 @@ + + +# HTML与CSS基础 + + + +# 深入JavaScript + +深入JS数据类型的转换规则 + +深入理解call和apply的使用 + +深入理解JS闭包 + +深入理解JS事件驱动 + +深入理解JS原型和原型链 + +深入理解JS作用域 + +Ajax技术和跨域问题 + +编写jQuery插件 + diff --git a/chapter4_database/README.md b/chapter4_database/README.md new file mode 100644 index 0000000..1f1fa0f --- /dev/null +++ b/chapter4_database/README.md @@ -0,0 +1,29 @@ +chapter2/README.md + +数据库基础知识 + + +# MySQL + +MySQL体系结构 + +MySQL表存储引擎 + +PHP的MySQL驱动和API详解 + +MySQL索引和全文检索技术 + +SQL语句优化和性能调优 + +MySQL数据表水平和垂直拆分 + +MySQL数据库读写分离技术 + +MySQL数据库高可用方案设计 + +# Redis + + +# MongoDB + + diff --git "a/chapter5_linux/Git\344\275\277\347\224\250\346\225\231\347\250\213.md" "b/chapter5_linux/Git\344\275\277\347\224\250\346\225\231\347\250\213.md" new file mode 100644 index 0000000..69bc098 --- /dev/null +++ "b/chapter5_linux/Git\344\275\277\347\224\250\346\225\231\347\250\213.md" @@ -0,0 +1,184 @@ +Git使用教程.md + +# Git简介 + +Git是一个分布式的版本控制系统(DVCS, Distributed Version Control Systems). + +Git官网: https://git-scm.com/ +Git下载: https://git-scm.com/download/ + +### Git常用命令 + +git pull:取回远程主机某个分支的更新,再与本地的指定分支合并 + +格式:git pull <远程主机名> <远程分支名>:<本地分支名> + +示例: +``` +$ git pull origin dev +From code.XXX.com:wangyt/php-dev-docs + * branch dev -> FETCH_HEAD +Already up-to-date. +``` + + +git log + +查看日志:git log +参数--pretty=online显示成一行 +> git log +> git log --pretty=online + + + + +mkdir git-test +cd git-test/ +git init +vim readme.txt +git status +git add readme.txt +git commit -m 'add new file readme.txt' + +vim readme.txt +git status +git diff readme.txt +git commit -m 'update readme.txt' + +git add readme.txt +git commit -m 'update readme.txt' +git log +git status + +vim readme.txt +git commit -m 'update readme.txt:TEST' +git add readme.txt +git commit -m 'update readme.txt:TEST' + + + + + +回到上一个版本 +git reset --hard HEAD^ + +回到某个指定的 commit id 版本: +git reset --hard 3628164 + +使用 git reflog 查看命令历史 +$ git reflog +2630090 HEAD@{0}: reset: moving to 2630090 +c585eb1 HEAD@{1}: reset: moving to HEAD^ +2630090 HEAD@{2}: commit: update readme.txt:TEST +c585eb1 HEAD@{3}: commit: update readme.txt +6d0aee0 HEAD@{4}: commit (initial): add new file readme.txt + + +``` +//编辑完文件,查看状态,会提示可能的操作 +$ git status +On branch master +Your branch is up-to-date with 'origin/master'. +Changes not staged for commit: + (use "git add ..." to update what will be committed) + (use "git checkout -- ..." to discard changes in working directory) + modified: git.doc.md +no changes added to commit (use "git add" and/or "git commit -a") +``` + +Administrator@BQ-DN-BJB-022 MINGW64 /d/working/php-dev-docs (master) +$ git branch + dev +* master + +Administrator@BQ-DN-BJB-022 MINGW64 /d/working/php-dev-docs (master) +$ git status +On branch master +Your branch is up-to-date with 'origin/master'. +Changes not staged for commit: + (use "git add ..." to update what will be committed) + (use "git checkout -- ..." to discard changes in working directory) + modified: git.doc.md +no changes added to commit (use "git add" and/or "git commit -a") + +Administrator@BQ-DN-BJB-022 MINGW64 /d/working/php-dev-docs (master) +$ git add git.doc.md + +Administrator@BQ-DN-BJB-022 MINGW64 /d/working/php-dev-docs (master) +$ git commit -m "UPDATE git.doc.md" +[master daeebd5] UPDATE git.doc.md + 1 file changed, 52 insertions(+), 10 deletions(-) + +Administrator@BQ-DN-BJB-022 MINGW64 /d/working/php-dev-docs (master) +$ git status +On branch master +Your branch is ahead of 'origin/master' by 1 commit. + (use "git push" to publish your local commits) +nothing to commit, working directory clean + +Administrator@BQ-DN-BJB-022 MINGW64 /d/working/php-dev-docs (master) +$ git push +Counting objects: 3, done. +Delta compression using up to 4 threads. +Compressing objects: 100% (3/3), done. +Writing objects: 100% (3/3), 1.17 KiB | 0 bytes/s, done. +Total 3 (delta 1), reused 0 (delta 0) +To git@code.boqii.com:wangyt/php-dev-docs + 710954f..daeebd5 master -> master + +Administrator@BQ-DN-BJB-022 MINGW64 /d/working/php-dev-docs (master) +$ git status +On branch master +Your branch is up-to-date with 'origin/master'. +nothing to commit, working directory clean + + + + +### 配置 + +列出当前的配置: + +git config -l +git config --global +git config --local + +设置邮箱和用户名: +> 如果没有配置邮箱与用户名,提交时会提示配置: +> ``` +> $ git commit -m "Add configure.php.dev.env.md" +> *** Please tell me who you are. +> Run +> git config --global user.email "you@example.com" +> git config --global user.name "Your Name" +> ``` + +``` +//全局的设置 +$ git config --global user.email "ahwyt2008@foxmail.com" +$ git config --global user.name "WangYongTao" +``` + +``` +//局部的设置 +$ git config --local user.email "ahwyt2008@163.com" +$ git config --local user.name "WANG-YongTao" +``` + + + + +# Git教程 + +官方教程:《Pro Git : 2nd Edition (2014)》 +https://git-scm.com/book/en/v2 +https://git-scm.com/book/zh (中文版) + +廖雪峰的官方网站:《Git教程》 +http://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000 + +易佰:《Git教程》 +http://www.yiibai.com/git/ + + +# 参考链接 diff --git a/chapter5_linux/README.md b/chapter5_linux/README.md new file mode 100644 index 0000000..e7f2ae0 --- /dev/null +++ b/chapter5_linux/README.md @@ -0,0 +1,16 @@ + +Linux的哲学思想 + +常用指令和使用技巧 + +文件权限和文件操作 + +管道和重定向 + +crontab和后台任务 + +Vim编辑器使用技巧 + +Shell程序设计 + + diff --git "a/chapter6_practice/PHP\344\273\243\347\240\201\351\243\216\346\240\274.md" "b/chapter6_practice/PHP\344\273\243\347\240\201\351\243\216\346\240\274.md" new file mode 100644 index 0000000..e69de29 diff --git "a/chapter6_practice/PHP\345\274\200\345\217\221\344\270\255\347\274\226\347\240\201\344\271\261\347\240\201\351\227\256\351\242\230.md" "b/chapter6_practice/PHP\345\274\200\345\217\221\344\270\255\347\274\226\347\240\201\344\271\261\347\240\201\351\227\256\351\242\230.md" new file mode 100644 index 0000000..4218c66 --- /dev/null +++ "b/chapter6_practice/PHP\345\274\200\345\217\221\344\270\255\347\274\226\347\240\201\344\271\261\347\240\201\351\227\256\351\242\230.md" @@ -0,0 +1,73 @@ +PHP乱码的一些问题 + +PHP开发中出现乱码,一般在文件、数据、各处的格式不同造成的。 + +请包装PHP文件格式为UTF8,模板HTML/CSS/JavaScript等文件也要保存成UTF8格式。 +操作:Notepad++: 打开文件,选择[格式(M)]>[转为UTF8无BOM编码格式],然后保存即可 + +由于目前还不是Unicode的,所以所有的字符串处理函数尽量换成多字节处理函数。 +即把substr之类的函数改成mb_substr,这可能需要安装mbstring扩展。 +参见PHP文档:http://php.net/manual/zh/ref.mbstring.php + +PHP与MySQL的数据库的交互时,一定要保证双方的编码一致。 + + + + + + +在HTML页面中声明编码格式: +在页面< head >< /head >里面增加meta信息: + + + +在PHP文件中使用UTF8编码: +header("Content-Type:text/html; charset=utf-8"); + +数据库使用UTF8: +创建数据库的时候,MySQL字符集选择'UTF8',MySQL连接校对选择utf8_general_ci + +$mysqli->query("SET character set 'utf8'");//读库 +$mysqli->query("SET NAMES 'utf8'");//写库 + + +#### 问题1:在Linux下执行PHP文件时错误:Could not open input file +解决:如果出现这个,可能就是文件格式的问题: +使用Vim命令:在Linux上查看文档格式 :set ff + fileformat=dos +执行 :set ff=unix +再次查看 :set ff + fileformat=unix +变成了unix格式的,重试执行PHP文件,正常。 + +使用Notepad++编辑器也可以改变格式: +[编辑(E)] > [档案格式转换] > [转换为UNINX格式] + + +#### PHP中有关编码的函数 + +##### iconv — 字符串按要求的字符编码来转换 + 格式:string iconv ( string $in_charset , string $out_charset , string $str ) + 说明:将字符串 str 从 in_charset 转换编码到 out_charset。 + +##### urlencode — 编码 URL 字符串 + 格式:string urlencode ( string $str ) + 说明:此函数便于将字符串编码并将其用于 URL 的请求部分,同时它还便于将变量传递给下一页。 + +##### urldecode — 解码已编码的 URL 字符串 + 格式:string urldecode ( string $str ) + 说明:解码给出的已编码字符串中的任何 %##。 加号('+')被解码成一个空格字符。 + +##### rawurlencode() - 按照 RFC 1738 对 URL 进行编码 +##### rawurldecode() - 对已编码的 URL 字符串进行解码 + +##### json_encode — 对变量进行 JSON 编码 +##### json_decode — 对 JSON 格式的字符串进行编码 + +##### serialize — 产生一个可存储的值的表示 +##### unserialize — 从已存储的表示中创建 PHP 的值 + +##### session_encode — 将当前会话数据编码为一个字符串 +##### session_decode() - Decodes session data from a session encoded string + + diff --git a/chapter6_practice/README.md b/chapter6_practice/README.md new file mode 100644 index 0000000..d71c9ce --- /dev/null +++ b/chapter6_practice/README.md @@ -0,0 +1,5 @@ +chapter2/README.md + +编程实践 + + diff --git "a/chapter6_practice/\345\246\202\344\275\225\350\256\251PHP\347\250\213\345\272\217\346\233\264\345\212\240\345\256\211\345\205\250.md" "b/chapter6_practice/\345\246\202\344\275\225\350\256\251PHP\347\250\213\345\272\217\346\233\264\345\212\240\345\256\211\345\205\250.md" new file mode 100644 index 0000000..d910660 --- /dev/null +++ "b/chapter6_practice/\345\246\202\344\275\225\350\256\251PHP\347\250\213\345\272\217\346\233\264\345\212\240\345\256\211\345\205\250.md" @@ -0,0 +1,67 @@ +如何让PHP程序更加安全? + + +## 常见的攻击方法 + +SQL注入 + + + +## 防护方法 + +- 表单数据过滤: + +$_POST +$_GET +$_REQUEST + +- 文件上传: + +### 密码安全: + + +明文密码: + +> cnBeta 2016年03月01日 09:18 +> 一个来自网络攻击论坛"Hell"的黑客宣称从Mate1.com那里盗走了2700万多个明文密码,并表示会将它们卖掉。 +> http://www.cnbeta.com/articles/479369.htm + +> 网易 2015年10月29日 18:00 +> 提供免费Web托管服务的000Webhost被黑客在5个月前利用旧版PHP的漏洞入侵系统,窃取了1300多万用户的明文密码、电子邮件和登录IP地址。 +> http://help.3g.163.com/15/1029/18/B746987900964K9G.html + +> 和讯科技 2015年04月08日 01:36 +> 3月19日,乌云披露,微付通支付平台安全漏洞可导致数据库泄露(用户密码竟然明文存储),危害等级“高”,漏洞状态显示“已交由国家互联网应急中心处理”。 +> http://tech.hexun.com/2015-04-08/174757376.html + +> 青岛晚报电子报 2015年01月09日 22:29 +> 昨日,记者从补天漏洞响应平台获悉,国内流行的手机抢票软件“火车票达人”存在高危漏洞,数百万机票、火车票订单用户的身份证号、用户名、明文密码、详细票务信息等。 +> http://wb.qdqss.cn/html/qdzb/20150109/qdzb26393.html + +> 网易数码 2011年12月28日 05:22 +> 你的密码安全吗?CSDN被爆引发的警示 失窃密码查询 作为一家知名的开发者网站CSDN竟然用明文保存密码,这让人不禁瞠目。 +> http://digi.163.com/11/1228/05/7MBCU9LS001664LU_3.html + +> 同花顺金融服务网 2011年12月30日 13:16 +> 导致600余万个注册邮箱账号和与之对应的明文密码泄露之后,本周一,又有天涯、...昨天,网络传言“泄密门”已经蔓延到银行。 +> http://finance.ifeng.com/bank/yhpl/20111230/5378418.shtml + + +- 使用 MySQLi 或 PDO 预处理语句: + + +- 跨站点脚本(XSS) + + + +## 参考文章 + +编写安全 PHP 应用程序的七个习惯: +http://www.ibm.com/developerworks/cn/opensource/os-php-secure-apps/index.html + +PHP安全编码: +http://drops.wooyun.org/tips/135 + +PHP文件上传中的安全问题: +http://www.cnblogs.com/cocowool/archive/2011/11/10/2245108.html +