所有由54xiake发布的文章

[centos7]postgresql安装、初始化密码、允许远程连接设置

tar xvzf postgresql-9.6.3.tar.gz
cd postgresql-9.6.3
./configure –prefix=/usr/local/pgsql
make
make install
adduser postgres
mkdir /usr/local/pgsql/data
chown postgres /usr/local/pgsql/data
su – postgres
/usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data
#用户postgres启动
/usr/local/pgsql/bin/postgres -D /usr/local/pgsql/data >logfile 2>&1 &
/usr/local/pgsql/bin/createdb test
/usr/local/pgsql/bin/psql test
#设置初始化密码
bin/psql postgres
\password postgres
#密码登录
./psql -h localhost -U postgres -W
#允许外网ip访问
防火墙增加5432端口访问
vim /etc/sysconfig/iptables
-A INPUT -p tcp -m state –state NEW -m tcp –dport 5432 -j ACCEPT
重启iptables
vim postgresql.conf
listen_addresses = ‘*’
vim pg_hba.conf
增加一行规则
host all all 0.0.0.0/0 trust
#查看版本
select VERSION();
PostgreSQL 9.6.3 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-11), 64-bit

[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 );
        });
    });

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