设为首页 收藏本站
查看: 722|回复: 0

[经验分享] Apache与PHP的整合(编译安装),不涉及MySQL数据库的整合

[复制链接]

尚未签到

发表于 2015-8-2 13:53:06 | 显示全部楼层 |阅读模式
最近开始看《Ajax for Dummies》,书里的示例一些是基于php的,所以需要建个php服务器才可以演示这些示例。拿自己的Ubuntu试了一下。
1.准备工作
先分别从http://httpd.apache.org和http://www.php.net下载回httpd2和php5的源码包,分别为:httpd-2.2.3.tar.gz和php-5.2.0.tar.gz。
在编译之前,先大概浏览一下它们的INSTALL文件,看看都有哪些说明。
httpd的说明很简单,再看php的说明,里面有一段是:
  Prerequisite knowledge and software for compiling:
     * Basic Unix skills (being able to operate "make" and a C compiler)
     * An ANSI C compiler
     * flex: Version 2.5.4
     * bison: Version 1.28 (preferred), 1.35, or 1.75
     * A web server
     * Any module specific components (such as gd, pdf libs, etc.)
也 就是说,要有C编译器,flex,bison,一个web服务器,还要一些模块的组件。由于计划用apache做web服务器程序,基本编译环境早就装好 (如果没有,就sudo apt-get install build-essential 安装之。),就看flex和bison这两个东东了。
新立得里面搜索了一下,有是有,就不知道是不是版本太陈旧了。还是问了一下google,得到了flex和bison的地址,http://www.gnu.org/software/flex/和http://www.gnu.org/software/bison/。分别下载回源码包,然后先编译安装这两个东西,同样看了看说明,直接
./configure
make
sudo make install
2.开始安装Apache
再回过头来看php的说明。
文件里先讲到的是apache1.3.×的版本如何编译,这里我下载的是2.2.3版的Apache了,直接跳过这一节,看关于Apache2的编译安装说明。
   Example 2-4. Installation Instructions (Apache 2 Shared Module
   Version)
1.  gzip -d httpd-2_0_NN.tar.gz
2.  tar xvf httpd-2_0_NN.tar
3.  gunzip php-NN.tar.gz
4.  tar -xvf php-NN.tar
5.  cd httpd-2_0_NN
6.  ./configure --enable-so
7.  make
8.  make install
    Now you have Apache 2.0.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.

前 面还有一点版本方面的说明就不管了,根据示例,进入httpd的文件夹,直接执行  ./configure  --enable-so来编译apache就可以了。考虑到,Apache在我机器上待的时间可能不长,如果按默认的安装,安装到/usr/local下 面去,我可能过几天就忘了,找不到了。就用prefix参数修改一下安装路径。   
./configure --enable-so --prefix=/opt/apache然 后就是等待配置的完成,生成Makefile,完了之后就 make 一下,现在可以去泡杯茶了。水烧开,茶泡好,sudo make install   完成Apache的安装。兴冲冲地转到/opt/apache/bin目录, sudo ./apachectl start  ,然后在FF里localhost一下,“It works!”,em,不错,apache已经可以运行了。 赶紧,sudo ./apachectl  stop 。
3.开始编译PHP5
还是看说明:
9.  cd ../php-NN
10. Now, configure your PHP.  This is where you customize your PHP
    with various options, like which extensions will be enabled.  Do a
    ./configure --help for a list of available options.  In our example
    we'll do a simple configure with Apache 2 and MySQL support.  Your
    path to apxs may differ, in fact, the binary may even be named apxs2 on
    your system.
      ./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql
11. make
12. make install
    If you decide to change your configure options after installation,
    you only need to repeat the last three 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.

进 入到php源码目录,示例中是  ./configure --with-apxs2=/usr/local/apache2/bin/apxs  --with-mysql这样的,但是,我不需要安装mysql,apache的安装目录也不是/usr/local/apache2,所以,稍做修改   
./configure --with-apxs2=/opt/apache/bin/apxs --prefix=/opt/php然后,除了等就还是等了 :( 机子破了点,没办法。(在等待的时间里,“我还抽了点时间洗了个澡,换了件衣服~~”)。然后,make 一下,这次,我去会了会新导师~~~,回来的时候,sudo make install 。到此,编译安装结束。
4.配置Apache,是php能够运行起来
再看说明:
13. Setup your php.ini
    cp php.ini-dist /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 10.
    If you instead choose php.ini-recommended, be certain to read the list
    of changes within, as they affect how PHP behaves.
14. 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.
    For PHP 4:
      LoadModule php4_module modules/libphp4.so
    For PHP 5:
      LoadModule php5_module modules/libphp5.so
15. Tell Apache to parse certain extensions as PHP.  For example,
    let's have Apache parse the .php extension as PHP.  You could
    have any extension(s) parse as PHP by simply adding more, with
    each separated by a space.  We'll add .phtml to demonstrate.
      AddType application/x-httpd-php .php .phtml
    It's also common to setup the .phps extension to show highlighted PHP
    source, this can be done with:
      AddType application/x-httpd-php-source .phps
16. Use your normal procedure for starting the Apache server, e.g.:
      /usr/local/apache2/bin/apachectl start
   Following the steps above you will have a running Apache 2.0 with
   support for PHP as SAPI module. Of course there are many more
   configuration options available for both, Apache and PHP. For more
   information use ./configure --help in the corresponding source tree.
   In case you wish to build a multithreaded version of Apache 2.0 you
   must overwrite the standard MPM-Module prefork either with worker or
   perchild. To do so append to your configure line in step 6 above
   either the option --with-mpm=worker or --with-mpm=perchild. Take care
   about the consequences and understand what you are doing. For more
   information read the Apache documentation about the MPM-Modules.
经过这样简单的步骤,再启动Apache,就可以执行php脚本了。  
  
  
  
  摘自:http://www.blogjava.net/xiaosilent/archive/2006/11/23/83058.html

  
  
  
  
  
  

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-93368-1-1.html 上篇帖子: apache common 工具包 下篇帖子: apache:一个ip绑定多个域名的问题
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表