月度归档:2017年06月

[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>

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