PHP gd库增加jpeg支持

wget http://www.ijg.org/files/jpegsrc.v9b.tar.gz
tar zxvf jpegsrc.v9b.tar.gz
cd jpeg-9b
./configure –prefix=/usr/local/jpeg –enable-shared –enable-static
make && make install

cd /alidata/server/temp/php-5.6.30/ext/gd
make clean
/alidata/server/php56/bin/phpize
./configure –with-php-config=/alidata/server/php56/bin/php-config –with-png-dir –with-freetype-dir=/usr/local/freetype.2.1.10 –with-jpeg-dir=/usr/local/jpeg –with-zlib-dir –with-gd
make && make install
/etc/init.d/php56-fpm restart

如果仍然不行,重新编译PHP。

如果重新编译仍然不行,那么就先不加gd选项编译PHP,然后再加上gd选项编译一次。

React Native WebView打开网页自动适应页面大小

参考文章:https://stackoverflow.com/questions/50110920/how-to-zoom-out-in-webview-in-react-native

<WebView
injectedJavaScript={
`const meta = document.createElement(‘meta’);
meta.setAttribute(‘content’, ‘width=device-width, initial-scale=0.5, maximum-scale=0.5, user-scalable=0’);
meta.setAttribute(‘name’, ‘viewport’);
document.getElementsByTagName(‘head’)[0].appendChild(meta); `
}
scalesPageToFit={false}
/>

 

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

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。