`
arganzheng
  • 浏览: 103501 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
文章分类
社区版块
存档分类
最新评论

Install AMP from source under Linux(Ubuntu)

阅读更多

Install AMP from source under Linux(Ubuntu)

2011-02-05 星期六 晴朗

Install AMP from source under Linux(Ubuntu)

安装Apache2.2.17

Follow the instruction in the offical website, it should work:
Overview for the impatient

Download $ lynx http://httpd.apache.org/download.cgi
Extract $ gzip -d httpd-2_0_NN.tar.gz 
$ tar xvf httpd-2_0_NN.tar
Configure $ ./configure --prefix=PREFIX
Compile $ make
Install $ make install
Customize $ vi PREFIX/conf/httpd.conf
Test $ PREFIX/bin/apachectl start

说明:上面的./configure只指定了安装目录,这种编译方式是静态编译方式,并且只包含最核型的模块,如下:

forrest@forrest-laptop:~/Install/apache2/modules$ ls
httpd.exp  libphp5.so

说明:libphp5.so是我后来编译php才进入的。可以用httpd -l选项查看静态编译进入的模块(注意查看不到动态加载的模块的,如mod_php5.so)

forrest@forrest-laptop:~/Install/apache2$ bin/httpd -l
Compiled in modules:
  core.c
  mod_authn_file.c
  mod_authn_default.c
  mod_authz_host.c
  mod_authz_groupfile.c
  mod_authz_user.c
  mod_authz_default.c
  mod_auth_basic.c
  mod_include.c
  mod_filter.c
  mod_log_config.c
  mod_env.c
  mod_setenvif.c
  mod_version.c
  prefork.c
  http_core.c
  mod_mime.c
  mod_status.c
  mod_autoindex.c
  mod_asis.c
  mod_cgi.c
  mod_negotiation.c
  mod_dir.c
  mod_actions.c
  mod_userdir.c
  mod_alias.c
  mod_so.c

这样的编译方式往往只能满足最小化的需求,对于一个比较大型的网站,往往需要更多的module,比如mod_rewrite,比如mod_ssl,比如mod_jk,etc. 主要有两种解决方案:
第一种方式是重新安装,这就是静态编译模块的坏处,一旦需要新增或者修改删除模块,需要重新编译整个apache。所以建议下次如果是重新编译的话,务必改成动态链接。如果要支持ssl,那么需要在编译的时候增加编译选项:--enable-ssl=shared。第二种方式是,编译成动态链接库(so),配置httpd.conf,让apache启动时加载(LoadModules)。
官方文档写的很详细,也很精彩:http://httpd.apache.org/docs/2.0/dso.html

使用如下编译方式,也不会生成很多modules:

forrest@forrest-laptop:~/Sources/httpd-2.2.17$ ./configure --prefix=/home/forrest/Install/apache2_dynamic --enable-modules=all --enable-so 
forrest@forrest-laptop:~/Install/apache2_dynamic/modules$ ls
httpd.exp

加上 --enable-mods-shared=all之后,就有很多modules了:

forrest@forrest-laptop:~/Sources/httpd-2.2.17$ ./configure --prefix=/home/forrest/Install/apache2_dynamic3 --enable-modules=all --enable-so --enable-mods-shared=all

forrest@forrest-laptop:~/Install/apache2_dynamic3/modules$ ls
httpd.exp           mod_authn_default.so    mod_cern_meta.so  mod_expires.so     mod_log_forensic.so  mod_status.so
mod_actions.so      mod_authn_file.so       mod_cgi.so        mod_ext_filter.so  mod_logio.so         mod_substitute.so
mod_alias.so        mod_authz_dbm.so        mod_dav_fs.so     mod_filter.so      mod_mime_magic.so    mod_unique_id.so
mod_asis.so         mod_authz_default.so    mod_dav.so        mod_headers.so     mod_mime.so          mod_userdir.so
mod_auth_basic.so   mod_authz_groupfile.so  mod_dbd.so        mod_ident.so       mod_negotiation.so   mod_usertrack.so
mod_auth_digest.so  mod_authz_host.so       mod_deflate.so    mod_imagemap.so    mod_reqtimeout.so    mod_version.so
mod_authn_anon.so   mod_authz_owner.so      mod_dir.so        mod_include.so     mod_rewrite.so       mod_vhost_alias.so
mod_authn_dbd.so    mod_authz_user.so       mod_dumpio.so     mod_info.so        mod_setenvif.so
mod_authn_dbm.so    mod_autoindex.so        mod_env.so        mod_log_config.so  mod_speling.so

forrest@forrest-laptop:~/Install/apache2_dynamic3/modules$ ls | wc -l
52

即使设置为all,仍然是有些模块有,有些模块没有:

forrest@forrest-laptop:~/Install/apache2_dynamic3/modules$ ls | grep ssl
forrest@forrest-laptop:~/Install/apache2_dynamic3/modules$ ls | grep rewrite
mod_rewrite.so

对于ssl模块,需要在编译的时候再加上--enable-ssl编译选项。但是需要注意的是ssl需要openssl的头文件,所以需要先安装openssl。

改成most,变成47个。

forrest@forrest-laptop:~/Sources/httpd-2.2.17$ ./configure --prefix=/home/forrest/Install/apache2_dynamic --enable-modules=all --enable-so --enable-mods-shared=most
forrest@forrest-laptop:~/Install/apache2_dynamic/modules$ ls
httpd.exp           mod_authn_dbm.so        mod_authz_user.so  mod_dumpio.so      mod_include.so      mod_setenvif.so
mod_actions.so      mod_authn_default.so    mod_autoindex.so   mod_env.so         mod_info.so         mod_speling.so
mod_alias.so        mod_authn_file.so       mod_cgi.so         mod_expires.so     mod_log_config.so   mod_status.so
mod_asis.so         mod_authz_dbm.so        mod_dav_fs.so      mod_ext_filter.so  mod_logio.so        mod_substitute.so
mod_auth_basic.so   mod_authz_default.so    mod_dav.so         mod_filter.so      mod_mime.so         mod_userdir.so
mod_auth_digest.so  mod_authz_groupfile.so  mod_dbd.so         mod_headers.so     mod_negotiation.so  mod_version.so
mod_authn_anon.so   mod_authz_host.so       mod_deflate.so     mod_ident.so       mod_reqtimeout.so   mod_vhost_alias.so
mod_authn_dbd.so    mod_authz_owner.so      mod_dir.so         mod_imagemap.so    mod_rewrite.so
forrest@forrest-laptop:~/Install/apache2_dynamic/modules$ ls | wc -l
47

发现其实其关键作用的只是这个编译选项: --enable-mods-shared=most

forrest@forrest-laptop:~/Sources/httpd-2.2.17$ ./configure --prefix=/home/forrest/Install/apache2_dynamic --enable-mods-shared=most
forrest@forrest-laptop:~/Install/apache2_dynamic/modules$ ls | wc -l
47

安装mod_ssl,这个module在apache的源码中,只需要增加--enable-ssl编译选项,就可以了。不像mod_jk和mod_php,需要另外下载代码,用apxs安装。
不过需要注意的是ssl需要openssl的头文件,所以需要先安装openssl。

checking whether to enable mod_ssl... checking dependencies
checking for SSL/TLS toolkit base... none
checking for OpenSSL version... checking openssl/opensslv.h usability... no
checking openssl/opensslv.h presence... no
checking for openssl/opensslv.h... no
checking openssl/ssl.h usability... no
checking openssl/ssl.h presence... no
checking for openssl/ssl.h... no
no OpenSSL headers found
checking for SSL-C version... checking sslc.h usability... no
checking sslc.h presence... no
checking for sslc.h... no
no SSL-C headers found
configure: error: ...No recognized SSL/TLS toolkit detected

forrest@forrest-laptop:~/Sources/httpd-2.2.17$ sudo apt-get install openssl libssl-dev

forrest@forrest-laptop:~/Sources/httpd-2.2.17$ ./configure --prefix=/home/forrest/Install/apache2_dynamic --enable-mods-shared=most --enable-ssl 
forrest@forrest-laptop:~/Install/apache2_dynamic/modules$ ls
httpd.exp           mod_authn_dbm.so        mod_authz_user.so  mod_dumpio.so      mod_include.so      mod_setenvif.so
mod_actions.so      mod_authn_default.so    mod_autoindex.so   mod_env.so         mod_info.so         mod_speling.so
mod_alias.so        mod_authn_file.so       mod_cgi.so         mod_expires.so     mod_log_config.so   mod_ssl.so
mod_asis.so         mod_authz_dbm.so        mod_dav_fs.so      mod_ext_filter.so  mod_logio.so        mod_status.so
mod_auth_basic.so   mod_authz_default.so    mod_dav.so         mod_filter.so      mod_mime.so         mod_substitute.so
mod_auth_digest.so  mod_authz_groupfile.so  mod_dbd.so         mod_headers.so     mod_negotiation.so  mod_userdir.so
mod_authn_anon.so   mod_authz_host.so       mod_deflate.so     mod_ident.so       mod_reqtimeout.so   mod_version.so
mod_authn_dbd.so    mod_authz_owner.so      mod_dir.so         mod_imagemap.so    mod_rewrite.so      mod_vhost_alias.so
forrest@forrest-laptop:~/Install/apache2_dynamic/modules$ ls |wc -l
48

2. 安装MySQL5.1.7

参考文档:http://dev.mysql.com/doc/refman/5.1/en/installing-source-distribution.html

# Preconfiguration setup
shell> groupadd mysql
shell> useradd -g mysql mysql
# Beginning of source-build specific instructions
shell> tar zxvf mysql-VERSION.tar.gz
shell> cd mysql-VERSION
shell> ./configure --prefix=/home/forrest/Install/mysql
shell> make
shell> make install
# End of source-build specific instructions
# Postinstallation setup
shell> cd /usr/local/mysql
shell> chown -R mysql .
shell> chgrp -R mysql .
shell> bin/mysql_install_db --user=mysql --with-datadir=/home/forrest/Install/mysql/data
shell> chown -R root .
shell> chown -R mysql var
# Next command is optional
shell> cp support-files/my-medium.cnf /etc/my.cnf
shell> add basedir and datadir to [mysqld]
shell> bin/mysqld_safe --user=mysql &
# Next command is optional
shell> cp support-files/mysql.server /etc/init.d/mysql.server
forrest@forrest-laptop:~/Install/mysql$ bin/mysql_install_db --user=mysql --basedir=/home/forrest/Install/mysql --datadir=/home/forrest/Install/mysql/data
Installing MySQL system tables...
OK
Filling help tables...
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

/home/forrest/Install/mysql/bin/mysqladmin -u root password 'new-password'
/home/forrest/Install/mysql/bin/mysqladmin -u root -h forrest-laptop password 'new-password'

Alternatively you can run:
/home/forrest/Install/mysql/bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:
cd /home/forrest/Install/mysql ; /home/forrest/Install/mysql/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
cd /home/forrest/Install/mysql/mysql-test ; perl mysql-test-run.pl

Please report any problems with the /home/forrest/Install/mysql/scripts/mysqlbug script!

forrest@forrest-laptop:~/Install/mysql$ 

set the root password:
/home/forrest/Install/mysql/bin/mysqladmin -u root password 'new-password'
update the root password:
mysql> update user set password=PASSWORD("NEWPASSWORD") where User='root';
mysql> flush privileges;
mysql> quit

3. PHP5.2.7

forrest@forrest-laptop:~/Sources/php-5.2.17$ ./configure --with-apxs2=/home/forrest/Install/apache2/bin/apxs --with-mysql=/home/forrest/Install/mysql/
forrest@forrest-laptop:~/Sources/php-5.2.17$ make
forrest@forrest-laptop:~/Sources/php-5.2.17$ sudo make install
[sudo] password for forrest: 
Installing PHP SAPI module:       apache2handler
/home/forrest/Install/apache2/build/instdso.sh SH_LIBTOOL='/home/forrest/Install/apache2/build/libtool' libphp5.la /home/forrest/Install/apache2/modules
/home/forrest/Install/apache2/build/libtool --mode=install cp libphp5.la /home/forrest/Install/apache2/modules/
cp .libs/libphp5.so /home/forrest/Install/apache2/modules/libphp5.so
cp .libs/libphp5.lai /home/forrest/Install/apache2/modules/libphp5.la
libtool: install: warning: remember to run `libtool --finish /home/forrest/Sources/php-5.2.17/libs'
chmod 755 /home/forrest/Install/apache2/modules/libphp5.so
[activating module `php5' in /home/forrest/Install/apache2/conf/httpd.conf]
Installing PHP CLI binary:        /usr/local/bin/
Installing PHP CLI man page:      /usr/local/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/man/man1/
  page: phpize.1
  page: php-config.1
Installing PEAR environment:      /usr/local/lib/php/
[PEAR] Archive_Tar    - installed: 1.3.7
[PEAR] Console_Getopt - installed: 1.2.3
[PEAR] Structures_Graph- installed: 1.0.3
[PEAR] XML_Util       - installed: 1.2.1
[PEAR] PEAR           - installed: 1.9.1
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
Installing PDO headers:          /usr/local/include/php/ext/pdo/
forrest@forrest-laptop:~/Sources/php-5.2.17$
Enabling the mysqli Extension on Linux/Unix
Enabling the mysqli extension on the Linux/Unix platform is accomplished by configuring PHP using the --with-mysqli flag. This flag should point to the location of the mysql_config program available to MySQL 4.1 and greater.

关于PHP的配置文件——php.ini
与MySQL一样,PHP也有自己的配置文件,叫做php.ini,与MySQL一样,这个配置文件需要用户自己cp到某个特定的目录(配置目录,编译选项--with-config-file-path 指定)。
如果没有指定,默认是/usr/local/lib/目录下。可以使用phpinfo()查看:

 

Configuration File (php.ini) Path /usr/local/lib
Configuration File (php.ini) Path /usr/local/lib

 

PHP comes bundled with a configuration file that controls many aspects of PHP's behavior. This file is known as php.ini, but it was originally named php.ini-dist. You need to copy this file to its appropriate location and rename it php.ini. The later section "Configuring PHP" examines php.ini's purpose and contents in detail. Note that you can place this configuration file anywhere you please, but if you choose a nondefault location, you also need to configure PHP using the --with-config-file-path option. Also note that there is another
default configuration file at your disposal, php.ini-recommended. This file sets various nonstandard settings and is intended to better secure and optimize your installation, although this configuration may not be fully compatible with some of the legacy applications. Consider using this file in lieu of php.ini-dist. To use this file, execute the following command:
%>cp php.ini-recommended /usr/local/lib/php.ini

在Unix上,php.ini文件缺省放在/usr/local/lib上面,因为缺省的存放路径是<install-path> /lib,但是可以在编译的时候使用--wthi-config-file-path参数来修改php.ini的存放位置,例如你可以使用--with-config-file-path=/etc把它存放到/etc下面,然后可以从源码包中拷贝php.ini-dist到/etc/php.ini并修改使之满足需要。

4. phpMyAdmin

http://www.phpmyadmin.net/documentation/

5. Testing Your Installation

The best way to verify your PHP installation is by attempting to execute a PHP script. Open a text editor and add the following lines to a new file:

<?php
phpinfo();
?>

Save this file as phpinfo.php. If you're running Apache, save it to the htdocs directory. If you're
running IIS, save the file to C:\inetpub\wwwroot.


关于PEAR:

PEAR (the acronym for PHP Extension and Application Repository) is one of the most effective means for finding and reusing great PHP code. Inspired by Perl's wildly popular CPAN (Comprehensive Perl Archive Network), the PEAR project was started in 1999 by noted PHP developer Stig Bakken, with the first stable release bundled with PHP version 4.3.0.

可以使用pear管理(安装卸载、升降级)packages。然后应用程序只需要将需要使用的packages Including进来。
Including a Package within Your Scripts

Using an installed PEAR package is simple. All you need to do is make the package contents available to
your script with include or preferably require. Keep in mind that you need to add the PEAR base
directory to your include_path directive; otherwise, an error similar to the following will occur:
Fatal error: Class 'MDB2' not found in /home/www/htdocs/book/11/database.php
on line 3
Those of you with particularly keen eyes might have noticed that in the earlier example involving
the Numbers_Roman package, a directory was also referenced:
require_once("Numbers/Roman.php");

像mysql和gd这样的库没有在PEAR中,只能重新编译PHP模块。

分享到:
评论

相关推荐

    linux Ubuntu下安装 Source insight

    "Linux Ubuntu下安装Source Insight" Linux Ubuntu下安装Source Insight是指在Ubuntu操作系统下安装Source Insight软件,从而实现在Linux平台下使用Source Insight编辑和阅读源码。本文将详细介绍如何在Ubuntu下...

    Linux安装Photoshop CS6 Install Photoshop CS6 on Linux Ubuntu 13.04

    这篇博客文章“Linux安装Photoshop CS6 Install Photoshop CS6 on Linux Ubuntu 13.04”似乎提供了详细步骤,帮助用户在Ubuntu 13.04上安装这款著名的图像编辑软件。 首先,你需要确保你的系统已经更新到最新状态,...

    Ubuntu source insight install

    在ubuntu下安装source insight工具的方法

    Linux Ubuntu下安装酷狗

    酷狗音乐linux版本还未出现,现在使用的是web版,具体安装如下: 先安装预装软件:命令 sudo apt-get install python-gtk2 python-webkit 再下载安装包即可。

    Install under Linux .pps

    Install under Linux 安装说明

    Install-Source-Insight-under-Linux.rar_insight_source insight

    **源码阅读神器Source Insight在Linux环境下的安装指南** Source Insight是一款广受欢迎的源代码查看和编辑工具,尤其适用于C/C++、Java等编程语言。它提供了强大的代码高亮、跳转、查找等功能,帮助开发者高效地...

    完全卸载wine和Source Insight的方法

    在Ubuntu环境下,彻底清除不再需要的应用程序,尤其是像Wine和Source Insight这样的工具,有时会变得相当复杂。这是因为Linux系统下的一些应用卸载并不像Windows那样简单直接,残留的配置文件、链接或依赖库可能会...

    source insight linux安装版本

    在Linux环境下安装Source Insight,需要一些额外的步骤,因为官方主要面向Windows平台。本文将详细介绍如何在Linux系统中安装和使用Source Insight。 首先,你需要获取Source Insight的Linux版本。在这个案例中,...

    install_linux3.0.4_ubuntu

    install_linux3.0.4_ubuntu is a document that have instruction to update your kernel to linux 3.0.4!

    Linux(Ubuntu 18.04) 罗技(logitech) G29 游戏方向盘数据解析(支持自定义开发)

    因项目需要,将在ubuntu下扩展产品,实现windows/linux下支持远程驾驶 依次执行如下命令 apt-get install jstest-gtk apt-get install cmake apt-get install sigc++ apt-get install gtkmm-2.4 apt-get install ...

    linux ubuntu下的merge小工具

    在Linux Ubuntu系统中,"merge"通常指的是合并两个或多个文本文件或代码文件的过程,而"Meld"是一款非常实用的图形化对比和合并工具。Meld不仅提供了文件的对比功能,还能帮助用户有效地合并差异,是Linux开发者和...

    SourceInsight for linux

    对于基于Ubuntu或者Debian的系统,可以通过命令行使用`sudo apt-get install wine`来安装Wine。这个命令会自动处理依赖关系并下载安装所需组件。如果你的Linux发行版不是这些,你可能需要查找对应的包管理器或使用第...

    linux ubuntu文献课件

    Linux Ubuntu 文献课件是专为想要学习和掌握Ubuntu Linux操作系统设计的一套全面教程。Ubuntu是一种基于Debian的开源Linux发行版,以其用户友好、安全稳定的特点受到全球用户的喜爱,尤其适合初学者入门。本课件旨在...

    WebLogic install under linux

    WebLogic在linux下的安装方法,很实用。

    Ubuntu20.04 lts Linux 蓝牙驱动

    标题 "Ubuntu20.04 LTS Linux 蓝牙驱动" 涉及的主要知识点是Linux操作系统中的蓝牙驱动程序安装,特别是针对Ubuntu 20.04长期支持版(LTS)的操作。Ubuntu是一个基于Debian的开源GNU/Linux发行版,而LTS版本则提供...

    Linux Ubuntu常用命令大全

    Linux Ubuntu常用命令大全 Linux操作系统的Ubuntu版本提供了许多实用的命令,以下是常用的命令大全,涵盖文件、文件夹管理、系统管理、打包、解压、make编译和apt命令等方面。 文件/文件夹管理 * ls:列出当前...

    qt-creator-opensource-linux-x86-3.5.1.run

    对于想要在linux Ubuntu14.04上部署qt的朋友,可以下载这个qt包,一路next下载完毕,接下来在终端执行sudo apt-get install qt5-default qtcreator安装qtcreator,即可在Ubuntu中搭建好qt

    pmLinux-Ubuntu-12.04-20.10-x86-arm-Driver

    《Ubuntu在ARM架构下的触屏驱动安装与配置详解——基于pmLinux-Ubuntu-12.04-20.10-x86-arm-Driver》 在嵌入式系统和物联网领域,Ubuntu操作系统因其开源、稳定且丰富的软件库而备受青睐。尤其是针对ARM架构的设备...

    Linux(Ubuntu17.04)vmtools的Linux.iso下载

    这里我们将深入探讨“Linux(Ubuntu17.04)vmtools的Linux.iso下载”这个主题。 首先,`Ubuntu 17.04` 是一款基于Debian的开源操作系统,由Ubuntu团队开发,其内核版本为4.10。Ubuntu 17.04,代号“Zesty Zapus”,...

Global site tag (gtag.js) - Google Analytics