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的单机版安装完成.

云通讯访问报错:172001网络错误

172001,错误信息=网络错误
172001是无法连接我们的服务器,请求不到或者发不出请求,sdk本地打印的故障报错。需要按如下顺序排查:
a.先打印请求url确认serverIP是否传错; 
b.Linux系统试用:curl -l  https://app.cloopen.com:8883 测试下,看是否是通的,windows系统,在浏览器输入 https://app.cloopen.com:8883看是否正常; 
c.如果是在Linux下 centos版本大于6.0并且使用java开发,用java -version确认下jdk版本(在此环境下需要使用sunjdk,openjdk不行);
d. 在 /etc/hosts 文件里添加" 42.121.254.126  app.cloopen.com",重启服务器。

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

(完)

React Native打包后运行闪退

错误原因1:将原本是JPG的图片强制改成PNG扩展名。

reactnative bundle platform android dev false entryfile index.js bundleoutput android/app/src/main/assets/index.android.bundle assetsdest android/app/src/main/res/

 

错误原因2: DrawerNavigator.js本身的错误

https://github.com/aksonov/react-native-router-flux/issues/3124

sed -i -e 's/TabRouter/tabRouter/g' node_modules/react-navigation/src/navigators/DrawerNavigator.js
sed -i -e 's/\/routers\/tabRouter/\/routers\/TabRouter/g' node_modules/react-navigation/src/navigators/DrawerNavigator.js

react-native run-ios 指定模拟器

如下示例,默认打开iPad Pro (9.7-inch)模拟器

react-native run-ios --simulator "iPad Pro (9.7-inch)"

也可在WebStorm的Configurations中修改,也就是Arguments中设置为

--simulator "iPad Pro (9.7-inch)"

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/apr16  //指定安装位置
make && make install
编译apr-util
cd apr-util-1.6.0
./configure --with-apr=/usr/local/apr16/ --prefix=/usr/local/apr16-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/apr16/ --with-expat=/usr/local/expat23/ --prefix=/usr/local/apr16-util
make clean //因执行过一次编译了,保险起见把那些编译出来的东东删掉,虽然理论上并不影响
make && make install
编译httpd
cd ~
cd httpd-2.4.27
./configure --prefix=/usr/local/httpd24 --sysconfdir=/etc/httpd24 --with-mpm=prefork --enable-mpms-shared=all --enable-mods-shared=most --with-apr=/usr/local/apr16 --with-apr-util=/usr/local/apr16-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=/usr/local/httpd24 --sysconfdir=/etc/httpd24 --with-mpm=prefork --enable-mpms-shared=all --enable-mods-shared=most --with-apr=/usr/local/apr16 --with-apr-util=/usr/local/apr16-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/apr16:指定apr所在目录
  • –with-apr-util=/usr/local/apr16-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 \
--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-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-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