下载最新代码:
git clone https://github.com/webcpp/hi-nginx.git
依赖安装:
sudo yum install gcc gcc-c++ make pcre-devel zlib-devel openssl-devel python36-devel lua-devel
进入hi-nginx文件夹,找到install_demo.sh,编辑install_demo.sh脚本:
#!/bin/bashif ! test -f Makefile;then./configure \ --with-cc=gcc \ --with-http_ssl_module \ --with-http_v2_module \ --prefix=/usr/local/nginx \ --enable-http-hi-cpp=YES \ --enable-http-hi-python=YES \ --enable-http-hi-lua=NO \ --enable-http-hi-java=NO \ --enable-http-hi-php=NO \ --with-http-hi-python-version=python3 \ --with-http-hi-lua-version=lua5.3 \ --add-module=ngx_http_hi_module \ --add-module=3rd/nchan-1.2.3 \ --add-module=3rd/nginx-rtmp-module-1.2.1else echo ready.fi
编译安装:
./install_demo.sh
make && make install
可能发生错误:
1.无法识别的命令行选项“-std=c++11”
解决方案:升级gcc-c++版本,至少4.8+,centos6.x yum的最高版本是4.4.7,需要手动升级。推荐使用centos7.x,gcc-c++版本刚刚好。
组件库:http://gcc.gnu.org/pub/gcc/infrastructure/
升级gcc-c++ 需要先保证以下三个组件的版本必须比文档中的高,如组件不存在需要安装
wget ftp://gcc.gnu.org/pub/gcc/infrastructure/gmp-4.3.2.tar.bz2
wget ftp://gcc.gnu.org/pub/gcc/infrastructure/mpfr-2.4.2.tar.bz2
wget ftp://gcc.gnu.org/pub/gcc/infrastructure/mpc-0.8.1.tar.gz
第一个安装GMP,在根目录下创建gmp-build用于存放编译后的文件,进去gmp-build
../configure --prefix=/usr/local/gmp-4.3.2
make && make check && make install
第二个安装MPFR
./configure --prefix=/usr/local/mpfr-2.4.2 --with-gmp=/usr/local/gmp-4.3.2
最后安装MPC
./configure --prefix=/usr/local/mpc-0.8.1 --with-gmp=/usr/local/gmp-4.3.2 --with-mpfr=/usr/local/mpfr-2.4.2
tar -xf gcc-4.8.2.tar.gz
cd gcc-4.8.2
./contrib/download_prerequisites
mkdir gcc-build-4.8.2
cd gcc-build-4.8.2
../configure --enable-checking=release --enable-languages=c,c++ --disable-multilib --with-gmp=/usr/local/gmp-4.3.2 --with-mpfr=/usr/local/mpfr-2.4.2 --with-mpc=/usr/local/mpc-0.8.1
make && make install 编译过程时间很长。。。请耐心等待。。。
2.Python,centos默认安装Python2.7,如果用到Python3.x需自行安装
两种安装方式
1.安装包安装
wget https://www.python.org/ftp/python/3.x.x/Python-3.x.x.tar.xz
./configure && make && make test && sudo make install
可能会报错:ModuleNotFoundError: No module named '_ctypes'
解决方案:yum install libffi-devel -y
2.yum安装
sudo yum install epel-release
sudo yum install python36
安装完成,进行配置
查看是否安装成功:python3 -V
3.pip或pip3安装pkgconfig
pip install pkgconfig
pip3 install pkgconfig
hi-nginx安装位置
nginx path prefix: "/usr/local/nginx"
nginx binary file: "/usr/local/nginx/sbin/nginx"
nginx modules path: "/usr/local/nginx/modules"
nginx configuration prefix: "/usr/local/nginx/conf"
nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
nginx pid file: "/usr/local/nginx/logs/nginx.pid"
nginx error log file: "/usr/local/nginx/logs/error.log"
nginx http access log file: "/usr/local/nginx/logs/access.log"
网友评论