20180629

防盗链
配置防盗链
盗链,全称是盗取链接,假如我们的网站有很多好看的图片,别人可以查看我们网站图片的链接,然后应用在他的网站上,这样的话,去访问他的网站,实际上消耗的是我们的流量(因为实际链接在我们这里),这样我们就不得不去配置防盗链,使得别人不能复制我们图片的链接。
1.在Apache子配置文件/usr/local/apache2.4/conf/extra/httpd-vhosts.conf中添加配置
2.20180629
3.在/data/wwwroot/111.com设置图片qq.png
4.20180629
5.20180629
重启服务
20180629
如果未设置referer ask.apelearn.com则Forbidden
20180629
当设置SetEnvIfNoCase Referer "^$" local_ref可直接访问图片
20180629
curl -e可以用于模拟一个referer参数 用http开头的合格referer
20180629
20180629

访问控制
20180629
Order确定执行顺序,整个语句都会执行一遍,与iptables的执行过程不同
如果先deny,后allow,则会先执行deny的操作,再执行允许的动作。后面的动作会覆盖前面的操作
如果先allow,后deny all,则最后的结果会是deny
20180629
验证
20180629

访问控制filematch
20180629
在Directory 下定义filesmatch
20180629
20180629

禁止PHP解析
20180629
不能解析

访问来控制禁止解析php
20180629

限制user_agent
20180629

20180629
20180629
-A指定user agent

php相关配置
20180629
创建phpinfo()
20180629
20180629
需要禁止的函数

定义时区
data.time.zone
display-error设置为off
20180629
配置错误日志
20180629
定义错误日志路径

定义openbasedir
20180629
未在定义允许的目录下
20180629

php扩展模块
20180629
yum -y install autoconf

[root@localhost b.com]# wget https://codeload.github.com/phpredis/phpredis/zip/develop -C /usr/local/src/phpredis-develop.zip
[root@localhost b.com]# ls /usr/local/src/
apr-1.6.3 apr-util-1.6.1 httpd-2.4.33 mysql-5.6.36 php-5.5.38.tar.bz2 php-5.6.30.tar.gz
apr-1.6.3.tar.gz apr-util-1.6.1.tar.gz httpd-2.4.33.tar.gz mysql-5.6.36.tar.gz php-5.6.30 phpredis-develop.zip
2.解压软件包
[root@localhost src]# unzip phpredis-develop.zip
3.切换到phpredis-develop目录
[root@localhost src]# cd phpredis-develop/
4.编译
//生成配置文件,比较特殊,默认的包没有.configure文件,需要用phpize生成
[root@localhost phpredis-develop]# /usr/local/php/bin/phpize
Configuring for:
PHP Api Version: 20131106
Zend Module Api No: 20131226
Zend Extension Api No: 220131226
//configure
[root@localhost phpredis-develop]# ./configure --with-php-config=/usr/local/php/bin/php-config
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
...中间略...
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... no

creating libtool
appending configuration tag "CXX" to libtool
configure: creating ./config.status
config.status: creating config.h
//编译安装
[root@localhost phpredis-develop]# make && make install
/bin/sh /usr/local/src/phpredis-develop/libtool --mode=compile cc -I. -I/usr/local/src/phpredis-develop -DPHP_ATOM_INC -I/usr/local/src/phpredis-develop/include -I/usr/local/src/phpredis-develop/main -I/usr/local/src/phpredis-develop -I/usr/local/php/include/php -I/usr/local/php/include/php/main -I/usr/local/php/include/php/TSRM -I/usr/local/php/include/php/Zend -I/usr/local/php/include/php/ext -I/usr/local/php/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /usr/local/src/phpredis-develop/redis.c -o redis.lo
mkdir .libs
...中间略...
See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.

Build complete.
Don't forget to run 'make test'.

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

//根据提示,可以看到共享的扩展已经安装到了 /usr/local/php/lib/php/extensions/no-debug-zts-20131226/目录
[root@localhost phpredis-develop]# ls -l /usr/local/php/lib/php/extensions/no-debug-zts-20131226/
total 2572
-rwxr-xr-x. 1 root root 607600 Jun 24 09:49 opcache.so
-rwxr-xr-x. 1 root root 2023136 Jun 30 04:57 redis.so
5.配置加载扩展模块
//查看扩展模块存放目录
[root@localhost phpredis-develop]# /usr/local/php/bin/php -i |grep extension_dir
extension_dir => /usr/local/php/lib/php/extensions/no-debug-zts-20131226 => /usr/local/php/lib/php/extensions/no-debug-zts-20131226
sqlite3.extension_dir => no value => no value
//编译php.ini
[root@localhost phpredis-develop]# vim /usr/local/php/etc/php.ini
//在文件最后加添
extension = redis.so

//测试配置及重载
[root@localhost phpredis-develop]# /usr/local/apache2.4/bin/apachectl -t
Syntax OK
[root@localhost phpredis-develop]# /usr/local/apache2.4/bin/apachectl graceful
//验证
[root@localhost phpredis-develop]# /usr/local/php/bin/php -m | grep redis
redis
另外一种方法快速安装redis.so模块 /usr/local/php7/bin/pecl install redis
技巧(以php-7为例):
如果想要编译一个模块,而且他自带的源码包目录/usr/local/src/php-7.1.6/ext 下有,那么只需要进行以下一些步骤,就可以完成扩展模块的安装
在你需要增加的拓展模块的目录下执行 /usr/local/php7/bin/phpize ,生成一个configure 文件
执行 ./configure –with-php-config=/usr/local/php7/bin/php-config 配置php-config文件
开始编译 make
编译后移动到目录 make install
修改配置文件vim /usr/local/php7/etc/php.ini ,新增所需extension=xxxxxxx.so 拓展模块
在PHP的源码包中没有第三方模块的包,但是在PHP源码包的/ext/目录下有好多扩展模块,如果所需要的扩展模块在该目录下,可以直接进行安装
在源码包中安装模块,在php的源码包中,有一个ext目录,这个目录下有很多的模块
[root@localhost php-7.1.6]# ls ext/
bcmath dom gd json odbc pdo_mysql pspell snmp sysvshm xsl
bz2 enchant gettext ldap opcache pdo_oci readline soap tidy zip
calendar exif gmp libxml openssl pdo_odbc recode sockets tokenizer zlib
com_dotnet ext_skel hash mbstring pcntl pdo_pgsql reflection spl wddx
ctype ext_skel_win32.php iconv mcrypt pcre pdo_sqlite session sqlite3 xml
curl fileinfo imap mysqli pdo pgsql shmop standard xmlreader
date filter interbase mysqlnd pdo_dblib phar simplexml sysvmsg xmlrpc
dba ftp intl oci8 pdo_firebird posix skeleton sysvsem xmlwriter
以添加zip模块为例
[root@localhost php-7.1.6]# /usr/local/php7/bin/php -m |grep zip
//当前没有zip模块
[root@localhost php-7.1.6]#
配置编译zip模块
[root@localhost php-7.1.6]# cd ext/zip/
//生成配置文件
[root@localhost zip]# /usr/local/php7/bin/phpize
Configuring for:
PHP Api Version: 20160303
Zend Module Api No: 20160303
Zend Extension Api No: 320160303
[root@localhost zip]#
//配置
[root@localhost zip]# ./configure --with-php-config=/usr/local/php7/bin/php-config
[root@localhost zip]# ./configure --with-php-config=/usr/local/php7/bin/php-config
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for a sed that does not truncate output... /usr/bin/sed
checking for cc... cc
...中间略...
creating libtool
appending configuration tag "CXX" to libtool
configure: creating ./config.status
config.status: creating config.h
//编译安装
[root@localhost zip]# make && make install
[root@localhost php-7.1.6]# make && make install
/bin/sh /usr/local/src/php-7.1.6/libtool --silent --preserve-dup-deps --mode=compile /usr/local/src/php-7.1.6/meta_ccld -Iext/date/lib -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 -DHAVE_TIMELIB_CONFIG_H=1 -Iext/date/ -I/usr/local/src/php-7.1.6/ext/date/ -DPHP_ATOM_INC -I/usr/local/src/php-7.1.6/include -I/usr/local/src/php-7.1.6/main -I/usr/local/src/php-7.1.6 -I/usr/local/src/php-7.1.6/ext/date/lib -I/usr/include/libxml2 -I/usr/include/freetype2 -I/usr/local/src/php-7.1.6/ext/mbstring/oniguruma -I/usr/local/src/php-7.1.6/ext/mbstring/libmbfl -I/usr/local/src/php-7.1.6/ext/mbstring/libmbfl/mbfl -I/usr/local/mysql/include -I/usr/local/src/php-7.1.6/ext/sqlite3/libsqlite -I/usr/local/src/php-7.1.6/TSRM -I/usr/local/src/php-7.1.6/Zend -D_REENTRANT -I/usr/include -g -O2 -fvisibility=hidden -pthread -DZTS -DZEND_SIGNALS -c /usr/local/src/php-7.1.6/ext/date/php_date.c -o ext/date/php_date.lo
...中间略...

Build complete.
Don't forget to run 'make test'.

Installing shared extensions: /usr/local/php7/lib/php/extensions/no-debug-zts-20160303/
//查看模块
[root@localhost zip]# ls /usr/local/php7/lib/php/extensions/no-debug-zts-20160303/
opcache.so zip.so
//再在/usr/local/php7/etc/php.ini文件最后添加
extension = zip.so
//检查配置及重载
[root@localhost zip]# /usr/local/apache2.4/bin/apachectl -t
Syntax OK
[root@localhost zip]# /usr/local/apache2.4/bin/apachectl graceful
//模块已经添加
[root@localhost zip]# /usr/local/php7/bin/php -m |grep zip
zip

八、扩展
几种限制ip的方法 http://ask.apelearn.com/question/6519
apache 自定义header http://ask.apelearn.com/question/830
apache的keepalive和keepalivetimeout http://ask.apelearn.com/question/556
apache开启压缩 http://ask.apelearn.com/question/5528
apache2.2到2.4配置文件变更 http://ask.apelearn.com/question/7292
apache options参数 http://ask.apelearn.com/question/1051
apache禁止trace或track防止xss http://ask.apelearn.com/question/1045
apache 配置https 支持ssl http://ask.apelearn.com/question/1029
apache rewrite教程 http://coffeelet.blog.163.com/blog/static/13515745320115842755199/ http://www.cnblogs.com/top5/archive/2009/08/12/1544098.html
apache rewrite 出现死循环 http://ask.apelearn.com/question/1043
php错误日志级别参考 http://ask.apelearn.com/question/6973
php开启短标签 http://ask.apelearn.com/question/120
php.ini详解 http://legolas.blog.51cto.com/2682485/493917

转载于:https://blog.51cto.com/13749388/2134822

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值