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模块。

深度学习是机器学习的一个子领域,它基于人工神经网络的研究,特别是利用多层次的神经网络来进行学习和模式识别。深度学习模型能够学习数据的高层次特征,这些特征对于图像和语音识别、自然语言处理、医学图像分析等应用至关重要。以下是深度学习的一些关键概念和组成部分: 1. **神经网络(Neural Networks)**:深度学习的基础是人工神经网络,它是由多个层组成的网络结构,包括输入层、隐藏层和输出层。每个层由多个神经元组成,神经元之间通过权重连接。 2. **前馈神经网络(Feedforward Neural Networks)**:这是最常见的神经网络类型,信息从输入层流向隐藏层,最终到达输出层。 3. **卷积神经网络(Convolutional Neural Networks, CNNs)**:这种网络特别适合处理具有网格结构的数据,如图像。它们使用卷积层来提取图像的特征。 4. **循环神经网络(Recurrent Neural Networks, RNNs)**:这种网络能够处理序列数据,如时间序列或自然语言,因为它们具有记忆功能,能够捕捉数据中的时间依赖性。 5. **长短期记忆网络(Long Short-Term Memory, LSTM)**:LSTM 是一种特殊的 RNN,它能够学习长期依赖关系,非常适合复杂的序列预测任务。 6. **生成对抗网络(Generative Adversarial Networks, GANs)**:由两个网络组成,一个生成器和一个判别器,它们相互竞争,生成器生成数据,判别器评估数据的真实性。 7. **深度学习框架**:如 TensorFlow、Keras、PyTorch 等,这些框架提供了构建、训练和部署深度学习模型的工具和库。 8. **激活函数(Activation Functions)**:如 ReLU、Sigmoid、Tanh 等,它们在神经网络中用于添加非线性,使得网络能够学习复杂的函数。 9. **损失函数(Loss Functions)**:用于评估模型的预测与真实值之间的差异,常见的损失函数包括均方误差(MSE)、交叉熵(Cross-Entropy)等。 10. **优化算法(Optimization Algorithms)**:如梯度下降(Gradient Descent)、随机梯度下降(SGD)、Adam 等,用于更新网络权重,以最小化损失函数。 11. **正则化(Regularization)**:技术如 Dropout、L1/L2 正则化等,用于防止模型过拟合。 12. **迁移学习(Transfer Learning)**:利用在一个任务上训练好的模型来提高另一个相关任务的性能。 深度学习在许多领域都取得了显著的成就,但它也面临着一些挑战,如对大量数据的依赖、模型的解释性差、计算资源消耗大等。研究人员正在不断探索新的方法来解决这些问题。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值