LAMP----linux+apache+mysql+php详细安装步骤之一APACHE篇(openldap等)

 

LAMP----linux+apache+mysql+php详细安装步骤之一APACHE(openldap)

 

linux详细版本为RHEL5.3

 

[root@localhost mail]# uname -a

Linux localhost.localdomain 2.6.18-128.el5 #1 SMP Wed Dec 17 11:42:39 EST 2008 i686 i686 i386 GNU/Linux

 

1、上传apache源代码文件

 

httpd-2.2.13.tar.bz2

 

其实纯粹安装一个apache很简单

 

[root@localhost apache]# tar xvf httpd-2.2.13

 

[root@localhost apache]# cd httpd-2.2.13

 

[root@localhost httpd-2.2.13]# ./configure --prefix=/usr/local/apache

 

[root@localhost httpd-2.2.13]# make

 

[root@localhost httpd-2.2.13]# make install

 

通过以上命令就可以了,安装的目录为/usr/local/apache

 

一般还会添加些常用的模块,如apr,apr-util,open-ldap等

 

apache一般会自带apr和apr-util,在srclib目录里

 

进入/root/apache/httpd-2.2.13/srclib/apr目录

 

[root@localhost apr]# ./configure --prefix=/usr/local/apr --enable-threads --enable-other-child

 

[root@localhost apr]# make

 

[root@localhost apr]# make install

 

然后进入/root/apache/httpd-2.2.13/srclib/apr-util

 

[root@localhost apr-util]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr --with-mysql=/usr/local/mysql \

> --with-ldap-lib=/usr/openldap/lib --with-ldap-include=/usr/openldap/include \

> --with-ldap=ldap --with-berkeley-db=/usr/local/BerkeleyDB.4.4

 

执行以上操作肯定会报错,因为LDAP未装,berkeleyDB.4.4也未装,所以还必须要先装这两个软件

 

上传openldap-stable-20100219.tgz和db-4.4.20.tar.gz,后者就是传说中的BerkeleyDB,也可以从ORACLE官网去下载他的源码包

 

[root@localhost apache]# tar zxvf db-4.4.20.tar.gz

 

[root@localhost apache]# cd db-4.4.20/build_unix/

 

[root@localhost build_unix]# ../dist/configure --prefix=/usr/local/BerkeleyDB.4.4

 

这儿有点要注意,BerkeleyDB不能在根目录下configure,一般都采用上面的方式进行配置

 

[root@localhost build_unix]# make

 

[root@localhost build_unix]# make install

 

安装完毕后需要配置些东西

 

[root@localhost build_unix]# vim /etc/ld.so.conf

 

在该文件中加入/usr/local/BerkeleyDB.4.4/lib

 

[root@localhost build_unix]# /sbin/ldconfig

 

[root@localhost build_unix]# vi /etc/profile

 

在末尾加上

 

LD_RUN_PATH=/usr/local/BerkeleyDB.4.4/lib

LD_LIBRARY_PATH=/usr/local/BerkeleyDB.4.4/lib

export LD_RUN_PATH LD_LIBRARY_PATH

 

[root@localhost build_unix]# source /etc/profile

 

下面开始安装openldap

 

[root@localhost apache]# tar zxvf openldap-stable-20100219.tgz

 

[root@localhost apache]# cd openldap-2.4.21/

 

[root@localhost openldap-2.4.21]# env CPPFLAGS="-I/usr/local/BerkeleyDB.4.4/include"LDFLAGS="-L/usr/local/BerkeleyDB.4.4/lib" ./configure --prefix=/usr/local/openldap --enable-bdb

 

报错 configure: error: BerkeleyDB version incompatible with BDB/HDB backends

 

版本错误

 

[root@localhost openldap-2.4.21]# cp /usr/local/BerkeleyDB.4.4/include/* /usr/include/

 

[root@localhost openldap-2.4.21]# cp /usr/local/BerkeleyDB.4.4/lib/* /usr/lib/

 

全部覆盖然后再执行

 

[root@localhost openldap-2.4.21]# env CPPFLAGS="-I/usr/local/BerkeleyDB.4.4/include"LDFLAGS="-L/usr/local/BerkeleyDB.4.4/lib" ./configure --prefix=/usr/local/openldap --enable-bdb

 

就OK了,然后按照要求执行

 

[root@localhost openldap-2.4.21]# make depend

 

[root@localhost openldap-2.4.21]# make

 

[root@localhost openldap-2.4.21]# make install

 

进入刚才apache下的apr-util目录

 

[root@localhost apr-util]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr --with-mysql=/usr/local/mysql \

> --with-ldap-lib=/usr/openldap/lib --with-ldap-include=/usr/openldap/include \

> --with-ldap=ldap --with-berkeley-db=/usr/local/BerkeleyDB.4.4

 

然后make make install即可

 

至此apr,apr-util,BerkeleyDB,openldap安装完毕,下面正式进入apache安装

 

[root@localhost httpd-2.2.13]# ./configure --prefix=/usr/local/apache --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-mods-shared='ldap authnz-ldap actions alias asis auth-basic auth-digest authn-anon authn-dbd authn-dbm authn-default authn-file authz-dbm authz-default authz-groupfile authz-host authz-owner authz-svn authz-user autoindex cern-meta cgi dav-fs dav-lock dav dav-svn dbd deflate dir dumpio env expires ext-filter filter headers ident imagemap include info log-config log-forensic logio mime-magic mime negotiation proxy-ajp proxy-balancer proxy-connect proxy-ftp proxy-http proxy-scgi proxy reqtimeout rewrite setenvif speling ssl status substitute unique-id userdir usertrack version vhost-alias'

 

以上我采用了动态模块的方式进行编译,每个模块可以通过httpd.conf的配置来选择是否加载模块,比如ldap模块

 

在httpd.conf里通过 LoadModule ldap_module modules/mod_ldap.so 来加载这个模块

 

只要将此行注释掉,apache将不再加载ldap模块

 

--enable-mods-shared=''的编译方式为动态编译,详见http://lamp.linux.gov.cn/Apache/ApacheMenu/programs/configure.html

 

配置完成后make  make install即可在/usr/local/apache安装好apache

 

安装完成

 

 

 

LAMP----linux+apache+mysql+php详细安装步骤之二mysql篇

 

 

[root@localhost mysql-5.1.36]# ./configure --prefix=/usr/local/mysql --localstatedir=/usr/local/mysql/data/ --without-innodb --without-debug --without-isam --with-charset=utf8 --with-collation=utf8_general_ci --with-extra-charsets=all --enable-assembler --with-pthread --enable-thread-safe-client --with-client-ldflags=-all-static -with-unix-socket-path=/usr/local/mysql/tmp/mysql.sock

 

[root@localhost mysql-5.1.36]# make

 

[root@localhost mysql-5.1.36]# make install

 

MYSQL安装比较简单,从网上找了些文档,然后总结了几个对LINUX下有帮助的参数,配置安装一下即可

 

 

Mysql 配置

 

[root@localhost mysql-5.1.36]# cp ./support-files/mysql.server /etc/init.d/mysql

 

[root@localhost mysql-5.1.36]# groupadd mysql

 

[root@localhost mysql-5.1.36]# useradd –g mysql mysql

 

[root@localhost mysql-5.1.36]# chmod 777 /etc/init.d/mysql

 

[root@localhost mysql-5.1.36]# /usr/local/mysql/bin/mysql_install_db

 

[root@localhost mysql-5.1.36]# chown -R mysql:mysql /usr/local/mysql/data/

 

启动 Mysql

 

[root@localhost mysql-5.1.36]# service mysql start

 

[root@localhost mysql-5.1.36]# /usr/local/mysql/bin/mysqladmin –u root –p password 'rootpw'       // 设置密码为 rootpw

 

[root@localhost mysql-5.1.36]Enter password:                 // 默认密码为空,所以直接回车

 

[root@localhost mysql-5.1.36]# /usr/local/mysql/bin/mysql –u root –p

 

Enter password:                 // 输入新密码后,登录成功

 

mysql 安装配置完毕。

 

 

LAMP----linux+apache+mysql+php详细安装步骤之三php篇

 

 

zlib-1.2.3.tar.bz2 libmcrypt-2.5.7.tar.gz mhash-0.9.9.9.tar.bz2 libiconv-1.13.1.tar.gz gd-2.0.33.tar.gz jpegsrc.v7.tar.gz libpng-1.2.10.tar.bz2 libXpm-3.5.5.tar.bz2 libxml2-2.7.4.tar.gz

 

以上是我单独安装的包,也可以使用REDHAT自带的,如果是自带的,一般在配置PHP时采用/usr/include/目录就能找到

 

而单独装的包,可以使用./configure --prefix=/dir 来自定义路径,在配置PHP时采用这个路径即可

 

[root@localhost php-5.2.13]# ./configure --cache-file=./config.cache --prefix=/usr/local/php --sysconfdir=/usr/local/php/etc \

> --infodir=/usr/local/php/info --mandir=/usr/local/php/man --with-apxs2=/usr/local/apache/bin/apxs \

> --disable-debug --with-config-file-path=/usr/local/php/lib --with-config-file-scan-dir=/usr/local/php/etc \

> --enable-libxml --with-libxml-dir=/usr/local/libxml --with-zlib=/usr/local/zlib --enable-bcmath \

> --with-bz2=/usr/bin/bzip2 --enable-calendar --enable-ctype --with-curl=/usr/include/curl --with-curlwrappers \

> --enable-zip --enable-ftp --with-gettext --enable-mbstring --with-mcrypt=/usr/local/libmcrypt --with-mhash=/usr/local/mhash \

> --with-iconv=/usr/local/libiconv --with-xmlrpc --with-xsl=/usr/include/libxslt --with-gd=/usr/local/gd2 \

> --with-jpeg-dir=/usr/local/jpeg7 --with-png-dir=/usr/local/libpng --with-xpm-dir=/usr/local/libXpm --with-ttf \

> --with-freetype-dir=/usr/include/freetype2/freetype --without-t1lib --enable-gd-native-ttf --enable-gd-jis-conv \

> --with-mysqli=/usr/local/mysql/bin/mysql_config --with-mysql=/usr/local/mysql --with-mysql-sock=/tmp/mysql.sock \

> --with-ldap=/usr/local/openldap --with-gmp=/usr/local/gmp --enable-sigchild --enable-pdo --with-pdo-mysql=/usr/local/mysql

 

make  make isntall后即可安装完成,make test可做可不做

 

在/usr/local/apache/conf/httpd.conf里找有没有加载PHP

 

LoadModule php5_module        modules/libphp5.so

 

AddType application/x-httpd-php .php

AddType application/x-httpd-php-source .phps

 

如果没有可以手动加上,测试PHP是否安装完成可以在 /usr/local/apache/htdocs里新建一个index.php,内容如下

 

phpinfo()

?>

 

保存后运行 /usr/local/apache/bin/apachectl -k start启动APACHE,在浏览器里访问该地址页面即可看到本机的安装的php信息

 

如果未出现,则证明PHP未安装成功。

转载于:https://www.cnblogs.com/geniusxjq/p/4094188.html

你可能感兴趣的:(LAMP----linux+apache+mysql+php详细安装步骤之一APACHE篇(openldap等))