Centos6.4 编译安装 nginx php

接力编写翻译php5

软件版本:php-5.4.27

依赖库:zlib,libxml2

穿插编写翻译器:arm-hisiv200-linux-gnueabi

  1. 将接力编写翻译器路线增加到PATH中,
    作者的陆续编写翻译器目录为/usr/local/arm-hisiv200-linux/,而交叉编写翻译器在时断时续编译器目录的/bin中,在支配台输入

    PATH=$PATH:/usr/local/arm-hisiv200-linux/bin/
    
  2. 先是先交叉编写翻译zlib,步入zlib源码目录。

  3. 执行CC=arm-hisiv200-linux-gnueabi-gcc  ./configure  –shared
     –prefix=ZLIB_PATH(编写翻译成功后的装置路线卡塔尔(قطر‎
  4. make && make install
  5. 在ZLIB_PATH中会有编译成功后的文件和配置。
  6. 下一场交叉编写翻译libxml2,步入libxml2源码目录。
  7. 执行CC=arm-hisiv200-linux-gnueabi-gcc  ./configure
     –host=arm-hisiv200-linux-gnueabi
     –prefix=LIBXML2_PATH(编写翻译成功后的安装路径卡塔尔(قطر‎
  8. make && make install
  9. 在LIBXML2_PATH中会有编写翻译成功后的文本和安插。
  10. 起初陆陆续续编写翻译php5,步入php5源码目录。
  11. 首先先推行./buildconf  –force,为了幸免现身 cp:cannot stat
    ‘sapi/cli/php.1′: No such file or directory
  12. 执行./configure  –host=arm-hisiv200-linux-gnueabi  –enable-shared
     –with-zlib-dir=ZLIB_PATH  –with-libxml-dir=LIBXML2_PATH
     –disable-phar  –with-sqlite  –with-pdo-sqlite  –without-iconv
     –enable-fpm  –prefix=PHP5_PATH
  13. make && make install
  14. 编写翻译好的php程序及配置就在PHP5_PATH中。

生龙活虎. 盘算重视库

我用的linux系统是 centos7.1。

交叉编写翻译nginx

软件版本:nginx-1.6.2

正视源码:pcre,zlib(这里是亟需使用它们的源码卡塔尔

穿插编写翻译器:arm-hisiv200-linux-gnueabi

linux版本:三10位ubuntu(这么些很要紧,主假如行使三十二位x86系统才具举行编写翻译成功,因为字长不近似卡塔尔国

时断时续编译nginx与接力编写翻译php5不相同正是nginx用的是重视的库的源码,而php5用的是库文件。

  1. 进入nginx-1.6.2源码目录。
  2. 在布置和编写翻译nginx会产出过多错误,大家二个叁个解决,首先笔者利用的configure配置如下:

    #!/bin/bash
    
    CC_PATH=/home/shanlink/Cross_compile/arm-hisiv200-linux/bin/arm-hisiv200-linux-gnueabi-gcc
    CPP_PATH=/home/shanlink/Cross_compile/arm-hisiv200-linux/bin/arm-hisiv200-linux-gnueabi-g++
    INSTALL_PATH=/home/shanlink/Cross_compile/nginx_ccs/
    PCRE_PATH=/home/shanlink/Cross_compile/pcre-8.11/
    ZLIB_PATH=/home/shanlink/Cross_compile/zlib-1.2.3/
    CC_OPTS="-I /home/shanlink/Cross_compile/arm-hisiv200-linux/target/include/"
    
    ./configure --prefix=$INSTALL_PATH --with-zlib=$ZLIB_PATH --with-pcre=$PCRE_PATH --with-cc=$CC_PATH --with-cpp=$CPP_PATH --with-cc-opt=$CC_POTS --with-ld-opt="-L /home/shanlink/Cross_compile/arm-hisiv200-linux/target/lib/"
    
  3. 好的,把上述内容做成三个运行脚本,运维,现身三个谬误:

    checking for OS
     + Linux 3.13.0-43-generic x86_64
    checking for C compiler ... found but is not working
    
    ./configure: error: C compiler /home/shanlink/Cross_compile/arm-hisiv200-linux/bin/arm-hisiv200-linux-gnueabi-gcc is not found
    

    解决办法便是:编辑auto/cc/name文件,在文件起头好似下风度翩翩段,注释掉exit
    1

    if [ "$NGX_PLATFORM" != win32 ]; then
    
        ngx_feature="C compiler"
        ngx_feature_name=
        ngx_feature_run=yes
        ngx_feature_incs=
        ngx_feature_path=
        ngx_feature_libs=
        ngx_feature_test=
        . auto/feature
    
        if [ $ngx_found = no ]; then
            echo
            echo $0: error: C compiler $CC is not found
            echo
            #exit 1        注释掉这一行     
        fi
    
    fi
    
  4. 再度运维大家的安顿脚本,那时候现身

    checking for TCP_INFO ... found
    checking for accept4() ... found
    checking for int size ...objs/autotest: 1: objs/autotest: Syntax error: word unexpected (expecting ")")
      bytes
    
    ./configure: error: can not detect int size
    cat: objs/autotest.c: No such file or directory
    

    肃清方法:编辑auto/types/sizeof文件,找到

    ngx_test="$CC $CC_TEST_FLAGS $CC_AUX_FLAGS 
              -o $NGX_AUTOTEST $NGX_AUTOTEST.c $NGX_LD_OPT $ngx_feature_libs"
    
    将的$CC改为x86上使用的gcc
    
    ngx_test="gcc $CC_TEST_FLAGS $CC_AUX_FLAGS 
              -o $NGX_AUTOTEST $NGX_AUTOTEST.c $NGX_LD_OPT $ngx_feature_libs"
    
  5. 再也运营大家的安顿脚本,那个时候应该能够安枕而卧配置达成。

  6. 施行make,那时会自然则然贰个错误

    checking for C compiler default output file name... a.out
    checking for suffix of executables... 
    checking whether we are cross compiling... configure: error: in `/home/shanlink/Cross_compile/pcre-8.11':
    configure: error: cannot run C compiled programs.
    If you meant to cross compile, use `--host'.
    See `config.log' for more details.
    make[1]: *** [/home/shanlink/Cross_compile/pcre-8.11//Makefile] Error 1
    make[1]: Leaving directory `/home/shanlink/Cross_compile/nginx-1.6.2'
    make: *** [build] Error 2
    

    本条是出于nginx在编写翻译时会同有的时候候计划pcre并且打开编写翻译,而由于是交叉编写翻译,pcre的配备时需求加多–host=arm-hisiv200-linux-gnueabi,因为是由nginx自动配置的,所以我们须求手动增添此选项于pcre,然后再make,此选项增添在

    文件:objs/Makefile
    
    找到如下一段:
    /home/shanlink/Cross_compile/pcre-8.11//Makefile:    objs/Makefile
        cd /home/shanlink/Cross_compile/pcre-8.11/ 
        && if [ -f Makefile ]; then $(MAKE) distclean; fi 
        && CC="$(CC)" CFLAGS="-O2 -fomit-frame-pointer -pipe " 
        ./configure --disable-shared 
    
    将
        ./configure --disable-shared 
    改为
        ./configure --disable-shared --host=arm-hisiv200-linux-gnueabi(这个交叉编译器前缀填你们电脑上自己的)
    
  7. 如果遇上一下破绽百出,原因是你们的linux系统是60个人的,而arm上相仿都以33人的,所以会有那几个张冠李戴,消除办法正是双重装叁个叁十二个人的linux系统。

    src/core/ngx_slab.c: In function 'ngx_slab_alloc_locked':
    src/core/ngx_slab.c:209: error: integer constant is too large for 'long' type
    src/core/ngx_slab.c:209: error: comparison is always true due to limited range of data type
    src/core/ngx_slab.c:221: error: integer constant is too large for 'long' type
    src/core/ngx_slab.c:221: error: comparison is always false due to limited range of data type
    src/core/ngx_slab.c:223: error: integer constant is too large for 'long' type
    src/core/ngx_slab.c:223: error: comparison is always true due to limited range of data type
    src/core/ngx_slab.c:253: error: integer constant is too large for 'long' type
    src/core/ngx_slab.c:253: error: comparison is always true due to limited range of data type
    src/core/ngx_slab.c:262: error: integer constant is too large for 'long' type
    src/core/ngx_slab.c:262: error: comparison is always false due to limited range of data type
    src/core/ngx_slab.c:289: error: left shift count >= width of type
    src/core/ngx_slab.c:292: error: integer constant is too large for 'long' type
    src/core/ngx_slab.c:294: error: left shift count >= width of type
    src/core/ngx_slab.c:304: error: integer constant is too large for 'long' type
    src/core/ngx_slab.c:376: error: left shift count >= width of type
    src/core/ngx_slab.c: In function 'ngx_slab_free_locked':
    src/core/ngx_slab.c:499: error: integer constant is too large for 'long' type
    src/core/ngx_slab.c:499: error: comparison is always false due to limited range of data type
    src/core/ngx_slab.c:552: error: integer constant is too large for 'long' type
    src/core/ngx_slab.c:575: error: integer constant is too large for 'long' type
    src/core/ngx_slab.c:575: error: comparison is always false due to limited range of data type
    src/core/ngx_slab.c:582: error: integer constant is too large for 'long' type
    src/core/ngx_slab.c: In function 'ngx_slab_alloc_pages':
    src/core/ngx_slab.c:643: error: integer constant is too large for 'long' type
    src/core/ngx_slab.c:652: error: integer constant is too large for 'long' type
    src/core/ngx_slab.c:652: error: large integer implicitly truncated to unsigned type
    make[1]: *** [objs/src/core/ngx_slab.o] Error 1
    make[1]: Leaving directory `/home/shanlink/Cross_compile/nginx-1.6.2'
    make: *** [build] Error 2
    
  8. 这时候继续make,还有只怕会产出五个错误,三个是

    src/os/unix/ngx_errno.c: In function 'ngx_strerror':
    src/os/unix/ngx_errno.c:37: error: 'NGX_SYS_NERR' undeclared (first use in this function)
    src/os/unix/ngx_errno.c:37: error: (Each undeclared identifier is reported only once
    src/os/unix/ngx_errno.c:37: error: for each function it appears in.)
    src/os/unix/ngx_errno.c: In function 'ngx_strerror_init':
    src/os/unix/ngx_errno.c:58: error: 'NGX_SYS_NERR' undeclared (first use in this function)
    make[1]: *** [objs/src/os/unix/ngx_errno.o] Error 1
    make[1]: Leaving directory `/home/shanlink/Cross_compile/nginx-1.6.2'
    make: *** [build] Error 2
    

    斩尽杀绝措施就是张开objs/ngx_auto_config.h,添加

    #ifndef NGX_SYS_NERR
    #define NGX_SYS_NERR    132
    #endif
    

    另三个漏洞相当多

    objs/src/event/ngx_event_accept.o: In function `ngx_event_accept':
    /home/shanlink/Cross_compile/nginx-1.6.2/src/event/ngx_event_accept.c:64: warning: warning: accept4 is not implemented and will always fail
    objs/src/core/ngx_cycle.o: In function `ngx_init_cycle':
    /home/shanlink/Cross_compile/nginx-1.6.2/src/core/ngx_cycle.c:457: undefined reference to `ngx_shm_free'
    /home/shanlink/Cross_compile/nginx-1.6.2/src/core/ngx_cycle.c:462: undefined reference to `ngx_shm_alloc'
    /home/shanlink/Cross_compile/nginx-1.6.2/src/core/ngx_cycle.c:648: undefined reference to `ngx_shm_free'
    objs/src/event/ngx_event.o: In function `ngx_event_module_init':
    /home/shanlink/Cross_compile/nginx-1.6.2/src/event/ngx_event.c:525: undefined reference to `ngx_shm_alloc'
    collect2: ld returned 1 exit status
    make[1]: *** [objs/nginx] Error 1
    make[1]: Leaving directory `/home/shanlink/Cross_compile/nginx-1.6.2'
    make: *** [build] Error 2
    shanlink@ubuntu:~/Cross_compile
    

    相同的,大家须要改善objs/ngx_auto_config.h文件,在文书中参预

    #ifndef NGX_HAVE_SYSVSHM
    #define NGX_HAVE_SYSVSHM 1
    #endif
    
  9. 好了,那个时候make && make install就相应能编写翻译过去了。

  10. 要是遇上别的编写翻译难点,请参照他事他说加以考查:

安装make:

假设linux系统未有事情发生前安装 gcc
等编写翻译软件能够用yum源安装。安装nginx,首先须要设置依赖模块pcre、zlib、openssl。

时有时无编写翻译squid

软件版本:squid-2.7-STABLE9

穿插编写翻译器:arm-hisiv200-linux-gnueabi

系统:32位ubuntu

在对squid举行交叉编写翻译时,必要动用x86版本的squid,所以大家要举行四个版本的编写翻译。

  1. 率先编写翻译x86本子的应用布置为

    ./configure --prefix=X86_SQUID_PATH
    
  2. make && make install

  3. 步入到squid源码目录下的src/文件夹,有个cf_gen程序,备份起来,交叉编写翻译时会用到。
  4. 确立三个arm-linux.cache文件,写入

    ac_cv_epoll_works=
    ac_cv_af_unix_large_dgram=
    ac_cv_func_setresuid=
    ac_cv_func_va_copy=
    ac_cv_func___va_copy=
    
  5. 执行

    #!/bin/bash
    
    ./configure --host=arm-hisiv200-linux-gnueabi --prefix=/home/shanlink/Cross_compile/squid_ccs/ --cache-file=arm-linux.cache
    

    那儿应该是力所能及顺遂经过的

  6. 实践make,相会世三个荒唐

    ./cf_gen: cannot execute binary file
    
  7. 将以前备份的x86的cf_gen复制到src/目录下替换arm的

  8. 重复施行make,应该能够顺利通过编写翻译
  9. make install
  10. 完成
yum -y install gcc automake autoconf libtool make

gzip 模块供给 zlib 库

安装g++:

rewrite 模块需求 pcre 库

yum install gcc gcc-c++

ssl 功能须要 openssl库

二. 编写翻译安装pcre

1.安装pcre依赖

pcre 是一个正则表明式的库,编写翻译nginx必要依赖该库落成url rewrite

  • 下载 pcre-8.38 wget
    ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.38.tar.gz
  • 解压 tar -zxvf pcre-8.38.tar.gz
  • 跻身到解压目录 cd 你的目录/pcre-8.38
  • 编译 ./configure –prefix=/opt/project/pcre #点名安装目录
  • 编写翻译落成今后安装 make && make install

下载源码

2.安装zlib依赖

cd /usr/local/src  wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.33.tar.bz2  tar jxvf pcre-8.33.tar.bz2
  • 下载 zlib-1.2.11 wget
  • 解压 tar -zxvf zlib-1.2.11.tar.gz
  • 进去到解压目录 cd 你的目录/zlib-1.2.11
  • 编译 ./configure –prefix=/opt/project/zlib #点名安装目录
  • 编写翻译完毕以后安装 make && make install

编写翻译安装

3.安装openSSL依赖

cd pcre-8.33  ./configure  make  make install
  • 下载 openssl-1.1.1-pre5 wget
  • 解压 tar -zxvf openssl-1.1.1-pre5.tar.gz
  • 进去到解压目录 cd 你的目录/openssl-1.1.1-pre5
  • 编译 ./configure –prefix=/opt/project/openssl #点名安装目录
  • 编译完毕以往安装 make && make install

三. 编写翻译安装zlib库

4.安装nginx服务

zlib 是gzip实现

手动创造 nginx 客户与客商组

下载源码

groupadd nginx

cd /usr/local/src  wget http://zlib.net/zlib-1.2.8.tar.gz  tar -zxvf zlib-1.2.8.tar.gz

useradd nginx -g nginx -s /sbin/nologin -M

编写翻译安装

  • 下载 wget
  • 解压 tar -zxvf nginx-1.14.0.tar.gz
  • 编译
cd zlib-1.2.8
./configure  make  make install

./configure –prefix=/opt/project/nginx-1.14 #nginx 安装地点
–sbin-path=/opt/project/nginx-1.14/sbin/nginx
#设置nginx可推行文件路线
–conf-path=/opt/project/nginx-1.14/config/nginx.conf
#安装nginx配置文件路线
–pid-path=/opt/project/nginx-1.14/logs/nginx.pid
#设置nginx.pid文件
–error-log-path=/opt/project/nginx-1.14/logs/error.log
#安装主错误,警报,和确诊文件的称谓
–lock-path=/opt/project/nginx-1.14/logs/nginx.log
–http-log-path=/opt/project/nginx-1.14/logs/access.log
#设置主乞请的HTTP服务器的日记文件的称呼
–with-http_ssl_module
–user=nginx
–group=nginx
–with-pcre=/var/software/nginx/pcre-8.38 #指的是pcre 的源码路线
–with-zlib=/var/software/nginx/zlib-1.2.11 #指的是zlib 的源码路线
–with-openssl=/var/software/nginx/openssl-1.1.1-pre5 #指的是openssl
的源码路线

四. 安装openssl

  • 安装 make && make install
  • nginx编写翻译安装完结以往,修正nginx.conf

反省是还是不是安装了ssl

user nginx nginx;

# rpm -qa|grep openssl  openssl-devel-1.0.1e-16.el6_5.14.x86_64  openssl-1.0.1e-16.el6_5.14.x86_64

启动nginx /opt/project/nginx/nginx

比如未有安装

重启nginx /opt/project/nginx/nginx -s reload

下载源码

干掉进程 pkill -9 nignx

cd /usr/local/src  wget http://www.openssl.org/source/openssl-1.0.1c.tar.gz  tar -zxvf openssl-1.0.1c.tar.gz

查看端口 netstat -ano|grep 80

编写翻译安装

翻开进度 ps -ef|grep nginx
6>

./configure  make  make install

图片 1

五. 编译安装nginx

若果访谈不了,供给关闭防火墙。

cd /usr/local/src  wget http://nginx.org/download/nginx-1.2.8.tar.gz  tar -zxvf nginx-1.2.8.tar.gz  cd nginx-1.2.8

centos7 查看防火墙状态
firewall-cmd –state #running 防火墙运转中 (not running 已关闭)

  ./configure –sbin-path=/usr/local/nginx/nginx
  –conf-path=/usr/local/nginx/nginx.conf
  –pid-path=/usr/local/nginx/nginx.pid
  –with-http_ssl_module
  –with-pcre=/usr/local/src/pcre-8.33
  –with-zlib=/usr/local/src/zlib-1.2.8
  –with-openssl=/usr/local/src/openssl-1.0.1c

关闭防火墙
systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁绝firewall开机运行

  make
  make install

即使在装置进度中,遭逢题目请自行google,因为系统的差距遇到的一无是处或者不太契合。

设置成功甘休后证实是不是安装成功

您可能感兴趣的稿子:

  • centos7利用yum安装lnmp的教程(linux+nginx+php7.1+mysql5.7)
  • LNMP编写翻译安装之nginx安装配置格局图像和文字教程
  • Centos
    6.8编写翻译安装LNMP情况(Nginx+MySQL+PHP)教程
  • CentOS
    7.0编写翻译安装lnmp教程(Nginx1.6.0+MySQL5.6.19+PHP5.5.14卡塔尔国
  • CentOS
    6.6服务器编写翻译安装lnmp(Nginx1.6.2+MySQL5.6.21+PHP5.6.3卡塔尔
  • lnmp情形中怎样为nginx开启pathinfo
  • LNMP服务器意况配置
    (linux+nginx+mysql+php卡塔尔
  • CentOS
    6.4安装配备LNMP服务器(Nginx+PHP+MySQL卡塔尔国
  • 依附Nginx0.8.54+PHP5.3.4+MySQL5.5.8的全新LNMP稳固版构造搭建的VPS
/usr/local/nginx/nginx   netstat -alptn|grep 80

六. 编译安装php

新本子的php中早就合龙了php-fpm 

  1. 有备无患专门的学问

    yum -y install libmcrypt-devel mhash-devel libxslt-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel

  2. 源码编译安装libmcrypt

    wget ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/attic/libmcrypt/libmcrypt-2.5.7.tar.gz tar -zxvf libmcrypt-2.5.7.tar.gz cd libmcrypt-2.5.7 ./configure make make install

  3. 下载源码

    wget tar zvxf php-5.4.7.tar.gz

  4. 编写翻译安装cd php-5.4.7

    ./configure –prefix=/usr/local/php

             --enable-fpm                                   
             --enable-mbstring                              
             --enable-sockets                               
             --enable-sysvsem                               
             --enable-sysvshm                               
             --enable-pcntl                                 
             --enable-mbregex                               
             --enable-zip                                   
             --enable-inline-optimization                   
             --disable-pdo                                  
             --disable-debug                                
             --disable-rpath                                
             --with-mcrypt                                  
             --with-zlib                                    
             --with-bz2                                     
             --with-mhash                                   
             --with-curl                                    
             --with-mysql                                   
             --with-gd                                      
             --with-pcre-regex                              
             --with-libdir=lib64
    

要是报如下错误

configure: error: Don't know how to define struct flock on this system, set --enable-opcache=no

修改 /etc/ld.so.conf 文件

vi /etc/ld.so.conf.d/local.conf  #添加2行
/usr/local/lib64   //64系统
/usr/local/src/libmcrypt-2.5.7/lib/.libs

#执行以下命令
chmod gu+x /etc/ld.so.conf.d/local.conf

#执行以下命令使生效
ldconfig -v

双重执行命令

打响后编写翻译安装

七. 配置运转

  1. 配置php-fpm

    cd /usr/local/php cp /etc/php-fpm.conf.default /etc/php-fpm.conf vi /etc/php-fpm.conf

修改
user = llong
group = llong

  1. 修改nginx 支持 php-fpm

打开 nginx.conf 

里面server段扩张如下配置,注意标红内容安顿,不然会忍俊不禁No input file
specified.错误

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000  #  location ~ .php$ {  root html;  fastcgi_pass 127.0.0.1:9000;  fastcgi_index index.php;  fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;  include fastcgi_params;  }
  1. 测量试验是不是布署成功

在/usr/local/nginx/html下创办index.php文件,输入如下内容

<?   echo phpinfo();   ?>

启动php-fpm和nginx

/usr/local/php/sbin/php-fpm (手动打补丁的启动方式/usr/local/php/sbin/php-fpm start)     /usr/local/nginx/nginx

 

 


发表评论

电子邮件地址不会被公开。 必填项已用*标注