浏览模式: 标准 | 列表 全部文章

在Mac系统下安装使用composer

关于PHP composer:

  • composer是 PHP 用来管理依赖(dependency)关系的工具。就像是IOS开发时用cocoapods管理第三方依赖库。
mac下开发环境安装方法:
 
A 安装brew
  • /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)”
  • brew update
 
B 安装composer
  • brew install composer
  • composer self-update
 
C 使用composer安装所需的php包
  • 进入https://packagist.org/搜索需要的依赖包,比如smarty然后复制安装命令
 
D 用终端进入需要安装的目录,然后执行安装命令即可
  • composer require smarty/smarty
 
E 如果使用composer更新包速度慢,则更换源
  • composer config -g repo.packagist composer https://packagist.phpcomposer.com

[转]CentOS 6、7下pptp vpn一键安装脚本

 https://blog.linuxeye.cn/412.html

  • wget http://mirrors.linuxeye.com/scripts/vpn_centos.sh
  • chmod +x ./vpn_centos.sh
  • ./vpn_centos.sh

#!/bin/bash

#

# Author:  yeho <lj2007331 AT gmail.com>

# Blog:  //blog.linuxeye.com

#

# Installs a PPTP VPN-only system for CentOS

# Check if user is root

[ $(id -u) != "0" ] && { echo -e "\033[31mError: You must be root to run this script\033[0m"; exit 1; }

export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

clear

printf "

#######################################################################

#    LNMP/LAMP/LANMP for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+    #

#            Installs a PPTP VPN-only system for CentOS               #

# For more information please visit //blog.linuxeye.com/31.html  #

#######################################################################

"

[ ! -e '/usr/bin/curl' ] && yum -y install curl

VPN_IP=`curl ipv4.icanhazip.com`

VPN_USER="linuxeye"

VPN_PASS="linuxeye"

VPN_LOCAL="192.168.0.150"

VPN_REMOTE="192.168.0.151-200"

while :; do echo

    read -p "Please input username: " VPN_USER

    [ -n "$VPN_USER" ] && break

done

while :; do echo

    read -p "Please input password: " VPN_PASS

    [ -n "$VPN_PASS" ] && break

done

clear

if [ -f /etc/redhat-release -a -n "`grep ' 7\.' /etc/redhat-release`" ];then

    #CentOS_REL=7

    if [ ! -e /etc/yum.repos.d/epel.repo ];then

        cat > /etc/yum.repos.d/epel.repo << EOF

[epel]

name=Extra Packages for Enterprise Linux 7 - \$basearch

#baseurl=http://download.fedoraproject.org/pub/epel/7/\$basearch

mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=\$basearch

failovermethod=priority

enabled=1

gpgcheck=0

EOF

    fi

    for Package in wget make openssl gcc-c++ ppp pptpd iptables iptables-services

    do

        yum -y install $Package

    done

    echo 'net.ipv4.ip_forward = 1' >> /etc/sysctl.conf

elif [ -f /etc/redhat-release -a -n "`grep ' 6\.' /etc/redhat-release`" ];then

    #CentOS_REL=6

    for Package in wget make openssl gcc-c++ iptables ppp

    do

        yum -y install $Package

    done

    sed -i 's@net.ipv4.ip_forward.*@net.ipv4.ip_forward = 1@g' /etc/sysctl.conf

    rpm -Uvh http://poptop.sourceforge.net/yum/stable/rhel6/pptp-release-current.noarch.rpm

    yum -y install pptpd

else

    echo -e "\033[31mDoes not support this OS, Please contact the author! \033[0m"

    exit 1

fi

echo "1" > /proc/sys/net/ipv4/ip_forward

sysctl -p /etc/sysctl.conf

[ -z "`grep '^localip' /etc/pptpd.conf`" ] && echo "localip $VPN_LOCAL" >> /etc/pptpd.conf # Local IP address of your VPN server

[ -z "`grep '^remoteip' /etc/pptpd.conf`" ] && echo "remoteip $VPN_REMOTE" >> /etc/pptpd.conf # Scope for your home network

if [ -z "`grep '^ms-dns' /etc/ppp/options.pptpd`" ];then

     cat >> /etc/ppp/options.pptpd << EOF

ms-dns 223.5.5.5 # Aliyun DNS Primary

ms-dns 114.114.114.114 # 114 DNS Primary

ms-dns 8.8.8.8 # Google DNS Primary

ms-dns 209.244.0.3 # Level3 Primary

ms-dns 208.67.222.222 # OpenDNS Primary

EOF

fi

echo "$VPN_USER pptpd $VPN_PASS *" >> /etc/ppp/chap-secrets

ETH=`route | grep default | awk '{print $NF}'`

[ -z "`grep '1723 -j ACCEPT' /etc/sysconfig/iptables`" ] && iptables -I INPUT 4 -p tcp -m state --state NEW -m tcp --dport 1723 -j ACCEPT

[ -z "`grep 'gre -j ACCEPT' /etc/sysconfig/iptables`" ] && iptables -I INPUT 5 -p gre -j ACCEPT

iptables -t nat -A POSTROUTING -o $ETH -j MASQUERADE

iptables -I FORWARD -p tcp --syn -i ppp+ -j TCPMSS --set-mss 1356

service iptables save

sed -i 's@^-A INPUT -j REJECT --reject-with icmp-host-prohibited@#-A INPUT -j REJECT --reject-with icmp-host-prohibited@' /etc/sysconfig/iptables

sed -i 's@^-A FORWARD -j REJECT --reject-with icmp-host-prohibited@#-A FORWARD -j REJECT --reject-with icmp-host-prohibited@' /etc/sysconfig/iptables

service iptables restart

chkconfig iptables on

service pptpd restart

chkconfig pptpd on

clear

echo -e "You can now connect to your VPN via your external IP \033[32m${VPN_IP}\033[0m"

echo -e "Username: \033[32m${VPN_USER}\033[0m"

echo -e "Password: \033[32m${VPN_PASS}\033[0m"

CentOS增加SMB服务

这篇日志被加密了,请输入密码后查看。

Windows版Digital Photo Professional 4.8.3...

 digital photo professional是佳能单反的配套软件,不过光盘早就扔了,只能去官方网站下载了。截止18年10月20日最新的版本为4.8.30。

页面地址:http://support-cn.canon-asia.com/contents/CN/ZH/0200550505.html

下载的话需要输入序列号,序列号就在相机底部的一排数字。

我拿到的下载地址是:http://gdlp01.c-wss.com/gds/5/0200005505/01/dppw4.8.30-installer.zip

 

Tags: digital photo professional

自用树莓派作为全屏网页展示机的配置

这篇日志被加密了,请输入密码后查看。

Apache服务器利用.htaccess隐藏网页文件扩展名

在网站根目录建立或上传.htaccess文件,内容如下:

  1. <IfModule mod_rewrite.c> 
  2. Options +FollowSymlinks 
  3. RewriteEngine On 
  4. RewriteBase / 
  5. RewriteCond %{REQUEST_FILENAME} !-f 
  6. RewriteCond %{REQUEST_FILENAME} !-d 
  7. RewriteCond %{REQUEST_FILENAME}.php -f 
  8. RewriteRule ^(.+)$ /$1.php [L,QSA] 
  9. </IfModule> 

解决80端口被封LNMP无法安装Let's Encrypt SSL证书

手头有一个国内的固定IP,80端口被封,内网中配置了一台运行lnmp的linux网站服务器,通过路由器端口映射功能,可以访问到443端口(https模式)。

lnmp自带的脚本中就可以增加Let's Encrypt SSL证书,但是该证书需要外网访问到域名才可以签发,但实际上80端口被封杀,压根无法访问到域名。通过google搜索发现也可以通过DNS验证模式来给需要上SSL的域名签名,但是毕竟繁琐。

时刻片刻,我想到了一个很有意思的方法——既然只是80端口被封,那么其它端口是可以正常访问到内网的网站服务器的(路由器上做端口映射)。

准备如下(以下数据都按实际修改):

1、国内的固定IP为1.1.1.1

2、国外买一台便宜的Linux服务器,安装好lnmp,获得固定IP为2.2.2.2

3、需要上SSL的域名为is36.com的子域名ssl.is36.com,is36.com域名放在dnspod.cn解析的,增加3个解析记录如下:

  • ssl.is36.com的A记录默认解析到1.1.1.1
  • ssl.is36.com的A记录国外线路解析到2.2.2.2
  • sslfd.is36.com的A记录默认解析到1.1.1.1

4、在国内的路由器上设置443端口映射到内网服务器443端口,888端口映射到内网服务器80端口.

5、在国内的服务器上新增sslfd.is36.com网站,指定网站目录为ssl.is36.com目录。

6、在国外的服务器上/usr/local/nginx/conf/vhost目录下新增一个sslfd.is36.com.conf文件,内容如下:

  • server
  • {
  •     listen          80;
  •     server_name     ssl.is36.com;
  •     location / {
  •         proxy_pass          http://sslfd.is36.com:888/;
  •         proxy_redirect      off;
  •         proxy_set_header    X-Real-IP       $remote_addr;
  •         proxy_set_header    X-Forwarded-For $proxy_add_x_forwarded_for;
  •         }
  • }

7、保存好以上配置信息后,执行service nginx reload使生效。

8、回到国内服务器上,执行新增网站ssl.is36.com,指定ssl.is36.com目录,指定增加Let's Encrypt证书,最后就会部署成功。

9、尝试访问https://ssl.is36.com,成功!

总结:本文的解决思路就是通过dnspod国内外分区域访问的方法,让Let's Encrypt的验证服务器(国外线路)访问到我们的国外服务器,国外服务器接收验证请求后利用nginx反向代理获取http://sslfd.is36.com:888/的数据,而http://sslfd.is36.com:888/网站的数据跟ssl.is36.com的网站数据是同一个目录的,自然就会让验证服务器觉得验证成功了!

[php]private public protected 三者之间关系

public 权限是最大的,可以内部调用,实例调用等;

private 私有类型,只有在本类中使用

protected 受保护类型,用于本类和继承类调用

  1. <?  
  2. //父类  
  3. class father{  
  4. public function a(){  
  5. echo "function a";   
  6. }  
  7. private function b(){  
  8. echo "function b";   
  9. }  
  10. protected function c(){  
  11. echo "function c";   
  12. }  
  13. }  
  14. //子类  
  15. class child extends father{  
  16. function d(){   
  17. parent::a();//调用父类的a方法  
  18. }  
  19. function e(){   
  20. parent::c(); //调用父类的c方法  
  21. }   
  22. function f(){   
  23. parent::b(); //调用父类的b方法  
  24. }   
  25.   
  26. }  
  27. $father=new father();  
  28. $father->a();  
  29. $father->b(); //显示错误 外部无法调用私有的方法 Call to protected method father::b()   
  30. $father->c(); //显示错误 外部无法调用受保护的方法Call to private method father::c()   
  31.   
  32. $chlid=new child();  
  33. $chlid->d();  
  34. $chlid->e();//可以调用受保护的方法 
  35. $chlid->f();//显示错误 无法调用父类private的方法 Call to private method father::b()   
  36. ?>