澳门新浦京电子游戏交叉编译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中。

ubuntu16 下 源码配置Lnmp环境,ubuntu16lnmp

最近把系统升级到 ubuntu16长期支持版 ,重新部署了lnmp环境

约定几个目录  源码目录  /usr/local/src 

                   mysql     /usr/local/mysql

                    php   /usr/local/php

                   nginx   /usr/local/nginx 

交叉编译nginx

软件版本:nginx-1.6.2

依赖源码:pcre,zlib(这里是需要用到它们的源码)

交叉编译器:arm-hisiv200-linux-gnueabi

linux版本:32位ubuntu(这个很重要,主要是使用32位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系统是64位的,而arm上一般都是32位的,所以会有这个错误,解决办法就是重新装一个32位的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. 如果遇到其他编译问题,请参考:

 

交叉编译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. 完成

mysql   版本 5.7.14

 

必备的包和工具

gcc/g++ :MySQL 5.6开始,需要使用g++进行编译。

bison  :MySQL语法解析器需要使用bison进行编译。

libncurses5-dev
:用于终端操作的开发包.(注:Debian/Ubuntu下需要安装libncurses5-dev;Redhat下需要安装
ncurses-devel)
zlib    :MySQL使用zlib进行压缩

 

功能需要的包

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      下载地址  

 

建立源码包目录

mkdir /usr/local/src

 

解压

tar zxvf cmake-3.6.1.tar.gz 

mv cmake-3.6.1 /usr/local/src

cd cmake-3.6.1

 

编译安装

./configure   make && make install

 

加入环境变量

vim ~/.bashrc

添加

export PATH=”/usr/local/src/cmake-3.6.1/bin/cmake:$PATH”

 

从MySQL
5.7.5开始Boost库是必需的,下载Boost库 

tar zxvf boost_1_59_0.tar.gz 

mv boost_1_59_0 /usr/local/

 

创建Mysql系统用户组和用户,及数据库存放目录:

mkdir -p /usr/local/mysql/

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

 

根据需要另外创建mysql socket
文件保存目录,如果要重新指定存放位置,需要重新编译

groupadd mysql    添加mysql 用户组

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

chown -R 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

 

创建数据库服务

在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参数,生成一个随机密码(注意保存登录时用)

数据库初始化后,再次修改权限:

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

 

准备配置文件并启动mysql服务

复制默认配置文件到/etc

cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf

改变文件权限为mysql 用户和组

sudo chown mysql:mysql /etc/my.cnf

简单修改一下配置文件

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

 

后台启动mysql

/usr/local/mysql/bin/mysqld_safe –user –defaults-file/etc/my.cnf

 

查看mysql 端口或进程

netstat -altn | grep 3306 或  ps -ef|grep mysql

tcp6       0      0 :::3306                 :::*                  
 LISTEN 

 

用初始随机密码登入后修改密码

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

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

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

 

添加服务,复制启动脚本到/etc/init.d目录

cd /usr/local/mysql/
cp support-files/mysql.server /etc/init.d/mysql

 

设置权限

sudo chmod 755 /etc/init.d/mysql

 

安装ubuntu启动服务管理

sudo apt-get install sysv-rc-conf 

sudo sysv-rc-conf mysql on

 

将mysql.service变得可用

systemctl enable mysql.service

 

开启或关闭mysql服务

sudo /etc/init.d/mysql {stop|start}    或者 sudo service mysql start |
stop

 

配置环境变量

sudo vim ~/.bashrc

export PATH=”/usr/local/mysql/bin/:$PATH”

export PATH

 

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

生成共享库

cd /usr/local/src/zlib

./configure –shared  && make test && make install

cp zutil.h /usr/local/include

cp zutil.c /usr/local/include

mkdir /usr/local/zlib

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

添加到动态链接库

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 用户和用户组

groupadd www    

useradd www -g www  

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

 

nginx官网

tar zxvf nginx-1.10.1.tar.gz -C /usr/local/src

cd /usr/local/src/nginx-1.10.1 

编译安装

 ./configure –prefix=/usr/local/nginx
–with-openssl=/usr/local/src/openssl-1.0.2g
–with-pcre=/usr/local/src/pcre –with-zlib=/usr/local/src/zlib
–pid-path=/usr/local/nginx/nginx.pid –with-http_ssl_module –with-http_stub_status_module 

make && make install

 

启动nginx服务

/usr/local/nginx/sbin/nginx  

查看nginx进程

ps -ef | grep nginx

关闭,重启服务

/usr/local/nginx/sbin/nginx -s stop, quit, reopen, reload

创建nginx启动脚本

vim /etc/init.d/nginx

#! /bin/sh
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: starts the nginx web server
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DESC="nginx daemon"
NAME=nginx
DAEMON=/usr/local/nginx/sbin/$NAME
CONFIGFILE=/usr/local/nginx/conf/$NAME.conf
PIDFILE=/usr/local/nginx/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME

set -e
[ -x "$DAEMON" ] || exit 0

do_start() {
 $DAEMON -c $CONFIGFILE || echo -n "nginx already running"
}

do_stop() {
 kill -INT `cat $PIDFILE` || echo -n "nginx not running"
}

do_reload() {
 kill -HUP `cat $PIDFILE` || echo -n "nginx can't reload"
}

case "$1" in
 start)
 echo -n "Starting $DESC: $NAME"
 do_start
 echo "."
 ;;
 stop)
 echo -n "Stopping $DESC: $NAME"
 do_stop
 echo "."
 ;;
 reload|graceful)
 echo -n "Reloading $DESC configuration..."
 do_reload
 echo "."
 ;;
 restart)
 echo -n "Restarting $DESC: $NAME"
 do_stop
 do_start
 echo "."
 ;;
 *)
 echo "Usage: $SCRIPTNAME {start|stop|reload|restart}" >&2
 exit 3
 ;;
esac

exit 0

  

保存设置

:wq 

更新权限

sudo chmod 755 /etc/init.d/nginx

sudo sysv-rc-conf nginx on

nginx 启动,停止,重启命令

/etc/init.d/nginx {start|stop|reload|restart}

 

配置nginx 支持 php

vim /usr/local/nginx/conf/nginx.conf

 

location / {

root /www;

index index.html index.htm index.php;

}

location ~ .php$ {

root /www;

fastcgi_pass 127.0.0.1:9000;

fastcgi_index index.php;

fastcgi_param SCRIPT_FILENAME /www$fastcgi_script_name;

include fastcgi_params;

}

//注:黑体www为web根目录,改成对应目录即可

 

PHP 

apt-get 安装php 7 php5.6 

php 7

 

apt-get install php7.0-mysql php7.0-curl php7.0-gd php7.0-intl php-pear
php-imagick php7.0-imap php7.0-mcrypt php-memcache  php7.0-pspell
php7.0-recode php7.0-sqlite3 php7.0-tidy php7.0-xmlrpc
php7.0-xsl php7.0-mbstring php-gettext

 

php 5.6

 

sudo apt install software-properties-common

sudo add-apt-repository ppa:ondrej/php

sudo apt-get update 

sudo apt-get install php5.6

sudo apt-get install php5.6-mbstring php5.6-mcrypt php5.6-mysql
php5.6-xml

 

5.6.25编译安装

安装必要的依赖

t1lib(php字体类扩展)  版本t1lib-5.1.2.tar.gz  

解压

tar zxvf t1lib-5.1.2.tar.gz -C /usr/local/src

cd /usr/local/src t1lib-5.1.2

./configure 

提示错误 : X11/Xaw/Label.h: No such file or directory

 

缺少libxaw库

sudo apt-get install libxaw7-dev 

./configure && make without_doc && make install

 

官网下载php5.6.25源码包

tar zxvf php-5.6.23.tar.gz -C /usr/local/src

cd /usr/local/src/

 

编译安装

 ./configure –prefix=/usr/local/php
 –with-config-file-path=/usr/local/php/etc
–with-mysql-sock=/usr/local/mysql/data/mysql.sock   –enable-mbstring
 –enable-mysqlnd –with-mysql=mysqlnd
–with-mysqli=/usr/local/mysql/bin/mysql_config –with-mysqli=mysqlnd
 –with-pdo-mysql=mysqlnd –enable-fpm   –with-fpm-group=www
 –with-fpm-user=www  –enable-bcmath  –enable-bcmath  –enable-soap
–enable-calendar    –with-pcre-dir=/usr/local/src/pcre   –with-mcrypt
–enable-xml  –with-xmlrpc  –with-xsl –enable-sockets
 –enable-opcache –with-gd  –with-jpeg-dir  –with-png-dir
 –with-xpm-dir  –with-freetype-dir   –enable-gd-native-ttf
 –enable-dtrace  –with-openssl –with-kerberos
–with-openssl-dir=/usr/local/src/openssl-1.0.2g   –enable-zip
–with-zlib-dir=/usr/local/src/zlib –with-t1lib=/usr/local/share/t1lib
 –with-libxml-dir –with-iconv-dir –with-libzip  –enable-intl
–with-curl=DIR  –enable-ftp

 

提示Cannot find sys/sdt.h which is required for DTrace support  

根据官方提示dTrace某些开发版需要安装 SystemTap SDT 开发包

apt-cache search SystemTap SDT

apt-get install systemtap-sdt-dev

 

提示curl 编译失败

apt-get install  libcurl4-gnutls-dev

apt-get install curl php5.6-curl

 

提示重新安装libzip

apt-get install libzip-dev

 

清除之前编译的可执行文件及配置文件,再次编译

 make clean

 

 ./configure –prefix=/usr/local/php
 –with-config-file-path=/usr/local/php/etc
–with-mysql-sock=/usr/local/mysql/data/mysql.sock   –enable-mbstring
 –enable-mysqlnd –with-mysql=mysqlnd
–with-mysqli=/usr/local/mysql/bin/mysql_config –with-mysqli=mysqlnd
 –with-pdo-mysql=mysqlnd –enable-fpm   –with-fpm-group=www
 –with-fpm-user=www  –enable-bcmath  –enable-bcmath  –enable-soap
–enable-calendar    –with-pcre-dir=/usr/local/src/pcre   –with-mcrypt
–enable-xml  –with-xmlrpc  –with-xsl –enable-sockets
 –enable-opcache –with-gd  –with-jpeg-dir  –with-png-dir
 –with-xpm-dir  –with-freetype-dir   –enable-gd-native-ttf
 –enable-dtrace  –with-openssl –with-kerberos
–with-openssl-dir=/usr/local/src/openssl-1.0.2g   –enable-zip
–with-zlib-dir=/usr/local/src/zlib –with-t1lib=/usr/local/share/t1lib
 –with-libxml-dir –with-iconv-dir –with-libzip  –enable-intl
–with-curl=DIR –with-imap –with-imap-ssl  –enable-ftp

 

测试

make && make test

测试通过进行安装

make install

 

配置php随系统启动

从源文件复制php.ini到目录

cp php.ini-development /usr/local/php/etc/php.ini

复制php-fpm.conf

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

 

php-fpm随系统自启动

sudo cp ./sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm

sudo sysv-rc-conf php-fpm on

sudo cp ./sapi/fpm/init.d.php-fpm /usr/local/php/sbin/init.d.php-fpm

sudo chmod 755 /etc/init.d/php-fpm

 

增加读和执行权利

cd /usr/local/php/sbin/

chmod 755 init.d.php-fpm

 

php脚本服务开启,停止,重启,状态命令

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

 

加入系统变量 

vim  ~/.bashrc

export PATH=”/usr/local/php/bin/:$PATH”

export PATH=”/usr/local/php/sbin/:$PATH”

export PATH

 

改变PHP用户组为www

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

查看端口

sudo netstat -tulpn 

 

php-fpm.conf 配置

pm.max_children = 5     

pm.start_servers = 2     在启动时启动的子进程数量

pm.min_spare_servers =
1    处于空闲”idle”状态的最小子进程,如果空闲进程数量小于这个值,那么相应的子进程会被创建

pm.max_spare_servers =
3    最大空闲子进程数量,空闲子进程数量超过这个值,那么相应的子进程会被杀掉。

 

在nginx web 目录建立 phpinfo() 文件 ,浏览器输出这个画面表示配置成功

澳门新浦京电子游戏 1

 

下 源码配置Lnmp环境,ubuntu16lnmp
最近把系统升级到 ubuntu16长期支持版 ,重新部署了lnmp环境 约定几个目录
源码目录 /usr/local/src mysq…

发表评论

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