接力编写翻译PHP5、Nginx、Squid的亲力亲为步骤

穿插编写翻译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中。

功能需求的包

libxml2  :用于XML输入输出方式的协助。

openssl  :使用openssl避孕套接字方式通讯。

dtrace  :用于诊断MySQL难点。

cmake  :MySQL 5.5起来,使用cmake实行工程处理,cmake要求2.8以上版本。

 

sudo apt-get install gcc

sudo apt-get install libxml2

sudo apt-get install  libncurses5-dev bison 

设置cmake      下载地址  

 

五、创制测验php文件
在/usr/local/nginx/html下创造info.php件,输入如下内容:
<?php
    echo phpinfo();
?>

穿插编写翻译nginx

软件版本:nginx-1.6.2

信任源码:pcre,zlib(这里是须求采用它们的源码State of Qatar

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

linux版本:叁十五位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上雷同都以叁十三人的,所以会有其一乖谬,消逝办法就是重新装一个叁10个人的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. 假使遇上其他编写翻译难点,请参见:

编写翻译安装

./configure   make && make install

 

# cd /usr/local/src ;wget -c
;tar -zxf
nginx-1.8.1.tar.gz ;cd nginx-1.8.1
#跻身解压目录,然后sed修改Nginx版本音讯为WS
sed -i -e ‘s/1.8.1/g’ -e ‘s/nginx\//WS/g’ -e ‘s/”NGINX”/”WS”/g’
src/core/nginx.h
预编译Nginx
# useradd www ;./configure –prefix=/usr/local/nginx \
–user=www \
–group=www \

穿插编写翻译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. 完成

履新权限

sudo chmod 755 /etc/init.d/nginx

sudo sysv-rc-conf nginx on

越来越多Nginx相关课程见以下内容

用起来随机密码登录后修改密码

/usr/local/mysql/bin/mysql -uroot -p

mysql> set password for
[email protected]=password(‘新密码’);

Query OK, 0 rows affected, 1 warning (0.00 sec)

 

–with-http_stub_status_module \
–with-http_ssl_module \
–with-pcre=/usr/local/src/pcre-8.37 \
–with-zlib=/usr/local/src/zlib-1.2.8 \
–with-openssl=/usr/local/src/openssl-1.0.2d
注意:
–with-pcre=/usr/local/src/pcre-8.37 指的是pcre-8.37 的源码路线。
–with-zlib=/usr/local/src/zlib-1.2.8 指的是zlib-1.2.8 的源码路线。
# make && make install

数据库开端化后,再一次改革权限:

chown -R mysql:mysql /usr/local/mysql/data  

 

Nginx
的详尽介绍
:请点这里
Nginx
的下载地址
:请点这里

Nginx     版本1.10.1

预备专门的学问

需要 zlib 库      

tar -xvf zlib-1.2.8.tar.gz -C /usr/local/src

mv /usr/local/src/zlib-1.2.8  /usr/local/src/zlib

CentOS 6.4安装配置Nginx+Pcre+php-fpm
http://www.linuxidc.com/Linux/2013-08/88984.htm

始建数据库服务

在5.5和5.6本子中,mysql数据库是利用mysqld_db_install命令进行最早化的;在5.7今后,数据库开头化产生了改造,必要mysqld命令进行初步化:

/usr/local/mysql/bin/mysqld  –initialize   –user=mysql
 –basedir=/usr/local/mysql –datadir=/usr/local/mysql/data/

—以root早先化操作时要加–user=mysql参数,生成三个随意密码(注意保存登陆时用)

# yum install -y gcc gcc-c++ automake autoconf libtool make

创造Mysql系统客户组和客商,及数据库存放目录:

mkdir -p /usr/local/mysql/

mkdir -p /usr/local/mysql/data/

 

基于需求其余创设mysql socket
文件保留目录,若是要再度钦命存放地点,要求再行编写翻译

groupadd mysql    添加mysql 用户组

useradd mysql -g mysql  添加mysql用户 并指定mysql用户组

chown -奥迪Q5 mysql:mysql /usr/local/mysql/
 改换钦点目录甚至其子目录下权限为mysql客户和mysql客户组

 

mysql官方下载地址

   选择可编写翻译版本

tar zxvf mysql-5.7.14.tar.gz

cd mysql-5.7.14

编译

cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql
-DMYSQL_DATADIR=/usr/local/mysql/data
-DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1
-DWITH_BLACKHOLE_STORAGE_ENGINE=1
-DWITH_PARTITION_STORAGE_ENGINE=1
-DWITH_PERFSCHEMA_STORAGE_ENGINE=1
-DWITHOUT_EXAMPLE_STORAGE_ENGINE=1
-DWITHOUT_FEDERATED_STORAGE_ENGINE=1 -DDEFAULT_CHARSET=utf8
-DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS=all
-DENABLED_LOCAL_INFILE=1
 -DMYSQL_UNIX_ADDR=/usr/local/mysql/data/mysql.sock
-DCOMPILATION_COMMENT=”string”-DENABLED_PROFILING=1
-DOPTIMIZER_TRACE=1 -DWITH_DEBUG=1 -DWITH_BOOST=/usr/local/boost

make && make install

 

CentOS 6.3下配置Nginx加载ngx_pagespeed模块
http://www.linuxidc.com/Linux/2013-09/89657.htm

php脚本服务开启,结束,重启,状态命令

./init.d.php-fpm {start|stop|force-quit|restart|reload|status}

 

# cd /usr/local/src ;wget ;tar zxf
zlib-1.2.8.tar.gz ;cd zlib-1.2.8 && ./configure –prefix=/usr/local/zlib
&& make && make install
设置ssl(有些vps私下认可没装ssl卡塔尔国

更正PHP顾客组为www

chown -R www:www /usr/local/php

翻看端口

sudo netstat -tulpn 

 

六、运行服务
# /usr/local/php/sbin/php-fpm
# /usr/local/nginx/sbin/nginx

简短校勘一下配备文件

vim /etc/my.cnf

[client]
port = 3306
socket = /usr/local/mysql/data/mysql.sock

[mysqld]
port = 3306
socket = /usr/local/mysql/data/mysql.sock
basedir = /usr/local/mysql
datadir  = /usr/local/mysql/data

 

# cd /usr/local/src ;wget
;tar zxf
openssl-1.0.2d.tar.gz

 

图片 1

安装权限

sudo chmod 755 /etc/init.d/mysql

 

搭建基于Linux6.3+Nginx1.2+PHP5+MySQL5.5的Web服务器全经过
http://www.linuxidc.com/Linux/2013-09/89692.htm

增加到动态链接库

Add /usr/local/zlib/lib to /etc/ld.so.conf

ldconfig

 

需要 pcre 库        

tar zxvf pcre-8.39.tar.gz -C /usr/local/src

mv /usr/local/src/pcre-8.39 /usr/local/src/prce

cd /usr/local/prce

./configure && make && make install

 

ssl作用须求openssl库     下载1.0.2g版本

tar zxvf openssl-1.0.2g.tar.gz -C /usr/local/src

cd /usr/local/openssl-1.0.2g

./config –prefix=/usr/local/ shared

make test && make install

累积到动态链接库

Add /usr/local/lib to /etc/ld.so.conf 

ldconfig

 

使用Nginx搭建WEB服务器
http://www.linuxidc.com/Linux/2013-09/89768.htm

必备的包和工具

gcc/g++ :MySQL 5.6发轫,必要采纳g++实行编译。

bison  :MySQL语法深入分析器必要接纳bison举行编写翻译。

libncurses5-dev
:用于终端操作的开垦包.(注:Debian/Ubuntu下须要安装libncurses5-dev;Redhat下须要安装
ncurses-develState of Qatar
zlib    :MySQL使用zlib实行压缩

 

三、编写翻译安装nginx

 

1、安装插件安装包
第一须要安装pcre库,然后再设置Nginx:
#设置pcre扶助rewrite库,也能够安装源码,注*设置源码时,钦定pcre路线为解压源码的门路,并不是编写翻译后的不二秘籍,不然会报错
(make[1]: *** [/usr/local/pcre/Makefile] Error 127 错误)
# yum -y install pcre-devel pcre zlib zlib-devel openssl
openssl-devel或
源码安装PCRE(pcre援救rewrite库)
# cd /usr/local/src ;wget
ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.37.tar.bz2
;tar jxf pcre-8.37.tar.bz2 ;cd pcre-8.37 && ./configure
–prefix=/usr/local/pcre && make && make install
源码安装zlib库(zlib援助gzip压缩)

发表评论

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

网站地图xml地图