CentOS + Apache2.4 + PHP5.6 FPM报503错误

Service Unavailable 503错误,很可能的原因是服务器过载。

错误提示:

The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.

服务器使用Apache2.4,fpm方式加载PHP,因此排查解决过程如下。

1. 查看PHP-FPM日志
#tail -f /alidata/server/php56/var/log/php-fpm.log
WARNING: [pool www] server reached pm.max_children setting (5), consider raising it

2. 修改PHP-FPM配置
#vi /alidata/server/php56/etc/php-fpm.conf
pm.max_children = 5
​修改为
pm.max_children = 100

计算依据参考:https://blog.csdn.net/solmyr_biti/article/details/53955141
pm.max_children = Total RAM dedicated to the web server / Max child process size – in my case it was 85MB
The server has 8GB of RAM, so:
pm.max_children = 6144MB / 85MB = 72

CentOS Requires: libc.so.6(GLIBC_2.17)(64bit) 升级glibc到2.17

1、原先的系统glibc库的版本是2.12,需要升级到2.17版本。

下载地址:

http://ftp.gnu.org/gnu/glibc/glibc-2.17.tar.gz
这里可以选择你所需要的版本。

2、安装部署

[root@kafzook1 common]# tar -xf glibc-2.17.tar.gz
[root@kafzook1 common]# cd glibc-2.17
[root@kafzook1 glibc-2.17]# mkdir build; cd build
[root@kafzook1 build]# ../configure –prefix=/usr –disable-profile –enable-add-ons –with-headers=/usr/include –with-binutils=/usr/bin
[root@kafzook1 build]# make -j 8
[root@kafzook1 build]# make install
[root@kafzook1 common]# strings /lib64/libc.so.6 | grep GLIBC
会看到下面的结果
GLIBC_2.2.5
GLIBC_2.2.6
GLIBC_2.3
GLIBC_2.3.2
GLIBC_2.3.3
GLIBC_2.3.4
GLIBC_2.4
GLIBC_2.5
GLIBC_2.6
GLIBC_2.7
GLIBC_2.8
GLIBC_2.9
GLIBC_2.10
GLIBC_2.11
GLIBC_2.12
GLIBC_2.13
GLIBC_2.14
GLIBC_2.15
GLIBC_2.16
GLIBC_2.17
GLIBC_PRIVATE

我们可以看到部署成功后的glibc的版本为2.17

问题总结:

在上面安装的过程中我们可能会遇到下面的问题

1. Requires: libc.so.6(GLIBC_2.17)(64bit),升级glibc后,通过strings /lib64/libc.so.6 | grep GLIBC可查到GLIBC_2.17,但还是报错。

解决办法:通过yum clean all,yum makecache,yum update解决了

2. 百度了一下这个问题,说是这个变量后面有一个冒号“:”,我们打印一下这个变量查看一下果然有一个冒号。
他人博客地址:glibc问题解决方案

解决方案:找到这一环境变量,把后面的冒号+$LD_LIBRARY_PATH去掉,然后source一下。

我们看到后面的冒号已经没有了。

———————
作者:wyl9527
来源:CSDN
原文:https://blog.csdn.net/wyl9527/article/details/78256066
版权声明:本文为博主原创文章,转载请附上博文链接!

CentOS6.5 下Nginx 的安装与配置

原文链接:https://www.cnblogs.com/DanBrown/p/8005184.html

1.安装必须环境

nginx的编译需要c++,同时prce(重定向支持)和openssl(https支持)也需要安装。

请顺序安装依赖

1  yum install gcc-c++  
2  yum -y install pcre*  
3  yum -y install openssl*

2.,下载nginx-1.9.9.tar.gz,可放在 /usr/local/ 目录下   ps:我这里使用的老本你可以尝试新版

1  [root@admin ~]# cd /usr/local/  
2  [root@admin local]# wget http://nginx.org/download/nginx-1.9.9.tar.gz

3.解压及编译

1 [root@admin local]# tar -zxvf nginx-1.9.9.tar.gz

4.进入nginx目录

1 [root@admin local]# cd nginx-1.9.9

5.设置安装目录为 /usr/local/nginx

1 [root@admin nginx-1.9.9]# ./configure --prefix=/usr/local/nginx

开始编译安装

1  [root@admin nginx-1.9.9]# make  
2  [root@admin nginx-1.9.9]# make install

我这里是阿里服务器在(控制台)实例中配置一下端口,,本机中再开放一下80端口(不知道请查我的博客中有讲过如何开放指定端口);

 

 

 

启动nginx服务

进入安装目录 /usr/local/nginx

1 [root@admin ~]# cd /usr/local/nginx  
2 [root@admin sbin]# ./nginx

查看进程,可以看到nginx的master和worker进程

1     [root@admin sbin]# ps -ef | grep nginx  
2     root     32150     1  0 13:28 ?        00:00:00 nginx: master process ./nginx  
3     nobody   32151 32150  0 13:28 ?        00:00:00 nginx: worker process  
4     root     32154 28494  0 13:28 pts/1    00:00:00 grep nginx

可以通过访问ip:80测试,看到页面这样的提示就说明安装成功

重启的命令:

1 [root@admin sbin]# ./nginx -s reload

最后可以配置一下命令 添加nginx为系统服务(service nginx start/stop/restart)

1、在/etc/init.d/目录下编写脚本,新建名为nginx的文件然后把脚本代码粘贴进去 注意:配置 文件位置我的在usr/local/下若果不是这个路径你需要修改)

脚本代码

然后执行

2 [root@example ~]# chmod 755 /etc/init.d/nginx
3 [root@example ~]# chkconfig --add nginx

nginx启动、停止、无间断服务重启

1 [root@example ~]# service nginx start
2 
3 [root@example ~]# service nginx stop
4 
5 [root@example ~]# service nginx reload

好了蕾丝(@.@)

注补充:

  停止服务  查进程号之后 kill -9 进程号 即可.

CentOS6.5安装Zookeeper

原文地址:https://www.cnblogs.com/duenboa/articles/6665169.html

1. 下载安装文件zookeeper-3.4.6.tar.gz
2. 还是copy到虚拟机的centos系统桌面
3. 新建/usr/loca/zookeeper文件夹
[root@localhost ~]# mkdir -pv /usr/local/zookeeper
4.拷贝文件到指定文件夹
[root@localhost ~]# cd /root/Desktop/
[root@localhost ~]# cp ./zookeeper-3.4.6.tar.gz /usr/local/zookeeper
5. 解压
[root@localhost ~]# tar -zxvf jdk-8u121-linux-x64.tar.gz
6. 配置环境变量
[root@localhost ~]#cd /etc/
[root@localhost ~]#cp ./profile ./profile.bak — 把文件备份一下
[root@localhost ~]#vi /etc/profile — 编辑此配置文件
在文件末尾添加此段内容: — 开始和–中间的一段.(注意,尽量保持环境变量名全大写,下划线隔开. 保持规范)
— 开始
export ZOOKEEPER_INSTALL=/usr/local/zookeeper/zookeeper-3.4.6/
export PATH=$PATH:$ZOOKEEPER_INSTALL/bin
— 结束
7. 配置文件修改
[root@localhost zookeeper-3.4.6]# cd /usr/local/zookeeper/zookeeper-3.4.6/conf/ — 进入文件所在路径
[root@localhost conf]# cp zoo_sample.cfg zoo.cfg — 将zoo.sample.cfg拷贝出一份zoo.cfg出来. 文件名强制
8. 文件内容如下:
[root@localhost conf]# vi zoo.cfg — 按i进入编辑模式. 修改完成之后, esc退出编辑模式, 大写字母Z双击即可保存.
# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial
# synchronization phase can take
initLimit=10
# The number of ticks that can pass between
# sending a request and getting an acknowledgement
syncLimit=5
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just
# example sakes.
dataDir=/tmp/zookeeper — 这里要设置一下文件路径 路径必须存在,不存在的话就新建一个呗
dataLogDir=/tmp/zookeeper/log — 日志路径 路径必须存在,不存在的话就新建一个呗
# the port at which the clients will connect
clientPort=2181 — 如果是多机器的话,在clientPort处添加服务器的ip
# the maximum number of client connections.
# increase this if you need to handle more clients
#maxClientCnxns=60
#
# Be sure to read the maintenance section of the
# administrator guide before turning on autopurge.
#
# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
#
# The number of snapshots to retain in dataDir
#autopurge.snapRetainCount=3
# Purge task interval in hours
# Set to “0” to disable auto purge feature
#autopurge.purgeInterval=1
修改完之后 通过 > # cat zoo.cfg 查看.
9. 开启服务,关闭服务, 查看
[root@localhost bin]# cd /usr/local/zookeeper/zookeeper.3.4.6/bin/
[root@localhost bin]# ./zkServer.sh stop — 停止服务
JMX enabled by default
Using config: /usr/local/zookeeper/zookeeper-3.4.6/bin/../conf/zoo.cfg
Stopping zookeeper … STOPPED
[root@localhost bin]# ./zkServer.sh start — 开启服务
JMX enabled by default
Using config: /usr/local/zookeeper/zookeeper-3.4.6/bin/../conf/zoo.cfg
Starting zookeeper … STARTED
[root@localhost bin]# ./zkServer.sh status — 查看状态
JMX enabled by default
Using config: /usr/local/zookeeper/zookeeper-3.4.6/bin/../conf/zoo.cfg
Mode: standalone
[root@localhost bin]#
[root@localhost bin]# ./zkCli.sh — 客户端启动, 可以查看启动状态和日志
Connecting to localhost:2181
2017-03-08 06:15:26,918 [myid:] – INFO [main:Environment@100] – Client environment:zookeeper.version=3.4.6-1569965, built on 02/20/2014 09:09 GMT
2017-03-08 06:15:26,923 [myid:] – INFO [main:Environment@100] – Client environment:host.name=localhost
2017-03-08 06:15:26,923 [myid:] – INFO [main:Environment@100] – Client environment:java.version=1.8.0_121
2017-03-08 06:15:26,925 [myid:] – INFO [main:Environment@100] – Client environment:java.vendor=Oracle Corporation
2017-03-08 06:15:26,926 [myid:] – INFO [main:Environment@100] – Client environment:java.home=/usr/local/java/jdk1.8.0_121/jre
2017-03-08 06:15:26,926 [myid:] – INFO [main:Environment@100] – Client environment:java.class.path=/usr/local/zookeeper/zookeeper-3.4.6/bin/../build/classes:/usr/local/zookeeper/zookeeper-3.4.6/bin/../build/lib/*.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../lib/slf4j-log4j12-1.6.1.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../lib/slf4j-api-1.6.1.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../lib/netty-3.7.0.Final.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../lib/log4j-1.2.16.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../lib/jline-0.9.94.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../zookeeper-3.4.6.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../src/java/lib/*.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../conf:.:/usr/local/java/jdk1.8.0_121/lib/dt.jar:/usr/local/java/jdk1.8.0_121/lib/tools.jar:/usr/local/java/jdk1.8.0_121/jre/lib:.:/usr/local/java/jdk1.8.0_121/lib/dt.jar:/usr/local/java/jdk1.8.0_121/lib/tools.jar:/usr/local/java/jdk1.8.0_121/jre/lib:.:/usr/local/java/jdk1.8.0_121/lib/dt.jar:/usr/local/java/jdk1.8.0_121/lib/tools.jar:/usr/local/java/jdk1.8.0_121/jre/lib:
2017-03-08 06:15:26,926 [myid:] – INFO [main:Environment@100] – Client environment:java.library.path=/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
2017-03-08 06:15:26,926 [myid:] – INFO [main:Environment@100] – Client environment:java.io.tmpdir=/tmp
2017-03-08 06:15:26,926 [myid:] – INFO [main:Environment@100] – Client environment:java.compiler=<NA>
2017-03-08 06:15:26,930 [myid:] – INFO [main:Environment@100] – Client environment:os.name=Linux
2017-03-08 06:15:26,930 [myid:] – INFO [main:Environment@100] – Client environment:os.arch=amd64
2017-03-08 06:15:26,930 [myid:] – INFO [main:Environment@100] – Client environment:os.version=2.6.32-431.el6.x86_64
2017-03-08 06:15:26,931 [myid:] – INFO [main:Environment@100] – Client environment:user.name=root
2017-03-08 06:15:26,931 [myid:] – INFO [main:Environment@100] – Client environment:user.home=/root
2017-03-08 06:15:26,931 [myid:] – INFO [main:Environment@100] – Client environment:user.dir=/usr/local/zookeeper/zookeeper-3.4.6/bin
2017-03-08 06:15:26,940 [myid:] – INFO [main:ZooKeeper@438] – Initiating client connection, connectString=localhost:2181 sessionTimeout=30000 watcher=org.apache.zookeeper.ZooKeeperMain$MyWatcher@277050dc
Welcome to ZooKeeper!
2017-03-08 06:15:27,039 [myid:] – INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@975] – Opening socket connection to server localhost/0:0:0:0:0:0:0:1:2181. Will not attempt to authenticate using SASL (unknown error)
JLine support is enabled
2017-03-08 06:15:27,290 [myid:] – INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@852] – Socket connection established to localhost/0:0:0:0:0:0:0:1:2181, initiating session
[zk: localhost:2181(CONNECTING) 0] 2017-03-08 06:15:27,445 [myid:] – INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1235] – Session establishment complete on server localhost/0:0:0:0:0:0:0:1:2181, sessionid = 0x15aae45f1330000, negotiated timeout = 30000
WATCHER::
WatchedEvent state:SyncConnected type:None path:null
root@localhost bin]# ps -ef | grep zookeeper — 查看zookeeper的服务进程. 看样子还是挺嗨的.
root 9779 9774 0 05:26 pts/0 00:00:09 /usr/local/java/jdk1.8.0_121/bin/java -Dzookeeper.log.dir=. -Dzookeeper.root.logger=INFO,CONSOLE -cp /usr/local/zookeeper/zookeeper-3.4.6/bin/../build/classes:/usr/local/zookeeper/zookeeper-3.4.6/bin/../build/lib/*.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../lib/slf4j-log4j12-1.6.1.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../lib/slf4j-api-1.6.1.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../lib/netty-3.7.0.Final.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../lib/log4j-1.2.16.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../lib/jline-0.9.94.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../zookeeper-3.4.6.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../src/java/lib/*.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../conf:.:/usr/local/java/jdk1.8.0_121/lib/dt.jar:/usr/local/java/jdk1.8.0_121/lib/tools.jar:/usr/local/java/jdk1.8.0_121/jre/lib:.:/usr/local/java/jdk1.8.0_121/lib/dt.jar:/usr/local/java/jdk1.8.0_121/lib/tools.jar:/usr/local/java/jdk1.8.0_121/jre/lib:.:/usr/local/java/jdk1.8.0_121/lib/dt.jar:/usr/local/java/jdk1.8.0_121/lib/tools.jar:/usr/local/java/jdk1.8.0_121/jre/lib: org.apache.zookeeper.ZooKeeperMain
root 10188 10183 0 06:14 pts/0 00:00:00 /usr/local/java/jdk1.8.0_121/bin/java -Dzookeeper.log.dir=. -Dzookeeper.root.logger=INFO,CONSOLE -cp /usr/local/zookeeper/zookeeper-3.4.6/bin/../build/classes:/usr/local/zookeeper/zookeeper-3.4.6/bin/../build/lib/*.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../lib/slf4j-log4j12-1.6.1.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../lib/slf4j-api-1.6.1.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../lib/netty-3.7.0.Final.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../lib/log4j-1.2.16.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../lib/jline-0.9.94.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../zookeeper-3.4.6.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../src/java/lib/*.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../conf:.:/usr/local/java/jdk1.8.0_121/lib/dt.jar:/usr/local/java/jdk1.8.0_121/lib/tools.jar:/usr/local/java/jdk1.8.0_121/jre/lib:.:/usr/local/java/jdk1.8.0_121/lib/dt.jar:/usr/local/java/jdk1.8.0_121/lib/tools.jar:/usr/local/java/jdk1.8.0_121/jre/lib:.:/usr/local/java/jdk1.8.0_121/lib/dt.jar:/usr/local/java/jdk1.8.0_121/lib/tools.jar:/usr/local/java/jdk1.8.0_121/jre/lib: org.apache.zookeeper.ZooKeeperMain
root 10230 1 0 06:15 pts/1 00:00:01 /usr/local/java/jdk1.8.0_121/bin/java -Dzookeeper.log.dir=. -Dzookeeper.root.logger=INFO,CONSOLE -cp /usr/local/zookeeper/zookeeper-3.4.6/bin/../build/classes:/usr/local/zookeeper/zookeeper-3.4.6/bin/../build/lib/*.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../lib/slf4j-log4j12-1.6.1.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../lib/slf4j-api-1.6.1.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../lib/netty-3.7.0.Final.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../lib/log4j-1.2.16.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../lib/jline-0.9.94.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../zookeeper-3.4.6.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../src/java/lib/*.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../conf:.:/usr/local/java/jdk1.8.0_121/lib/dt.jar:/usr/local/java/jdk1.8.0_121/lib/tools.jar:/usr/local/java/jdk1.8.0_121/jre/lib: -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.local.only=false org.apache.zookeeper.server.quorum.QuorumPeerMain /usr/local/zookeeper/zookeeper-3.4.6/bin/../conf/zoo.cfg
root 10282 10277 0 06:15 pts/0 00:00:01 /usr/local/java/jdk1.8.0_121/bin/java -Dzookeeper.log.dir=. -Dzookeeper.root.logger=INFO,CONSOLE -cp /usr/local/zookeeper/zookeeper-3.4.6/bin/../build/classes:/usr/local/zookeeper/zookeeper-3.4.6/bin/../build/lib/*.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../lib/slf4j-log4j12-1.6.1.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../lib/slf4j-api-1.6.1.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../lib/netty-3.7.0.Final.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../lib/log4j-1.2.16.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../lib/jline-0.9.94.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../zookeeper-3.4.6.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../src/java/lib/*.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../conf:.:/usr/local/java/jdk1.8.0_121/lib/dt.jar:/usr/local/java/jdk1.8.0_121/lib/tools.jar:/usr/local/java/jdk1.8.0_121/jre/lib:.:/usr/local/java/jdk1.8.0_121/lib/dt.jar:/usr/local/java/jdk1.8.0_121/lib/tools.jar:/usr/local/java/jdk1.8.0_121/jre/lib:.:/usr/local/java/jdk1.8.0_121/lib/dt.jar:/usr/local/java/jdk1.8.0_121/lib/tools.jar:/usr/local/java/jdk1.8.0_121/jre/lib: org.apache.zookeeper.ZooKeeperMain
root 10314 8885 0 06:18 pts/0 00:00:00 grep zookeeper
[root@localhost bin]#
10 到此, zookeeper的单机版安装完成.

Linux免密码登录设置

原文地址:https://blog.csdn.net/furzoom/article/details/79139570

假设要登录的机器为192.168.1.100,当前登录的机器为192.168.1.101。

首先在101的机器上生成密钥(如果已经生成可以跳过):

$ ssh-keygen -t rsa

一路回车即可。

然后在将生成的公钥复制到机器100上的~/.ssh/authorized_keys中,使用如下命令:

$ ssh-copy-id -i ~/.ssh/id_rsa.pub root@192.168.1.100

root为需要登录到机器100上的身份,需要替换成需要的用户名。

最后,测试免密码登录:

$ ssh root@192.168.1.100

(完)

Centos6.6下编译安装最新apache

转载地址:http://www.linuxprobe.com/centos66-make-apache.html
安装编译环境
安装开发工具组
yum groupinstall 'Development tools'
仅安装需要的工具

因我的虚拟机是mini安装,配置aliyun的yum源家里小水管下载慢,就只装个gcc好了。

yum install gcc
下载源码包
下载最新版httpd

下载地址:http://httpd.apache.org/download.cgi#apache24

写此篇文章时最新版本为:httpd-2.4.27

在Centos6.6下编译安装最新apache在Centos6.6下编译安装最新apache

如果默认镜像下载太慢的话,可以在红框内选择其他国内镜像。

执行如下命令将源码包下载至Linux中并解压

wget https://mirrors.tuna.tsinghua.edu.cn/apache//httpd/httpd-2.4.27.tar.gz
tar -xf httpd-2.4.27.tar.gz
下载apr及apr-util

apr是Apache Portable Runtime的缩写,中文译为Apache可移植运行环境,是httpd所必须的,apr-util同理。

apr及apr-util下载地址:http://apr.apache.org/download.cgi

执行如下命令:

wget https://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-1.6.2.tar.gz
wget https://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-util-1.6.0.tar.gz
tar -xf apr-1.6.2.tar.gz
tar -xf apr-util-1.6.0.tar.gz

着手编译

首先编译apr
cd apr-1.6.2
./configure --prefix=/usr/local/apr  //指定安装位置
make && make install
编译apr-util
cd apr-util-1.6.0
./configure --with-apr=/usr/local/apr/ --prefix=/usr/local/apr-util  //指定apr所在目录及apr-util安装目录
make && make install

在这里会报一个错,如下所示

xml/apr_xml.c:35:19: error: expat.h: No such file or directory   //注意这一行,提示没有expat.h这个头文件
xml/apr_xml.c:66: error: expected specifier-qualifier-list before ‘XML_Parser’
......强行省略.....
xml/apr_xml.c: In function ‘do_parse’:
xml/apr_xml.c:434: error: ‘apr_xml_parser’ has no member named ‘xp’
.....不要看我......
xml/apr_xml.c:500: error: ‘apr_xml_parser’ has no member named ‘xp_err’
make[1]: *** [xml/apr_xml.lo] Error 1
make[1]: Leaving directory `/root/apr-util-1.6.0'
make: *** [all-recursive] Error 1

expat是解析XML的程序,是不是想立马执行yum install expat-devel呢?

然而我可以告诉你,然并卵!

不管是base库中的2.0版还是epel库中的2.1版在后面编译httpd的时候都会报错!

所以,我们去expat的官网去下载最新版的expat。

cd ~
wget https://nchc.dl.sourceforge.net/project/expat/expat/2.2.3/expat-2.2.3.tar.bz2
tar -xf expat-2.2.3.tar.bz2
cd expat-2.2.3
./configure --prefix=/usr/local/expat23
make && make install

现在可以重新编译apr-util了

cd ~
cd apr-util-1.6.0
./configure --with-apr=/usr/local/apr/ --with-expat=/usr/local/expat23/ --prefix=/usr/local/apr-util
make clean //因执行过一次编译了,保险起见把那些编译出来的东东删掉,虽然理论上并不影响
make && make install
编译httpd
cd ~
cd httpd-2.4.27
./configure --prefix=/alidata/server/httpd24 --sysconfdir=/alidata/server/httpd24/conf --with-mpm=prefork --enable-mpms-shared=all --enable-mods-shared=most --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/

到这一步会报错,提示我们没有装pcre,报错如下:

configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/

执行yum install pcre-devel即可

./configure --prefix=/alidata/server/httpd24 --sysconfdir=/alidata/server/httpd24/conf --with-mpm=prefork --enable-mpms-shared=all --enable-mods-shared=most --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/
make && make install

下面解释一下所用的选项:

  • –prefix=/usr/local/httpd24 :配置安装目录不用多说了吧?
  • –sysconfdir=/etc/httpd24:指定配置文件存放目录,默认存放到安装目录下
  • –with-mpm=prefork:默认mpm为prefork
  • –enable-mpms-shared=all:将所有mpm编译为.so模块
  • –enable-mods-shared=most:编译大多数模块为.so文件
  • –with-apr=/usr/local/apr:指定apr所在目录
  • –with-apr-util=/usr/local/apr-util/ : 指定apr-util所在目录

更多的./configure脚本选项请参考:http://httpd.apache.org/docs/2.4/programs/configure.html

测试新版httpd

首先将httpd2.4.27的bin目录加到PATH环境变量中以便执行命令~

echo "export PATH=$PATH:/usr/local/httpd24/bin" >> /etc/profile.d/httpd.sh
source /etc/rc.local

简单执行下面命令开启服务并测试:

apachectl start

打开浏览器–>访问192.168.123.233–>看到如下图说明安装成功

在Centos6.6下编译安装最新apache在Centos6.6下编译安装最新apache

上文所指报错

好吧,我没重现出错误情景….

如遇到类似如下报错,可自行编译expat

libaprutil-1.so: undefined reference to `XML_GetErrorCode'
新增编译时没有启用的模块
1. 进入apache源代码的modules/proxy目录
2. 运行如下命令自动编译、安装和修改httpd.conf文件,激活mod_proxy模块:
apachepath/bin/apxs -c -i -a mod_proxy.c proxy_util.c
apachepath/bin/apxs -c -i -a mod_proxy_http.c proxy_util.c
选项说明:
-c 执行编译操作
-i 安装操作,安装一个或多个动态共享对象到服务器的modules目录
-a 自动增加一个LoadModule行到httpd.conf文件,以激活此模块,若此行存在则启用之
-A 与-a类似,但是它增加的LoadModule行前有井号前缀(#)
-e 需要执行编辑操作,可与-a和-A选项配合使用,与-i操作类似,修改httpd.conf文件,但并不安装此模块
3. 重启apache。

PHP多版本共存:php5.6与php5.5共存

续:
php多版本共存,需要使用php-fpm来运行php方便,这样更方便配置和管理
准备工作:
创建PHP5.6的相关目录,不要与已安装的php5.5的目录相同

mkdir /alidata/server/php56  安装目录 
mkdir /alidata/server/php56/etc      配置文件存放目录

源码包下载:

wget http://cn2.php.net/distributions/php-5.6.30.tar.gz

解压,编译安装php

tar xvf php-5.6.30.tar.gz
cd php-5.6.30
所有配置参数与上一个php5.5的完全相同,只有安装的目录和配置文件目录不同。
./configure \
--prefix=/alidata/server/php56 \
--with-config-file-path=/alidata/server/php56/etc \
--with-apxs2=/alidata/server/httpd/bin/apxs \
--with-libdir=lib64
--enable-inline-optimization \
--disable-debug \
--disable-rpath \
--enable-shared \
--enable-opcache \
--enable-fpm \
--with-fpm-user=www \
--with-fpm-group=www \
--with-mysql=mysqlnd \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-mssql=/usr/local/freetds \
--with-pdo-dblib=/usr/local/freetds \
--with-gettext \
--enable-mbstring \
--with-iconv \
--with-mhash \
--with-openssl \
--enable-bcmath \
--enable-soap \
--with-libxml-dir \
--enable-pcntl \
--enable-shmop \
--enable-sysvmsg \
--enable-sysvsem \
--enable-sysvshm \
--enable-sockets \
--with-curl \
--with-zlib \
--enable-zip \
--with-bz2 \
--with-gd \
--without-sqlite3 \
--without-pdo-sqlite \
--with-pear \
--with-mcrypt \
--with-freetype-dir=/usr/local/freetype.2.1.10 \
--with-jpeg-dir=/usr/local/jpeg.6

make && make install

若编译安装时遇到如下错误

/usr/local/src/php-5.3.10/ext/xmlrpc/libxmlrpc/encodings.c:73: undefined reference to `libiconv_open’ /usr/local/src/php-5.3.10/ext/xmlrpc/libxmlrpc/encodings.c:81: undefined reference to `libiconv’ /usr/local/src/php-5.3.10/ext/xmlrpc/libxmlrpc/encodings.c:101: undefined reference to `libiconv_close’ collect2: ld returned 1 exit status make: *** [sapi/fpm/php-fpm] 错误
在执行完 ./configure … 之后,修改下 Makefile,找到其中的
EXTRA_LIBS = -lcrypt -lz -lcrypt -lrt -lmysqlclient -lmcrypt -lldap -llber -lfreetype -lpng -lz -ljpeg -lcurl -lz -lrt -lm -ldl -lnsl -lrt -lxml2 -lz -lm -lssl -lcrypto -ldl -lz -lcurl -ldl -lgssapi_krb5 -lkrb5 -lk5crypto -lcom_err -lidn -lssl -lcrypto -lz -lxml2 -lz -lm -lssl -lcrypto -ldl -lz -lxml2 -lz -lm -lxml2 -lz -lm -lcrypt -lxml2 -lz -lm -lxml2 -lz -lm -lxml2 -lz -lm -lxml2 -lz -lm -lcrypt
在最后面添加 -liconv ,修改后如下
EXTRA_LIBS = -lcrypt -lz -lcrypt -lrt -lmysqlclient -lmcrypt -lldap -llber -lfreetype -lpng -lz -ljpeg -lcurl -lz -lrt -lm -ldl -lnsl -lrt -lxml2 -lz -lm -lssl -lcrypto -ldl -lz -lcurl -ldl -lgssapi_krb5 -lkrb5 -lk5crypto -lcom_err -lidn -lssl -lcrypto -lz -lxml2 -lz -lm -lssl -lcrypto -ldl -lz -lxml2 -lz -lm -lxml2 -lz -lm -lcrypt -lxml2 -lz -lm -lxml2 -lz -lm -lxml2 -lz -lm -lxml2 -lz -lm -lcrypt -liconv

配置php-fpm

拷贝配置文件,在安装目录里
cd /alidata/server/php56/etc
cp php-fpm.conf.default php-fpm.conf 
修改配置文件
vim php-fpm.conf
将listen = 127.0.0.1:9000 改为listen = 127.0.0.1:9056
与php5.59000端口区别开,防止端口冲突

拷贝服务脚本,在源码包里
# cp sapi/fpm/init.d.php-fpm /etc/init.d/php56-fpm
# chmod +x /etc/init.d/php56-fpm
# chkconfig --add php56-fpm

启动php-fpm

 service php56-fpm start
 监听端口为:9056

nginx 切换php版本只需修改nginx.conf即可
php5.5 php-fpm 监听端口为:9000
php5.6 php-fpm监听端口为:9056

vim /etc/nginx/nginx.conf
将fastcgi_pass   127.0.0.1:9000;修改为
  fastcgi_pass   127.0.0.1:9056;
  重启nginx,打开phpinfo

apache切换PHP版本:
由于之前是用php mod来运行php,php作为apache的一个模块来运行。如果想要使用多版本切换,就不能再用php mod来运行了,必须要用php-fpm运行,然后和Apache关联。

修改配置文件

vim /etc/httpd/httpd.conf

首先注释掉以下内容(这是用php mod与PHP关联的)

#LoadModule php5_module modules/libphp5.so
#<FilesMatch \.php$> 
   #SetHandler application/x-httpd-php
#</FilesMatch>

然后去掉以下两行的注释,开启代理功能

LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so

再添加下面内容,使用php-fpm与PHP关联

<FilesMatch \.php$>
         SetHandler "proxy:fcgi://127.0.0.1:9056"
</FilesMatch>

重启apache服务,成功切换为php5.6
致此全部完成,nginx和apache全都可以正常切换PHP版本

记一次下载在线电影的过程

第一步,在浏览器控制台的网络面板中,查看网络请求,主要对两个请求感兴趣,一是m3u8文件,一是ts文件,分别获得地址。

第二步,打开m3u8文件,可以看到里面其实是ts文件列表,程序循环下载这些ts文件。

第三步,执行下面的命令,其使用ffmpeg将下载的众多ts文件进行合并,获得output.mp4。

ffmpeg -i playlist.m3u8 -c copy -bsf:a aac_adtstoasc output.mp4

CentOS 6.5 yum install PostgreSQL 9.4

一、在/etc/yum.repos.d/CentOS-Base.repo 中的[base],[updates]中都增加:exclude=postgresql*

二、引入 PostgreSQL 9.4 Repository 官方的安装源

网址是: http://download.postgresql.org/pub/repos/yum/9.4/redhat/rhel-6.6-x86_64/pgdg-centos94-9.4-2.noarch.rpm

如果这个网址显示404 Not Found,可以进入到 http://download.postgresql.org/pub/repos/yum/9.4/redhat 目录之后,一步一步点进去,找到你要下载的那个rpm包的链接。

[plain] view plain copy

 print?

  1. rpm -Uvh http://download.postgresql.org/pub/repos/yum/9.4/redhat/rhel-6.6-x86_64/pgdg-centos94-9.4-2.noarch.rpm

三、安装

[plain] view plain copy

 print?

  1. yum install postgresql94 postgresql94-server postgresql94-contrib

四、初始化PostgreSQL数据库

[plain] view plain copy

 print?

  1. service postgresql-9.4 initdb

五、设置开机自启动

[plain] view plain copy

 print?

  1. service postgresql-9.4 start
  2. chkconfig postgresql-9.4 on

六、修改监听地址、端口

/var/lib/pgsql/9.4/data/postgresql.conf 中 把注释符号去掉,显示如下:

[plain] view plain copy

 print?

  1. listen_address=’*’
  2. port=5432

七、增加操作系统用户

[plain] view plain copy

 print?

  1. [root@wc1 ~]# adduser pgdbuser

八、创建postgresql数据库中的用户

在安装完postgresql数据库之后,会有一个默认的用户postgres,切换到postgres用户,然后执行psql命令,连接postgresql,然后再创建pgdbuser用户,最后退出

[plain] view plain copy

 print?

  1. [root@wc1 ~]# su – postgres
  2. -bash-4.1$ psql
  3. psql (9.4.11)
  4. Type “help” for help.
  5.                                         ^
  6. postgres=# create user pgdbuser  with superuser login password ‘pgdbuser’;
  7. CREATE ROLE
  8. postgres=# \q

 

九、修改/var/lib/pgsql/9.4/data/pg_hba.conf文件如下:

其中ident是linux系统下postgresql默认的local认证方式,通过操作系统用户映射的数据库用户,不需要输入密码,就可以登录。

而md5,不需要在操作系统层建立对应的同名的用户。

[plain] view plain copy

 print?

  1. # TYPE  DATABASE        USER            ADDRESS                 METHOD
  2. # “local” is for Unix domain socket connections only
  3. local   all             all                                     md5
  4. # IPv4 local connections:
  5. host    all             all             127.0.0.1/32            md5
  6. # IPv6 local connections:
  7. host    all             all             ::1/128                 md5

修改之后要重启服务:

[plain] view plain copy

 print?

  1. [root@wc1 Desktop]# service postgresql-9.4 restart
  2. Stopping postgresql-9.4 service:                           [  OK  ]
  3. Starting postgresql-9.4 service:                           [  OK  ]

十、登录postgresql

由于都是需要密码验证登录,所以当前os用户为root,需要指定登录的数据库、用户,然后按照提示输入密码后登陆。

接下来,创建数据库,显示当前数据库,切换到新建的库,创建表,插入数据,查询数据。

[plain] view plain copy

 print?

  1. [root@wc1 Desktop]# psql -d postgres -U pgdbuser
  2. Password for user pgdbuser:
  3. psql (9.4.11)
  4. Type “help” for help.
  5. postgres=# create database test;
  6. ERROR:  database “test” already exists
  7. postgres=# create database xxx;
  8. CREATE DATABASE
  9. postgres=# select current_database();
  10.  current_database
  11. ——————
  12.  postgres
  13. (1 row)
  14. postgres=# \c xxx
  15. You are now connected to database “xxx” as user “pgdbuser”.
  16. xxx=# create table tb(id int);
  17. CREATE TABLE
  18. xxx=# insert into tb values(1);
  19. INSERT 0 1
  20. xxx=# select * from tb;
  21.  id
  22. —-
  23.   1
  24. (1 row)
  25. xxx=#

如果把修改/var/lib/pgsql/9.4/data/pg_hba.conf,把第一个md5改成ident,那么登录时候,需要切换到上面创建的操作系统用户:pgdbuser,然后就可以直接登录。

[plain] view plain copy

 print?

  1. # TYPE  DATABASE        USER            ADDRESS                 METHOD
  2. # “local” is for Unix domain socket connections only
  3. local   all             all                                     ident
  4. # IPv4 local connections:
  5. host    all             all             127.0.0.1/32            md5
  6. # IPv6 local connections:
  7. host    all             all             ::1/128                 md5
重启服务。
登录:
[plain] view plain copy

 print?

  1. [root@wc1 Desktop]# psql -d postgres -U pgdbuser
  2. psql: FATAL:  Peer authentication failed for user “pgdbuser”
  3. [root@wc1 Desktop]# su – pgdbuser
  4. [pgdbuser@wc1 ~]$ psql -d postgres
  5. psql (9.4.11)
  6. Type “help” for help.
  7. postgres=# \c xxx
  8. You are now connected to database “xxx” as user “pgdbuser”.
  9. xxx=# select * from tb;
  10.  id
  11. —-
  12.   1
  13. (1 row)
  14. xxx=#