[php]关闭php版本信息X-Powered-By

查看网页header信息,可以看到PHP的版本,为了安全起见,我们可以关闭这个PHP版本的信息(X-Powered-By)

curl –head “http://blog.54xiake.cn”
HTTP/1.1 200 OK
Server: nginx/1.1.5
Date: Sat, 10 Jun 2017 05:09:36 GMT
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
Vary: Accept-Encoding
X-Powered-By: PHP/5.5.29
X-Pingback: http://blog.54xiake.cn/xmlrpc.php

php.ini中搜索expose_php,默认为On
修改为expose_php = Off

[php]windows上启动两个apache,两个版本php

原理:安装两个apache服务,对应不同的配置文件(http.conf),加载不同的php模块,启用两个不同端口。

apache版本:apache2.4.10
php版本:php5.5.18/php7.1.5

两个httpd.conf配置文件差异部分

httpd.conf

Listen 80
PHPIniDir “F:/SERVER/php5.5.18”
LoadFile “F:/SERVER/php5.5.18/libpq.dll”
LoadFile “F:/SERVER/php5.5.18/libpq.dll”
LoadFile “F:/SERVER/php5.5.18/libeay32.dll”
LoadFile “F:/SERVER/php5.5.18/ssleay32.dll”
LoadModule php5_module “F:/SERVER/php5.5.18/php5apache2_4.dll”

httpd-php7.conf

Listen 81
PHPIniDir “F:/SERVER/php7.1.5”
LoadFile “F:/SERVER/php7.1.5/libpq.dll”
LoadFile “F:/SERVER/php7.1.5/libpq.dll”
LoadFile “F:/SERVER/php7.1.5/libeay32.dll”
LoadFile “F:/SERVER/php7.1.5/ssleay32.dll”
LoadModule php7_module “F:/SERVER/php7.1.5/php7apache2_4.dll”

两个php.ini配置文件差异部分
php5.5.18中php.ini文件
extension_dir = “F:\SERVER\php5.5.18\ext\”

php7.1.5中php.ini文件
extension_dir = “F:\SERVER\php7.1.5\ext”

将需要的扩展打开
extension=php_gd2.dll
extension=php_openssl.dll
extension=php_pdo_mysql.dll
extension=php_pdo_pgsql.dll
extension=php_pgsql.dll
extension=php_soap.dll
服务安装
F:\SERVER\apache2.4.10\bin\httpd.exe -k install -n Apache2.4 -f “F:\SERVER\apache2.4.10\conf\httpd.conf”
F:\SERVER\apache2.4.10\bin\httpd.exe -k install -n Apache2.4-Php7 -f “F:\SERVER\apache2.4.10\conf\httpd-php7.conf”

启动服务即可
net start Apache2.4
net start Apache2.4-Php7

访问
http://localhost
查看server
Server:Apache/2.4.10 (Win64) OpenSSL/1.0.2k PHP/5.5.18
http://localhost:80
查看server
Server:Apache/2.4.10 (Win64) OpenSSL/1.0.2k PHP/7.1.5

[laravel]怎么禁止laravel自动转义HTML标签?

问题:使用ueditor显示数据库中存取的html数据,出现html被转义
解决方法:
Blade输出的时候,使用下面的方式

<script type="text/javascript">
    var ue = UE.getEditor('container');
    ue.ready(function() {
        ue.execCommand('serverparam', '_token', '{{ csrf_token() }}');
        ue.setContent("{!!$content!!}");//{{$content}}这样会被转义
    });
</script>

这样输出的是没有转义的值。

[centos7]yum安装所需软件

个人习惯:公共软件采用yum安装,其他服务(nginx、php、mysql等)采用自己编译安装!

#安装iptables
yum -y install iptables-services
#安装git(用于下载github上的东西)
yum install git
#nodejs安装异常Node.js configure error: No acceptable C compiler found!

yum install gcc-c++

[centos7]关闭默认防火墙启用iptables防火墙

CentOS 7.0默认使用的是firewall作为防火墙,使用iptables必须重新设置一下
1、直接关闭防火墙
systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall开机启动
2、设置 iptables service
yum -y install iptables-services
如果要修改防火墙配置,如增加防火墙端口9200
vim /etc/sysconfig/iptables
增加规则
-A INPUT -p tcp -m state –state NEW -m tcp –dport 9200 -j ACCEPT
保存退出后
systemctl restart iptables.service #重启防火墙使配置生效
systemctl enable iptables.service #设置防火墙开机启动
最后重启系统使设置生效即可。

[centos7]网络配置及开机启动

#配置网络
#!/bin/bash
ifconfig ens33 192.168.1.122 netmask 255.255.255.0
ifconfig ens33 up | down //激活,关闭设备ens33
route add default gw 192.168.1.1
将上述命令保存成脚本
/home/yugang/bin/setnet.sh
vim /etc/rc.local
加入/home/yugang/bin/setnet.sh重启
#配置公共域名解析服务DNS
echo “nameserver 8.8.8.8”>> /etc/resolv.conf
ping外网可通即可

5120 recv() failed (104: Connection reset by peer) while reading response

问题:

图片不显示,nginx报错如下:

[error] 28585#0: *5120 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 124.127.211.125, server: www.54xiake.cn, request: “GET /admin/index.php?act=captcha&2027168701 HTTP/1.1”, upstream: “fastcgi://127.0.0.1:9000”, host: “www.54xiake.cn”

查看

Nov 02 23:50:15.324126 [WARNING] fpm_stdio_child_said(), line 167: child 10866 (pool default) said into stderr: “libpng warning: Application was compiled with png.h from libpng-1.5.12”
Nov 02 23:50:15.324325 [WARNING] fpm_stdio_child_said(), line 167: child 10866 (pool default) said into stderr: “”
Nov 02 23:50:15.324411 [WARNING] fpm_stdio_child_said(), line 167: child 10866 (pool default) said into stderr: “libpng warning: Application is running with png.c from libpng-1.2.49”
Nov 02 23:50:15.324490 [WARNING] fpm_stdio_child_said(), line 167: child 10866 (pool default) said into stderr: “”
Nov 02 23:50:15.324582 [WARNING] fpm_stdio_child_said(), line 167: child 10866 (pool default) said into stderr: “gd-png: fatal libpng error: Incompatible libpng version in application and library”
Nov 02 23:50:16.061598 [NOTICE] fpm_got_signal(), line 48: received SIGCHLD
Nov 02 23:50:16.061754 [WARNING] fpm_children_bury(), line 215: child 10866 (pool default) exited on signal 11 SIGSEGV (core dumped) after 113.343143 seconds from start
Nov 02 23:50:16.062287 [NOTICE] fpm_children_make(), line 352: child 11306 (pool default) started

解决:

rpm -e –nodeps libpng-devel-1.2.49-1.el6_2.x86_64

rpm -e –nodeps libpng-1.2.49-1.el6_2.x86_64

 

 

 

jQuery插件实现瀑布留布局masonry + infinitescroll 图片高度处理

jQuery插件实现瀑布留布局masonry + infinitescroll 。 使用官方的示例代码实际测试发现,当上传到服务器的时候,由于图片下载速度问题,导致图片高度不能被正确识别,从而造成层的重叠。 解决方法就是使用imagesLoaded加载。

var $container = $('#flow');
    $('#flow').imagesLoaded(function(){
        $('#flow').masonry({
            itemSelector: '.box',
            gutterWidth: 20,
            columnWidth: 238
        });
    });

这样解决了第一次加载时候的问题,但是当异步请求之后加载的图片仍然无法正确的获取高度,解决的办法就是先将下载的图片隐藏,等图片下载完毕后再使用masonry渲染。代码如下:

    $('#flow').infinitescroll({
        loading     : {
            msgText        : "<em>正在加载</em>",
            img: "http://www.infinite-scroll.com/loading.gif",
            finishedMsg : "<em>木有了哦...</em>"
        },
        navSelector : "#plist",
        nextSelector: "#plist a",
        itemSelector: ".box",
        pixelsFromNavToBottom: 100,
        animate: true
    },function(newElements) {
     //先隐藏
        var $newElems = $( newElements ).css({ opacity: 0 });
        $newElems.imagesLoaded(function(){
      //图片显示后再进行masonry渲染
          $newElems.animate({ opacity: 1 });
          $container.masonry( 'appended', $newElems, true );
        });
    });

这样就很好的解决了图片加载的问题。

win7(32)-apache2.2.9-mysql5.5.25-php5.3.28开发环境配置

作为一名php程序员,最好还是学会自己搭开发环境,这样才能知道哪些模块是自己需要的,出了问题到底应该怎么解决,今天把自己搭的一个环境整理了一下,大致修改都有了,有兴趣的朋友可以看看。还有一些其他版本的,有时间整理了,在分享吧,呵呵!

配置好的环境已经放到百度网盘

链接: http://pan.baidu.com/s/1o63FtsY 密码: efaw

大致过程如下,希望能帮到一些朋友

win7(32)-apache2.2.9-mysql5.5.25-php5.3.28
将MyServer.zip解压到E盘根目录,自己手动安装服务
一、配置环境
操作系统:win7 32位
php版本:php-5.3.28(32位)
apache版本:httpd-2.2.9(32位)
mysql版本:mysql-5.5.25

二、配置文件修改
httpd.conf修改
ServerRoot “E:/MyServer/apache2.2”
Listen 9090
PHPIniDir “E:/MyServer/php5.3.28”
LoadFile “E:/MyServer/php5.3.28/ssleay32.dll”
LoadFile “E:/MyServer/php5.3.28/libeay32.dll”
LoadFile “E:/MyServer/mysql5.5/lib/libmysql.dll”
LoadModule php5_module “E:/MyServer/php5.3.28/php5apache2_2.dll”
ServerName localhost:9090
DocumentRoot “E:/MyServer/apache2.2/htdocs”
NameVirtualHost *:9090
Include “conf/vhosts/*.conf”

test.conf
<VirtualHost *:9090>
DocumentRoot “E:\MyServer\www\test”
ServerName www.test.com
<Directory />
Options Indexes FollowSymLinks
DirectoryIndex index.html index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
</VirtualHost>

php.ini修改
short_open_tag = On
display_errors = On
extension_dir = “E:\MyServer\php5.3.28\ext\”
extension=php_curl.dll
extension=php_gd2.dll
extension=php_mbstring.dll
extension=php_mysql.dll
extension=php_mysqli.dll
extension=php_pdo_mysql.dll
extension=php_pdo_pgsql.dll
extension=php_pdo_sqlite.dll
extension=php_pgsql.dll
extension=php_soap.dll
extension=php_sockets.dll
extension=php_xmlrpc.dll
extension=php_xsl.dll
[memcache]
extension=php_memcache.dll

my.ini修改
basedir=”E:/MyServer/mysql5.5/”
datadir=”E:/MyServer/mysql5.5/data/”

把E:\MyServer\php5.3.28\php5ts.dll拷贝到E:\MyServer\apache2.2\bin这个目录下面
重启apache

host修改(用于虚拟主机通过域名本地访问)
用文本编辑工具打开C:\Windows\System32\drivers\etc\hosts
本地host增加一行记录
127.0.0.1 www.test.com

数据库
E:\MyServer\mysql5.5\bin>mysqladmin -u root -p password 54xiake.cn
账号root密码54xiake.cn

三、安装|卸载服务(以管理员身份运行cmd.exe)
C:\Windows\System32\cmd.exe

安装|启动服务
E:\MyServer\apache2.2\bin\httpd.exe -k install -n Apache2.2 -f “E:\MyServer\apache2.2\conf\httpd.conf”
net start Apache2.2

E:\MyServer\mysql5.5\bin\mysqld.exe –install MySQL5.5 –defaults-file=”E:\MyServer\mysql5.5\my.ini”
net start MySQL5.5

停止|卸载服务
net stop Apache2.2
sc delete Apache2.2

net stop MySQL5.5
sc delete MySQL5.5
E:\MyServer\mysql5.5\bin\mysqld.exe -remove MySQL5.5

四、问题解决
1、PHP Warning: PHP Startup: Unable to load dynamic library ‘E:\\MyServer\\php5.3.28\\ext\\php_curl.dll’ – \xd5\xd2\xb2\xbb\xb5\xbd\xd6\xb8\xb6\xa8\xb5\xc4\xc4\xa3\xbf\xe9\xa1\xa3\r\n in Unknown on line 0
解决方法:
LoadFile “E:/MyServer/php5.3.28/ssleay32.dll”
LoadFile “E:/MyServer/php5.3.28/libeay32.dll”

五、访问测试
phpinfo
http://www.test.com:9090/p.php
php探针
http://www.test.com:9090/tz.php
系统测试(Piwik: 开放源代码的Web统计软件)
http://www.test.com:9090/piwik
账号:admin 密码:123456

有任何问题,请留言,好了,就这么多了,期待下回分享吧!