兴發国际娱乐手机登录 3

环境搭建笔记,19编译安装详解

详解CentOS 7 下PHP 5.6.19编译安装全过程,希望对你有用。

安装PHP 

1、apache安装部署

官网:

文档:

源码包:apache-2.4.20

下载依赖包:

wget
http://archive.apache.org/dist/apr/apr-1.4.5.tar.gz 
                          //如果没有wget命令  安装:        # yum -y
install wget

wget
http://archive.apache.org/dist/apr/apr-util-1.3.12.tar.gz

wget
http://jaist.dl.sourceforge.net/project/pcre/pcre/8.39/pcre-8.39.tar.gz

解压依赖包:

tar -xzvf apr-1.4.5.tar.gz

tar -xzvf apr-util-1.3.12.tar.gz

pcre-8.39.tar.gz

安装apr-1.4.5

进入安装目录

安装并编译

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

make && make install

安装apr-util

进入安装目录

安装并编译

./configure –prefix=/usr/local/apr-util
-with-apr=/usr/local/apr/bin/apr-1-config

make && make install

安装pcre-8.39

进入安装目录

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

make && make install

安装apache

进入安装目录

用–with参数指定安装的依赖包

./configure –prefix=/usr/local/apache –with-apr=/usr/local/apr
–with-apr-util=/usr/local/apr-util/ –with-pcre=/usr/local/pcre

make:编译时间会比较长

make install:安装

配置文件:conf/httpd.conf

启动:./apachectl -k start

安全停止:./apachectl -k graceful-stop

立刻停止:./apachectl -k stop

安全重启:./apachectl -k graceful

立刻重启:./apachectl -k restart

0x01  前言

在php官网下载php-5.6.19.tar.gz源代码(php7虽然说性能提升很大,但是小菜菜还是先用着这个先吧),解压后根目录有个INSTALL文件,里面有安装教程了,目录如下:

Installing PHP
__________________________________________________________________

* General Installation Considerations
* Installation on Unix systems

  • Apache 1.3.x on Unix systems
    + Apache 2.x on Unix systems
  • Lighttpd 1.4 on Unix systems
  • Sun, iPlanet and Netscape servers on Sun Solaris
  • CGI and command line setups
  • HP-UX specific installation notes
  • OpenBSD installation notes
  • Solaris specific installation tips
  • Debian GNU/Linux installation notes
    * Installation on Mac OS X
  • Using Packages
  • Using the bundled PHP
  • Compiling PHP on Mac OS X
    * Installation of PECL extensions
  • Introduction to PECL Installations
  • Downloading PECL extensions
  • Installing a PHP extension on Windows
  • Compiling shared PECL extensions with the pecl command
  • Compiling shared PECL extensions with phpize
  • php-config
  • Compiling PECL extensions statically into PHP
    * Problems?
  • Read the FAQ
  • Other problems
  • Bug reports
    * Runtime Configuration
  • The configuration file
  • .user.ini files
  • Where a configuration setting may be set
  • How to change configuration settings
    * Installation
    __________________________________________________________________

对应你当前的系统,查看相应的内容,当前我的环境应该参考Apache 2.x on Unix
systems这部分

Apache 2.x on Unix systems

This section contains notes and hints specific to Apache 2.x installs
of PHP on Unix systems.
Warning

We do not recommend using a threaded MPM in production with Apache 2.
Use the prefork MPM, which is the default MPM with Apache 2.0 and 2.2.
For information on why, read the related FAQ entry on using Apache2
with a threaded MPM

The » Apache Documentation is the most authoritative source of
information on the Apache 2.x server. More information about
installation options for Apache may be found there.

The most recent version of Apache HTTP Server may be obtained from
» Apache download site, and a fitting PHP version from the above
mentioned places. This quick guide covers only the basics to get
started with Apache 2.x and PHP. For more information read the »
Apache
Documentation. The version numbers have been omitted here, to ensure
the instructions are not incorrect. In the examples below, ‘NN’ should
be replaced with the specific version of Apache being used.

There are currently two versions of Apache 2.x – there’s 2.0 and 2.2.
While there are various reasons for choosing each, 2.2 is the current
latest version, and the one that is recommended, if that option is
available to you. However, the instructions here will work for either
2.0 or 2.2.

  1. Obtain the Apache HTTP server from the location listed above, and
    unpack it:
    gzip -d httpd-2_x_NN.tar.gz
    tar -xf httpd-2_x_NN.tar

  2. Likewise, obtain and unpack the PHP source:
    gunzip php-NN.tar.gz
    tar -xf php-NN.tar

  3. Build and install Apache. Consult the Apache install documentation
    for more details on building Apache.
    cd httpd-2_x_NN
    ./configure –enable-so
    make
    make install

  4. Now you have Apache 2.x.NN available under /usr/local/apache2,
    configured with loadable module support and the standard MPM
    prefork. To test the installation use your normal procedure for
    starting the Apache server, e.g.:
    /usr/local/apache2/bin/apachectl start

and stop the server to go on with the configuration for PHP:
/usr/local/apache2/bin/apachectl stop

  1. Now, configure and build PHP. This is where you customize PHP with  
        这里开始就是php的安装,上面说的都是apache
    various options, like which extensions will be enabled. Run
    ./configure –help for a list of available options. In our example
    we’ll do a simple configure with Apache 2 and MySQL support.
    If you built Apache from source, as described above, the below
    example will match your path for apxs, but if you installed Apache
    some other way, you’ll need to adjust the path to apxs accordingly.
    Note that some distros may rename apxs to apxs2.
    cd ../php-NN
    ./configure
    –with-apxs2=/usr/local/apache2/bin/apxs –with-mysql
    make
    make install

If you decide to change your configure options after installation,
you’ll need to re-run the configure, make, and make install steps.      
  如果需要改变设置就重新安装
You only need to restart apache for the new module to take effect.
A recompile of Apache is not needed.
Note that unless told otherwise, ‘make install’ will also install
PEAR, various PHP tools such as phpize, install the PHP CLI, and
more.

  1. Setup your php.ini
    cp php.ini-development /usr/local/lib/php.ini

You may edit your .ini file to set PHP options. If you prefer
having php.ini in another location, use
–with-config-file-path=/some/path in step 5.                          
             自定义配置文件路径
If you instead choose php.ini-production, be certain to read the
list of changes within, as they affect how PHP behaves.

  1. Edit your httpd.conf to load the PHP module. The path on the right
    hand side of the LoadModule statement must point to the path of the
    PHP module on your system. The make install from above may have
    already added this for you, but be sure to check.
    LoadModule php5_module modules/libphp5.so                              
    在httpd配置文件中添加语句加载php模块
  2. Tell Apache to parse certain extensions as PHP. For example, let’s
    have Apache parse .php files as PHP. Instead of only using the
    Apache AddType directive, we want to avoid potentially dangerous  
    只使用AddType指令具有潜在危险
    uploads and created files such as exploit.php.jpg from being
    executed as PHP. Using this example, you could have any
    extension(s) parse as PHP by simply adding them. We’ll add .php to
    demonstrate.
    <FilesMatch \.php$>                                
    正则表达式,匹配所有“.php”结尾的文件名
    SetHandler application/x-httpd-php
    </FilesMatch>
    Or, if we wanted to allow .php, .php2, .php3, .php4, .php5, .php6,
    and .phtml files to be executed as PHP, but nothing else, we’d use
    this:
    <FilesMatch “\.ph(p[2-6]?|tml)$”>
    SetHandler application/x-httpd-php
    </FilesMatch>
    And to allow .phps files to be handled by the php source filter,
    and displayed as syntax-highlighted source code, use this:
    <FilesMatch “\.phps$”>

SetHandler application/x-httpd-php-source
</FilesMatch>
mod_rewrite may be used To allow any arbitrary .php file to be
displayed as syntax-highlighted source code, without having to
rename or copy it to a .phps file:
RewriteEngine On
RewriteRule (.*\.php)s$ $1 [H=application/x-httpd-php-source]
The php source filter should not be enabled on production systems,
where it may expose confidential or otherwise sensitive information
embedded in source code.

  1. Use your normal procedure for starting the Apache server, e.g.:
    /usr/local/apache2/bin/apachectl start

OR
service httpd restart

Following the steps above you will have a running Apache2 web server
with support for PHP as a SAPI module. Of course there are many more
configuration options available Apache and PHP. For more information
type ./configure –help in the corresponding source tree.

Apache may be built multithreaded by selecting the worker MPM, rather
than the standard prefork MPM, when Apache is built. This is done by
adding the following option to the argument passed to ./configure, in
step 3 above:
–with-mpm=worker

This should not be undertaken without being aware of the consequences
of this decision, and having at least a fair understanding of the
implications. The Apache documentation regarding » MPM-Modules
discusses MPMs in a great deal more detail.

Note:

兴發国际娱乐手机登录,The Apache MultiViews FAQ discusses using multiviews with PHP.

Note:

To build a multithreaded version of Apache, the target system must
support threads. In this case, PHP should also be built with
experimental Zend Thread Safety (ZTS). Under this configuration, not
all extensions will be available. The recommended setup is to build
Apache with the default prefork MPM-Module.
__________________________________________________________________

 

问题记录:

问题:AH00558: httpd: Could not reliably determine the server’s fully
qualified domain name, using localhost.localdomain. Set the ‘ServerName’
directive globally to suppress this message

**解决:进入apache安装目录、编辑httpd.conf文件,搜索”#ServerName”,添加ServerName
localhost:8080

**

# vi httpd.conf

#ServerName www.example.com:80

ServerName localhost:80

相应位置端口修改80,再重新启动apache 即可。

# /usr/local/apache/bin/apachectl -k restart

兴發国际娱乐手机登录 1

检验安装结果,本机浏览器打开     127.0.0.1:80    远程浏览器打开  
 ip:80    显示下方内容,到此配置部署成功!

0x02  php编译选项

具体参数含义可以用./configure
–help来查看。源自 

列表如下(部分参数未得到解释):

# 指定 php 安装目录

–prefix=/usr/local/php 

# 指定php.ini位置

–with-config-file-path=/usr/local/php/etc 

# mysql安装目录,对mysql的支持

–with-mysql=/usr/local/mysql

mysqli扩展技术不仅可以调用MySQL的存储过程、处理MySQL事务,而且还可以使访问数据库工作变得更加稳定。

–with-mysqli=/usr/local/mysql/bin/mysql_config  

整合 apache,apxs功能是使用mod_so中的LoadModule指令,加载指定模块到
apache,要求 apache 要打开SO模块

–with-apxs2=/usr/local/apache/bin/apxs 

# 选项指令 –with-iconv-dir 用于 PHP 编译时指定 iconv
在系统里的路径,否则会扫描默认路径。

–with-iconv-dir=/usr/local 

–with-freetype-dir   打开对freetype字体库的支持 

–with-jpeg-dir   打开对jpeg图片的支持 

–with-png-dir   打开对png图片的支持 

–with-zlib-dir   打开zlib库的支持,用于http压缩传输

–with-libxml-dir   打开libxml2库的支持

–disable-rpath    关闭额外的运行库文件 

–enable-bcmath    打开图片大小调整,用到zabbix监控的时候用到了这个模块

–enable-shmop –enable-sysvsem
 这样就使得你的PHP系统可以处理相关的IPC函数了。

–enable-inline-optimization  优化线程

–with-curl    打开curl浏览工具的支持 

–with-curlwrappers    运用curl工具打开url流 

–enable-mbregex

–enable-fpm 打上PHP-fpm 补丁后才有这个参数,CGI方式安装的启动程序

–enable-mbstring    多字节,字符串的支持 

–with-mcrypt                    mcrypt算法扩展

–with-mhash                     mhash算法扩展

–with-gd    打开gd库的支持 

–enable-gd-native-ttf   支持TrueType字符串函数库

–with-openssl      openssl的支持,加密传输https时用到的

–enable-pcntl   freeTDS需要用到的,可能是链接mssql 才用到

–enable-sockets     打开 sockets 支持

–with-xmlrpc    打开xml-rpc的c语言 

–enable-zip   打开对zip的支持 

–enable-ftp   打开ftp的支持 

–with-bz2    打开对bz2文件的支持        

–without-iconv   关闭iconv函数,字符集间的转换 

–with-ttf     打开freetype1.*的支持,可以不加了 

–with-xsl     打开XSLT 文件支持,扩展了libXML2库 ,需要libxslt软件 

–with-gettext     打开gnu 的gettext 支持,编码库用到 

–with-pear    打开pear命令的支持,PHP扩展用的 

–enable-calendar    打开日历扩展功能

–enable-exif    图片的元数据支持 

–enable-magic-quotes    魔术引用的支持 

–disable-debug    关闭调试模式 

–with-mime-magic=/usr/share/file/magic.mime      魔术头文件位置

 

CGI方式安装才用的参数

–enable-fastCGI            支持fastcgi方式启动PHP

–enable-force-CGI-redirect        重定向方式启动PHP

–with-ncurses         支持ncurses
屏幕绘制以及基于文本终端的图形互动功能的动态库

–with-gmp  应该是支持一种规范

–enable-dbase                     建立DBA 作为共享模块

–with-pcre-dir=/usr/local/bin/pcre-config      perl的正则库案安装位置

–disable-dmalloc

–with-gdbm                     dba的gdbm支持

–enable-sigchild

–enable-sysvshm

–enable-zend-multibyte         支持zend的多字节

–enable-wddx

–enable-soap

两种方法
 1.下载安装包安装
 2.使用yum在线安装

2.mysql安装部署

检查安装支持包yum -y install make gcc-c++ cmake bison-devel 
ncurses-devel

下载mysql57-community-release-el7-11.noarch.rpm

# yum localinstall mysql57-community-release-el7-11.noarch.rpm

# y

# yum install mysql-server              //安装mysql-server

# systemctl start mysqld.service        //启动mysql服务

# vim /var/log/mysqld.log                     
//找到mysql登录密码,可直接到下一步

# grep ‘password’ /var/log/mysqld.log

# mysql -uroot -p**********                  
//***********是上一步找到的登录密码

mysql> alter user ‘root’@’localhost’ identified by ‘12345678’        
 //修改mysql密码,如果提示密码不符合,设置复杂密码即可

mysql> quit                              //退出 mysql

0x03  安装过程

[root@localhost php-5.6.19]# ./configure –prefix=/usr/local/php
–with-mysql=/usr/local/mysql/ –with-openssl
–with-mysqli=/usr/local/mysql/bin/mysql_config –enable-mbstring
–with-freetype-dir –with-jpeg-dir –with-png-dir –with-zlib
–with-libxml-dir –enable-xml –enable-sockets
–with-apxs2=/usr/local/apache2/bin/apxs –with-config-file-path=/etc
–with-config-file-scan-dir=/etc/php.d –with-bz2
–enable-maintainer-zts

1、按照上面选项编译报错

checking libxml2 install dir… yes
checking for xml2-config path… 
configure: error: xml2-config not
found. Please check your libxml2 installation.

显示内容是xml2-config找不到,发现libxml2已经安装但是安装文件没有xml2-config,安装libxml2-devel后

[root@localhost php-5.6.19]# rpm -ql libxml2-devel
/usr/bin/xml2-config
……

2、继续编译,报错如下

checking for BZip2 support… yes
checking for BZip2 in default path… not found
configure: error: Please reinstall the BZip2 distribution

安装bzip2-devel

[root@localhost php-5.6.19]# yum install bzip2-devel

3、继续编译,报错如下

checking for specified location of the MySQL UNIX socket… no
configure: error: Cannot find libmysqlclient_r under
/usr/local/mysql/.
Note that the MySQL client library is not bundled anymore!

对于这个问题有个比较久远的帖子 

最终找到一个可行的办法就是,编译之前,先处理一下mysql的库,默认查找libmysqlclient_r.so,可是mysql默认为libmysqlclient.so,内容完全一样,做个链接即可
# cd /usr/local/mysql/lib/mysql/ 
# ln -s libmysqlclient.so.15.0.0 libmysqlclient_r.so

最后成功解决,可以make了,视个人系统环境不同,可能编译出错也不同,其时就是少什么库,就安装什么,对于编译错误找到一个总结比较好的帖子

Generating files
configure: creating ./config.status
creating main/internal_functions.c
creating main/internal_functions_cli.c
+——————————————————————–+
| License: |
| This software is subject to the PHP License, available in this |
| distribution in the file LICENSE. By continuing this installation |
| process, you are bound by the terms of this license agreement. |
| If you do not agree with the terms of this license, you must abort |
| the installation process at this point. |
+——————————————————————–+

Thank you for using PHP.

config.status: creating php5.spec
config.status: creating main/build-defs.h
config.status: creating scripts/phpize
config.status: creating scripts/man1/phpize.1
config.status: creating scripts/php-config
config.status: creating scripts/man1/php-config.1
config.status: creating sapi/cli/php.1
config.status: creating sapi/cgi/php-cgi.1
config.status: creating ext/phar/phar.1
config.status: creating ext/phar/phar.phar.1
config.status: creating main/php_config.h
config.status: executing default commands

make 完成之后,信息提示如下:

Generating phar.php
Generating phar.phar
PEAR package PHP_Archive not installed: generated phar will require
PHP’s phar extension be enabled.
clicommand.inc
directorytreeiterator.inc
invertedregexiterator.inc
directorygraphiterator.inc
pharcommand.inc
phar.inc

Build complete.
Don’t forget to run ‘make test’.

最终make install 安装完成

[root@localhost php-5.6.19]# make install
Installing PHP SAPI module: apache2handler
/usr/local/apache2/build/instdso.sh
SH_LIBTOOL=’/usr/local/apr/build-1/libtool’ libphp5.la
/usr/local/apache2/modules
/usr/local/apr/build-1/libtool –mode=install install libphp5.la
/usr/local/apache2/modules/
libtool: install: install .libs/libphp5.so
/usr/local/apache2/modules/libphp5.so
libtool: install: install .libs/libphp5.lai
/usr/local/apache2/modules/libphp5.la
libtool: install: warning: remember to run `libtool –finish
/usr/local/src/php-5.6.19/libs’
chmod 755 /usr/local/apache2/modules/libphp5.so
[activating module `php5′ in /etc/httpd/httpd.conf]
Installing shared extensions:
/usr/local/php/lib/php/extensions/no-debug-zts-20131226/
Installing PHP CLI binary: /usr/local/php/bin/
Installing PHP CLI man page: /usr/local/php/php/man/man1/
Installing PHP CGI binary: /usr/local/php/bin/
Installing PHP CGI man page: /usr/local/php/php/man/man1/
Installing build environment: /usr/local/php/lib/php/build/
Installing header files: /usr/local/php/include/php/
Installing helper programs: /usr/local/php/bin/
program: phpize
program: php-config
Installing man pages: /usr/local/php/php/man/man1/
page: phpize.1
page: php-config.1
Installing PEAR environment: /usr/local/php/lib/php/
[PEAR] Archive_Tar – installed: 1.4.0
[PEAR] Console_Getopt – installed: 1.4.1
[PEAR] Structures_Graph- installed: 1.1.1
[PEAR] XML_Util – installed: 1.3.0
[PEAR] PEAR – installed: 1.10.1
Wrote PEAR system config file at: /usr/local/php/etc/pear.conf
You may want to add: /usr/local/php/lib/php to your php.ini
include_path
/usr/local/src/php-5.6.19/build/shtool install -c ext/phar/phar.phar
/usr/local/php/bin
ln -s -f phar.phar /usr/local/php/bin/phar
Installing PDO headers: /usr/local/php/include/php/ext/pdo/


一 下载安装包安装

mysql 3306端口

mysql安装后默认是localhost访问,如果需要外部访问可以设置一个新的账号把host改为%,意味着所有ip均可以访问

grant all privilegeson*.* to’outUser’@’%’identifiedby’12’with grant
option

然后

flush privileges;

就可以使用outUser账户密码12来外部访问,有的时候无法访问需要打开防火墙开放端口

centos 7 中使用的是firewall-cmd命令

# firewall-cmd –list-all-zones    #查看所有的zone信息

# firewall-cmd –get-default-zone     #查看默认zone是哪一个

# firewall-cmd –zone=internal –change-zone=p3p1 
#临时修改接口p3p1所属的zone为internal

# firewall-cmd –add-service=http    #暂时开放http

# firewall-cmd –permanent –add-service=http  #永久开放http

# firewall-cmd –zone=public –add-port=80/tcp –permanent 
#在public中永久开放80端口

# firewall-cmd –permanent –zone=public –remove-service=ssh  
#从public zone中移除服务

# firewall-cmd –reload   #重新加载配置

0x03 后续工作

查看apache配置文件,发现已经加载了php模块

LoadModule alias_module modules/mod_alias.so
#LoadModule rewrite_module modules/mod_rewrite.so
LoadModule php5_module modules/libphp5.so

在apache安装目录下modules里面有php安装后新增的libphp5.so

[root@localhost php-5.6.19]#
ll /usr/local/apache2/modules/libphp5.so
-rwxr-xr-x. 1 root root 34524225 3月 7 00:12
/usr/local/apache2/modules/libphp5.so

以上即可说明php已经正常安装

1、在apache配置文件添加以下语句,实现php文件调用php模块解析

 AddType application/x-httpd-php .php

2、复制php源码根目录下的配置文件到/etc

cp php.ini-production /etc/php.ini

至此php已经可以正常工作了

1、 下载
   
2、解压
    tar -zxvf php-5.3.16.tar.gz
3、建立目标文件夹
    mkdir /usr/local/php
    也就是说等下安装的php要安装到这个文件夹里面
4、配置
    回到原来解压后的文件夹
    ./configure –prefix=/usr/local/php 
–with-apxs2=/usr/local/apache/bin/apxs

打开3306端口

firewall-cmd –add-port=3306/tcp –permanent

ok

兴發国际娱乐手机登录 2

0x04 测试

因为apache编译安装的网页文件目录为/usr/local/apache2/htdocs

在其中新增php文件测试能否正常解析,新增经典测试语句

[root@localhost php-5.6.19]# cat
/usr/local/apache2/htdocs/phpinfo.php
<?php
phpinfo();
?>

兴發国际娱乐手机登录 3

Ubuntu 16.10
开启PHP错误提示 
http://www.linuxidc.com/Linux/2016-10/136537.htm

Ubuntu 16.04环境中安装PHP7.0 Redis扩展
http://www.linuxidc.com/Linux/2016-09/135631.htm

在 CentOS 7.x / Fedora
21 上面体验 PHP 7.0 
http://www.linuxidc.com/Linux/2015-05/117960.htm 

CentOS 6.3 安装LNMP (PHP 5.4,MyySQL5.6)
http://www.linuxidc.com/Linux/2013-04/82069.htm 

在部署LNMP的时候遇到Nginx启动失败的2个问题
http://www.linuxidc.com/Linux/2013-03/81120.htm 

PHP源码安装、简单配置、测试及连接数据库
http://www.linuxidc.com/Linux/2016-10/135977.htm

《细说PHP》高清扫描PDF+光盘源码+全套教学视频
http://www.linuxidc.com/Linux/2014-03/97536.htm 

CentOS 7.2下编译安装PHP7.0.10+MySQL5.7.14+Nginx1.10.1 
http://www.linuxidc.com/Linux/2016-09/134804.htm

PHP
的详细介绍
:请点这里
PHP
的下载地址
:请点这里

本文永久更新链接地址:http://www.linuxidc.com/Linux/2017-03/142002.htm

兴發国际娱乐手机登录 4

–prefix=   确定程序的安装路径

3、php安装

依赖包要先安装上

php-mcrypt libmcrypt libmcrypt-devel  autoconf
 freetype gd jpegsrc libmcrypt libpng libpng-devel libjpeg libxml2
libxml2-devel zlib curl curl-devel

下载安装包          wget
http://au1.php.net/distributions/php-7.0.18.tar.gz

进入解压安装包

# ./configure –enable-fpm –with-pdo-mysql
–with-apxs2=/usr/local/apache/bin/apxs

*** 注: 在configure过程中, 可能会遇到下面的错误! Sorry, I cannot
run apxs. ***

Sorry, I cannot run apxs. Possible reasons follow:

  1. Perl is not installed

  2. apxs was not found. Try to pass the path using
    –with-apxs2=/path/to/apxs

  3. Apache was not built using –enable-so (the apxs usage page is
    displayed)

configure: error: Sorry, I cannot run apxs. Either you need to install
Perl or you need to pass the absolute path of apxs by using
–with-apxs=/absolute/path/to/apxs

–with-apxs2=/usr/local/apache/bin/apxs  
其中apxs是在安装Apache时产生的,到自己的apache寻找此文件
         apxs:是一个为Apache
HTTP服务器编译和安装扩展模块的工具,使之可以用由mod_so提供的LoadModule
       
指令在运行时加载到Apache服务器中。我的理解是通过这个工具把PHP模块动态加载到Apache中

解决方案:直接运行”/usr/local/apache/bin/apxs”这个脚本, 得到下面的错误提示:

bash: ./apxs: /replace/with/path/to/perl/interpreter: bad interpreter:
No such file or directory

感觉是apxs程序有问题, 但问题在哪里呢? “interpreter”是什么呢?
interpreter是”解释程序”!

运行”head -1 /usr/local/apache/bin/apxs”得到下面内容:

#!/replace/with/path/to/perl/interpreter -w

这里没有指明正确的perl执行程序的位置! 原来这就才是真正的问题原因所在!!!

打开apxs文件把这一行更改为”#!/usr/bin/perl -w”. 再运行php的configure,
一切正常!

配置完成

# make 编译完成Build complete  “Do you want to send this report
now?[Yns]:n”

# make install安装

/*****      以下安装记录

[root@localhost php-7.0.18]# make install

Installing PHP SAPI module:      apache2handler

/usr/local/apache/build/instdso.sh
SH_LIBTOOL=’/usr/local/apr/build-1/libtool’ libphp7.la
/usr/local/apache/modules

/usr/local/apr/build-1/libtool –mode=install install libphp7.la
/usr/local/apache/modules/

install .libs/libphp7.so /usr/local/apache/modules/libphp7.so

install .libs/libphp7.lai /usr/local/apache/modules/libphp7.la

libtool: install: warning: remember to run `libtool –finish
/tmp/soft/php-7.0.18/libs’

chmod 755 /usr/local/apache/modules/libphp7.so

[activating module `php7′ in /usr/local/apache/conf/httpd.conf]

Installing shared extensions:   
/usr/local/lib/php/extensions/no-debug-zts-20151012/

Installing PHP CLI binary:        /usr/local/bin/

Installing PHP CLI man page:      /usr/local/php/man/man1/

Installing PHP FPM binary:        /usr/local/sbin/

Installing PHP FPM defconfig:    /usr/local/etc/

Installing PHP FPM man page:      /usr/local/php/man/man8/

Installing PHP FPM status page:  /usr/local/php/php/fpm/

Installing phpdbg binary:        /usr/local/bin/

Installing phpdbg man page:      /usr/local/php/man/man1/

Installing PHP CGI binary:        /usr/local/bin/

Installing PHP CGI man page:      /usr/local/php/man/man1/

Installing build environment:    /usr/local/lib/php/build/

Installing header files:          /usr/local/include/php/

Installing helper programs:      /usr/local/bin/

program: phpize

program: php-config

Installing man pages:            /usr/local/php/man/man1/

page: phpize.1

page: php-config.1

Installing PEAR environment:      /usr/local/lib/php/

[PEAR] Archive_Tar    – installed: 1.4.2

[PEAR] Console_Getopt – installed: 1.4.1

[PEAR] Structures_Graph- installed: 1.1.1

[PEAR] XML_Util      – installed: 1.4.2

[PEAR] PEAR          – installed: 1.10.3

Wrote PEAR system config file at: /usr/local/etc/pear.conf

You may want to add: /usr/local/lib/php to your php.ini include_path

/tmp/soft/php-7.0.18/build/shtool install -c ext/phar/phar.phar
/usr/local/bin

ln -s -f phar.phar /usr/local/bin/phar

Installing PDO headers:          /usr/local/include/php/ext/pdo/

******/   以上安装记录

安装完成

部署php

进入php安装解压包

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

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

# vim /usr/local/etc/php-fpm.conf

最后一行改为

include=/usr/local/etc/php-fpm.d/*.conf

:wq保存退出

# cp /usr/local/etc/php-fpm.d/www.conf.default
/usr/local/etc/php-fpm.d/php-fpm.conf

# cp sapi/fpm/php-fpm /usr/local/bin(php之前版本需要)

# vim /usr/local/php/php.ini      后面路径改为:/usr/local/lib/php.ini

cgi.fix_pathinfo=0(找到这一行修改)

# vim /usr/local/etc/php-fpm.d/php-fpm.conf

user = nobody

group = nobody

listen = 127.0.0.1:9000

启动服务

# cd /usr/local/bin

# php-fpm(启动)

# ps aux | grep php-fpm(查看进程,是否启动)

# kill php-fpm(关闭php)

-bash: kill: php-fpm: 参数必须是进程或任务 ID

# killall php-fpm          //如果没有kill命令输入   #  yum install
psmisc

# ps -aux | grep php-fpm(查看关闭结果)

root      11039  0.0  0.0 112664  968 pts/0    S+  21:10  0:00 grep
–color=auto php-fpm

# php-fpm(启动)

这个apxs很重要,是apache 增加扩展模块 需要的!!!

注:如何安裝 vim 呢?

# rpm -qa|grep vim

输入rpm -qa|grep vim 命令, 如果 vim 已经正确安裝,会返回下面的三行代码:

vim-enhanced-7.4.160-7.el7

vim-minimal-7.4.160-7.el7

vim-common-7.4.160-7.el7

如果少了其中的某一条,比如 vim-enhanced 的,就用命令 yum -y install
vim-enhanced 来安裝:

yum -yinstallvim-enhanced

如果上面的三条一条都沒有返回, 可以直接用 yum -y install vim* 命令

yum -y install vim*

 

4、apache配置php

出现错误:configure: error: xml2-config not found. Please check your
libxml2 installation.

运行yum install libxml2,然后再运行yum install
libxml2-devel安装完毕后,重新运行上面的./configure命令。、

 

编译完成时会列出一些配置文件信息,需要注意

Generating files

configure: creating ./config.status

creating main/internal_functions.c

creating main/internal_functions_cli.c

+——————————————————————–+

| License:                                                          
|

| This software is subject to the PHP License, available in this    
|

| distribution in the file LICENSE.  By continuing this installation
|

| process, you are bound by the terms of this license agreement.    
|

| If you do not agree with the terms of this license, you must abort
|

| the installation process at this point.                          
 |

+——————————————————————–+

 

Thank you for using PHP.

 

config.status: creating php5.spec

config.status: creating main/build-defs.h

config.status: creating scripts/phpize

config.status: creating scripts/man1/phpize.1

config.status: creating scripts/php-config

config.status: creating scripts/man1/php-config.1

config.status: creating sapi/cli/php.1

config.status: creating sapi/cgi/php-cgi.1

config.status: creating ext/phar/phar.1

config.status: creating ext/phar/phar.phar.1

config.status: creating main/php_config.h

发表评论

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