0%

centos 6.x 都可以按照这个升级php需要的libxml最新版 2.9

##一、安装python2.7##
在安装python之前,我们先来安装在进行python编译时,所需要的的各种依赖软件包,如下:

1
yum -y install xz wget gcc make gdbm-devel openssl-devel sqlite-devel zlib-devel bzip2-devel

依赖软件包安装完毕后,我们来下载pytho2.7源码包,并进行相关的操作,如下:

1
2
3
4
wget http://mirrors.sohu.com/python/2.7.12/Python-2.7.12.tar.xz
tar -xf Python-2.7.12.tar.xz
cd Python-2.7.12
./configure --enable-shared --enable-loadable-sqlite-extensions --with-zlib

配置完毕后,开始进行编译和安装,如下:

1
make && make install

如果安装没有正确错误的话,正确显示如下:

1
python -V

##二、修改系统默认python版本##
centos6系列默认的python版本为python2.6.6,如果我们要修改系统默认的python版本的话,需要进行如下操作。
执行以下命令,对python2.6进行备份,然后为python2.7创建软链接,如下:

1
2
mv /usr/bin/python /usr/bin/python2.6.6
ln -s /usr/local/bin/python2.7 /usr/bin/python

此时,我们可以执行python –V命令,如果出现如下#错误#:

1
python: error while loading shared libraries: libpython2.7.so.1.0: cannot open shared object file: No such file or directory

需要编辑配置文件/etc/ld.so.conf添加新的一行内容/usr/local/lib,保存退出,如下:

1
2
vim /etc/ld.so.conf
/usr/local/lib

ld.so.conf文件配置完毕后,我们需要执行如下命令:

1
2
/sbin/ldconfig
/sbin/ldconfig -v

然后再执行python –V命令,查看python版本:系统默认的python版本已经被修改为python2.7

##三、修改yum相关配置##
python2.7安装完毕,由于版本的原因可能会导致yum命令不能使用,就需要我们进行相关的配置。
我们需要先把python2.6备份起来,然后再对yum的配置文件进行修改。如果不进行这一步操作的话,执行yum命令将会提示你python的版本不对。

1
2
mv /usr/bin/python /usr/bin/python2.6.6
ln -s /usr/local/bin/python2.7 /usr/bin/python

然后再编辑/usr/bin/yum文件,将第一行的#!/usr/bin/python修改为#!/usr/bin/python2.6.6,如下:

1
2
vim /usr/bin/yum
#!/usr/bin/python2.6.6

现在执行yum命令已经不会出现错误信息了。

##四、python3.5安装命令##
在以上三个章节中,我们介绍了python2.7的安装,这章我们把python3.5安装命令贴出来,就不进行详细的介绍了。
安装相关依赖:

1
yum -y install xz wget gcc make gdbm-devel openssl-devel sqlite-devel zlib-devel bzip2-devel

安装python3:

1
2
3
4
5
wget http://mirrors.sohu.com/python/3.5.2/Python-3.5.2.tar.xz
tar -xf Python-3.5.2.tar.xz
cd Python-3.5.2
./configure --enable-shared --enable-loadable-sqlite-extensions --with-zlib
make && make install

修改系统的默认python版本:

1
2
3
4
5
6
7
8
9
10
mv /usr/bin/python /usr/bin/python2.6.6
ln -s /usr/local/bin/python3 /usr/bin/python
vim /etc/ld.so.conf
/usr/local/lib
include ld.so.conf.d/*.conf
/sbin/ldconfig
python –V
修改yum使用的python版本:
vim /usr/bin/yum
#!/usr/bin/python2.6.6

修改 lnmp-1.3/include/.upgrade_php.sh

1
./configure --with-libxml-dir=/root/libxml2-2.9.5/

##参考网址##

http://www.cnblogs.com/hjqjk/p/6866803.html

http://ilanni.blog.51cto.com/526870/1880498

https://gist.github.com/JburkeRSAC/8b946b79cbad72cc2604

1
2
3
4
5
6
7
8
9
10
11
12
#!/bin/bash
#By jburke@wapacklabs.com
cd ~ && apt-get install apache2 vim tmux libxml2-dev make -y
wget http://xmlsoft.org/sources/libxml2-2.9.0.tar.gz
tar -zxvf libxml2-2.9.0.tar.gz
cd libxml2-2.9.0/ && ./configure
make && make install
cd ~ && wget https://downloads.php.net/~stas/php-5.4.45.tar.gz
tar -zxvf php-5.4.45.tar.gz
cd php-5.4.45/ && ./configure --with-libxml-dir=/root/libxml2-2.9.0/
make && make install
php -v

https://www.vultr.com/docs/install-imagemagick-on-centos-6

服务器用的版本为:Version 11.2.0.4.0 ,自行替换版本号。
下载地址:http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html 用户名QQ邮箱。
用到的包:

oracle-instantclient11.2-basic-11.2.0.4.0-1.x86_64.rpm
oracle-instantclient11.2-sqlplus-11.2.0.4.0-1.x86_64.rpm
oracle-instantclient11.2-devel-11.2.0.4.0-1.x86_64.rpm

1.下载以下包,但是需要一个oracle的OTN的注册帐号(免费):
http://download.oracle.com/otn/linux/instantclient/112020/oracle-instantclient11.2-basic-11.2.0.2.0.i386.rpm
http://download.oracle.com/otn/linux/instantclient/112020/oracle-instantclient11.2-sqlplus-11.2.0.2.0.i386.rpm
然后把该两包放到CentOS一个任意目录,比如 ~/tmp,以下过程我都用root帐号/

2.安装该包:

1
2
3
#rpm -ivh ~/tmp/oracle-instantclient11.2-basic-11.2.0.4.0.i386.rpm
#rpm -ivh ~/tmp/oracle-instantclient11.2-sqlplus-11.2.0.4.0.i386.rpm
#vi ~/.bashrc 加入
1
LD_LIBRARY_PATH=/usr/local/lib:/usr/lib/oracle/11.2/client/lib      #对于64位版本可能是client64

3.测试一下:

1
2
#sqlplus /nolog  系统报错
sqlplus: error while loading shared libraries: libsqlplus.so: cannot open shared object file: No such file or directory

4.然后需要:

1
2
3
#vi /etc/ld.so.conf 加入
/usr/lib/oracle/11.2/client/lib/
#/sbin/ldconfig

这样重新运行

1
2
3
4
# sqlplus /nolog    
SQL*Plus: Release 11.2.0.2.0 Production on Tue Nov 8 11:09:58 2011
Copyright (c) 1982, 2010, Oracle. All rights reserved.
SQL>

成功了

5.如需要连接远程oracle,必须配置TNS

1
2
#mkdir -p /usr/lib/oracle/11.2/network/admin
#vi /usr/lib/oracle/11.2/network/admin/tnsnames.ora

加入一个Oracle数据库tns信息

PRODB2 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.3.103.1)(PORT = 1521))
)
(CONNECT_DATA =
(SERVER=DEDICATED)
(SID = PRODB2)
)
)

同时修改环境变量

1
2
3
4
#vi ~/.bashrc
LD_LIBRARY_PATH=/usr/local/lib:/usr/lib/oracle/11.2/client/lib
export ORACLE_HOME=/usr/lib/oracle/11.2
export TNS_ADMIN=/usr/lib/oracle/11.2/network/admin

重启一下环境变量,或者用户logout/login一次

1
#source ~/.bashrc

测试一下

1
2
3
4
5
6
7
#sqlplus myOracleUsername/password@PRODB2
SQL*Plus: Release 11.2.0.2.0 Production on Tue Nov 8 11:11:56 2011
Copyright (c) 1982, 2010, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP and Data Mining options
SQL> select * from tab;

成功。

6.如果其他用户需要使用sqlplus,需要在该用户的~/.bashrc文件中添加上面提到的3行环境变量

感谢:本文完全参考:http://cysky.blog.51cto.com/211942/563294

lnmp 默认用户组是www,需要用www的用户组用户创建文件日志。不然php cli 命令就是以root运行的。

1
2
3
sudo crontab -u www -e #www用户组的crontab
* * * * * php /home/wwwroot/www.xxx.com/artisan schedule:run >> /dev/null 2>&1
`

Let’s encrypt : https://github.com/certbot/certbot

1
git clone https://github.com/certbot/certbot.git

修改python pip 源,解决卡在:

1
Installing Python packages...

在当前用户目录下建立 ~/.pip/pip.conf 文件。内容如下:

1
2
3
4
5
[global]
index-url = http://mirrors.aliyun.com/pypi/simple/

[install]
trusted-host=mirrors.aliyun.com

如果你使用官方脚本,将下列命令中的所有 certbot 替换为 ./certbot-auto 即可。
这里我们使用 certbot certonly –webroot 方式来获取证书,此命令借助已有的 Web 服务实现认证,并生成证书,命令执行过程中不会对网站的正常运行造成影响,以后给证书续期也更平滑。

1
./certbot-auto certonly --webroot -w /home/wwwroot/rails/xxx/public -d www.xxx.com

如果服务器配置正确,命令行参数也无误,那么就能成功完成,提示如下:

1
2
3
4
5
6
- Congratulations! Your certificate and chain have been saved at
/etc/letsencrypt/live/www.xxx.com/fullchain.pem. Your cert will
expire on 2017-04-06. To obtain a new or tweaked version of this
certificate in the future, simply run certbot again. To
non-interactively renew *all* of your certificates, run
"certbot renew"

提示信息告诉你证书存放在 /etc/letsencrypt/live/www.xxx 目录下,过期时间是 2017-04-06,最后还告诉你续期的方法是执行 certbot renew

openresty nginx.conf 配置:

1
2
3
4
5
6
7
8
9
10
listen 80;
listen 443 ssl http2 reuseport;
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
ssl_certificate /etc/letsencrypt/live/www.xxx.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/www.xxx.com/privkey.pem;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; #这里弃用sslv3协议,安全期间
ssl_ciphers EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;

##http 自动跳转 https

1
2
3
4
5
server {  
listen 80;
server_name www.bnlt.org;
return 301 https://$server_name$request_uri;
}

原作者:https://bnlt.org/zai-centos-6-he-nginx-zhong-bu-shu-lets-encrypt-de-ssl-zheng-shu/

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
wget http://caspian.dotconf.net/menu/Software/SendEmail/sendEmail-v1.56.tar.gz
tar -zxvf sendEmail-v1.56.tar.gz
cp -a sendEmail-v1.56/sendEmail /usr/local/bin/
chmod +x /usr/local/bin/sendEmail


wait $!
email_reciver="xxx@qq.com"
#发送者邮箱
email_sender=xxx@163.com
#邮箱用户名
email_username=xxx@163.com
#邮箱密码
#使用qq邮箱进行发送需要注意:首先需要开启:POP3/SMTP服务,其次发送邮件的密码需要使用在开启POP3/SMTP服务时候腾讯提>供的第三方客户端登陆码。
email_password=123qwe
file1_path=${Nginx_logs}${Log_Name}_${before_yesterday}.log.gz
#smtp服务器地址
email_smtphost=smtp.163.com
email_title="日志"-${Log_Name}_${before_yesterday}.log.gz
email_content=${file1_path}

/usr/local/bin/sendEmail -f ${email_sender} -t ${email_reciver} -s ${email_smtphost} -u ${email_title} -xu ${email_username} -xp ${email_password} -m ${email_content} -a ${file1_path} ${file2_path} -o message-charset=utf-8

#注意版本#
##安装openssl##

1
wget https://www.openssl.org/source/openssl-1.0.2j.tar.gz

##安装openresty##

1
2
3
4
5
6
wget https://openresty.org/download/openresty-1.11.2.2.tar.gz
tar -xzvf openresty-1.11.2.2.tar.gz
cd openresty-1.11.2.2
./configure --user=www --group=www --prefix=/usr/local/openresty --with-luajit --without-http_redis2_module --with-http_stub_status_module --with-http_v2_module --with-http_gzip_static_module --with-http_sub_module --with-openssl=/root/openssl-1.0.2j
gmake
gmake install

##设置openresty使用服务启动##

1
vi /etc/init.d/openresty

把下面的内容复制到 openresty 文件里

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#! /bin/sh
# chkconfig: 2345 55 25
# Description: Startup script for nginx webserver on Debian. Place in /etc/init.d and
# run 'update-rc.d -f nginx defaults', or use the appropriate command on your
# distro. For CentOS/Redhat run: 'chkconfig --add nginx'

### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the nginx web server
# Description: starts nginx using start-stop-daemon
### END INIT INFO

# Author: licess
# website: http://www.phpsong.com

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
NAME=nginx
NGINX_BIN=/usr/local/openresty/nginx/sbin/$NAME
CONFIGFILE=/usr/local/openresty/nginx/conf/$NAME.conf
PIDFILE=/usr/local/openresty/nginx/logs/$NAME.pid

case "$1" in
start)
echo -n "Starting $NAME... "

if netstat -tnpl | grep -q nginx;then
echo "$NAME (pid `pidof $NAME`) already running."
exit 1
fi

$NGINX_BIN -c $CONFIGFILE

if [ "$?" != 0 ] ; then
echo " failed"
exit 1
else
echo " done"
fi
;;

stop)
echo -n "Stoping $NAME... "

if ! netstat -tnpl | grep -q nginx; then
echo "$NAME is not running."
exit 1
fi

$NGINX_BIN -s stop

if [ "$?" != 0 ] ; then
echo " failed. Use force-quit"
exit 1
else
echo " done"
fi
;;

status)
if netstat -tnpl | grep -q nginx; then
PID=`pidof nginx`
echo "$NAME (pid $PID) is running..."
else
echo "$NAME is stopped"
exit 0
fi
;;

force-quit)
echo -n "Terminating $NAME... "

if ! netstat -tnpl | grep -q nginx; then
echo "$NAME is not running."
exit 1
fi

kill `pidof $NAME`

if [ "$?" != 0 ] ; then
echo " failed"
exit 1
else
echo " done"
fi
;;

restart)
$0 stop
sleep 1
$0 start
;;

reload)
echo -n "Reload service $NAME... "

if netstat -tnpl | grep -q nginx; then
$NGINX_BIN -s reload
echo " done"
else
echo "$NAME is not running, can't reload."
exit 1
fi
;;

configtest)
echo -n "Test $NAME configure files... "

$NGINX_BIN -t
;;

*)
echo "Usage: $0 {start|stop|force-quit|restart|reload|status|configtest}"
exit 1
;;

esac

保存文件
这样就可以使用服务的方式来操作 openresty
##把原来nginx的配置文件复 openresty 目录下##

1
2
cp /usr/local/nginx/conf/*.conf /usr/local/openresty/nginx/conf/
cp -r /usr/local/nginx/conf/vhost /usr/local/openresty/nginx/conf

请根据自己的服务器情况来,别覆盖错了。
##修改配置文件##

1
vi /usr/local/openresty/nginx/conf/nginx.conf

##修改pid的路径为##

1
pid   /usr/local/openresty/nginx/logs/nginx.pid;

##停止原来的nginx服务器在启动openresty##

1
2
service nginx stop
service openresty start

##openresty 服务器管理命令##

1
2
3
service openresty start //启动openresty
service openresty stop //停止openresty
service openresty restart //重启openresty

结束。

版权:https://www.phpsong.com/2936.html

封单个IP

1
iptables -I INPUT -s 123.60.2.200 -j DROP

封IP段

1
iptables -I INPUT -s 211.1.0.0/16 -j DROP

封整个段

1
iptables -I INPUT -s 211.0.0.0/8 -j DROP

保存iptables

1
service iptables save

重启防火墙

1
service iptables restart

清除原有规则

1
2
3
4
5
6
iptables -F 清除预设表filter中的所有规则链的规则
iptables -X 清除预设表filter中使用者自定链中的规则

备份
```bash
cp /etc/sysconfig/iptables /var/