北京SEO

LAMP 源码编译安装 (Apache MySQL5.5.21 PHP5.3.10)

2019/10/10/17:45:02  阅读:1771  来源:谷歌SEO算法  标签: SEO教程

LAMP环境也web服务器中的一种搭配方案了,在这里我就来为各位介绍一下Apache MySQL5.5.21 PHP5.3.10,希望下文可以给各位带来帮助.

一:安装相关依赖组件

先yum安装基本的依赖组件:

  1. yuminstallmakeapr*autoconfautomakegccgcc-c++zlib-developensslopenssl-develpcre-develgdkernelkeyutilspatchperlkernel-headerscompat*mpfrcppglibclibgomplibstdc++-develpplcloog-pplkeyutils-libs-devellibcom_err-devellibsepol-devellibselinux-develkrb5-develzlib-devellibXpm*freetypelibjpeg*libpng*php-commonphp-gdncurses*libtool*libxml2libxml2-develpatch--disable-fileinfo

yum安装过后基本的组件已安好,以下编译安装可以安装最新版的组件.

1:安装zlib

zlib 官网:http://zlib.net

  1. wgethttp://zlib.net/zlib-1.2.8.tar.gz
  2. tar-xvzfzlib-1.2.8.tar.gz
  3. cdzlib-1.2.7.tar.gz
  4. ./configure
  5. make
  6. makeinstall

2:安装freetype

  1. wgethttp://download.savannah.gnu.org/releases/freetype/freetype-2.5.0.1.tar.gz
  2. cd/usr/local/src
  3. tar-zxvffreetype-2.3.5.tar.gz
  4. cdfreetype-2.3.5
  5. ./configure--prefix=/usr/local/freetype
  6. make
  7. makeinstall

make 的时候可能出现错误:

  1. /usr/include/libpng12/pngconf.h:336:error:expected‘=’,‘,’,‘;’,‘asm’or‘__attribute__’before‘.’token
  2. /usr/include/libpng12/pngconf.h:337:error:expected‘=’,‘,’,‘;’,‘asm’or‘__attribute__’before‘include’
  3. make:***[/usr/local/src/freetype-2.5.0.1/objs/sfnt.lo]Error1

解决办法:

./configure –prefix=/usr/local/freetype –without-png(加上这个选项就行了)

3:安装libpng

  1. wgethttp://sourceforge.net/projects/libpng/files/libpng12/older-releases/1.2.31/libpng-1.2.31.tar.gz/download
  2. cd/usr/local/src
  3. tar-zxvflibpng-1.2.31.tar.gz
  4. cdlibpng-1.2.31
  5. ./configure
  6. make
  7. makeinstall

4:安装libxml2

  1. wgethttp://xmlsoft.org/sources/old/libxml2-2.7.1.tar.gz
  2. cd/usr/local/src
  3. tar-xzvflibxml2-2.7.1.tar.gz
  4. cdlibxml2-2.7.1
  5. ./configure--prefix=/usr/local/libxml2--without-zlib 记得加上后面这句,不然会出错
  6. make
  7. makeinstall

5:安装libmcypt

  1. wgetftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt/libmcrypt-2.5.7.tar.gz
  2. cd/usr/local/src
  3. tarzxvflibmcrypt-2.5.7.tar.gz
  4. cdlibmcrypt-2.5。7
  5. ./configure--prefix=/usr/local/libmcrypt
  6. make
  7. makeinstall

6:安装gd2(php的gd库,压缩和处理图片会用到).

  1. wgethttp://google-desktop-for-linux-mirror.googlecode.com/files/gd-2.0.35.tar.gz
  2. cd/usr/local/src
  3. tar-zxvfgd-2.0.35.tar.gz
  4. mkdir-p/usr/local/gd
  5. cdgd-2.0.35
  6. ./configure--prefix=/usr/local/gd--enable-m4_pattern_allow--with-jpeg--with-png--with-zlib--with-freetype=/usr/local/freetype--with-libmcrypt=/usr/local/libmcrypt
  7. make
  8. makeinstal

–with-jpeg:使其支持jpeg图片处理,–with-png:支持png图片处理.

编译过程可能出现错误,就先编译安装下gettext:

  1. wgethttp://ftp.gnu.org/pub/gnu/gettext/gettext-0.18.3.1.tar.gz
  2. tarxzfgettext-0.17.tar.gz
  3. cdgettext-0.17
  4. ./configure
  5. make
  6. makeinstall

注意:gd库版本如果是gd-2.0.35以上,则需要 ./configure –enable-m4_pattern_allow或者编译安装 gettext组件后再重新编译gd

7:安装apr(Apache可移植运行库).

在这个地址http://mirror.bit.edu.cn/apache/apr/ 下载apr和apr-util

  1. cd/usr/local/src
  2. wgethttp://mirror.bit.edu.cn/apache/apr/apr-1.5.1.tar.gz
  3. tar-zxvfapr-1.5.1.tar.gz
  4. cdapr-1.5.1
  5. ./configure--prefix=/usr/local/apr
  6. make
  7. makeinstall

8:安装apr-util

  1. wgethttp://mirror.bit.edu.cn/apache/apr/apr-util-1.4.1.tar.gz
  2. tarzxvfapr-util-1.4.1.tar.gz
  3. cdapr-util-1.4.1
  4. ./configure--prefix=/usr/local/apr-util--with-apr=/usr/local/apr
  5. make
  6. makeinstall

9:安装openssl

wget ftp://ftp.openssl.org/source/openssl-1.0.1c.tar.gz #openssldir 是配置文件目录,建议安装两次,shared 作用是生成动态连接库.

  1. tar-zxfopenssl-1.0.1c.tar.gz
  2. cdopenssl-1.0.1c/
  3. ./config--prefix=/usr/local/openssl--openssldir=/usr/local/openssl/ssl
  4. make&&makeinstall
  5. ./configshared--prefix=/usr/local/openssl--openssldir=/usr/local/openssl/ssl
  6. makeclean
  7. make
  8. makeinstall

10:安装curl

  1. wgethttp://curl.haxx.se/download/curl-7.17.1.tar.gz
  2. tar-zxvfcurl-7.17.1.tar.gz
  3. cdcurl-7.17.1
  4. ./configure--prefix=/usr/local/curl
  5. make
  6. makeinstall

如果出现错误:

  1. curl.so-lz-lrt-Wl,-rpath-Wl,/usr/local/curl/lib
  2. ../lib/.libs/libcurl.so:undefinedreferenceto`ERR_remove_thread_state’
  3. collect2:ldreturned1exitstatus
  4. make[2]:***[curl]Error1
  5. make[2]:Leavingdirectory`/usr/local/src/curl-7.32.0/src’
  6. make[1]:***[all]Error2
  7. make[1]:Leavingdirectory`/usr/local/src/curl-7.32.0/src’
  8. make:***[all-recursive]Error1

建议安装旧点的版本,特别是如果openssl的版本是1.0以下.

二:安装httpd

  1. wgethttp://mirrors.cnnic.cn/apache//httpd/httpd-2.4.9.tar.gz
  2. tar-zxvfhttpd-2.4.9.tar.gz
  3. cdhttpd-2.4.9
  4. ./configure--prefix=/usr/local/apache--with-apr=/usr/local/apr--with-included-apr--with-apr-util=/usr/local/apr-util--with-ssl=/usr/local/openssl--enable-ssl=static--enable-so--enable-maintainer-mode--with-mpm=prefork--enable-rewrite=shared--enable-userdir--enable-vhost-alias=shared--enable-cgi--enable-cgid--enable-expires=shared--enable-mem-cache=shared--enable-disk-cache=shared--enable-cache=shared--enable-deflate--enable-modules=all--enable-mods-shared=all
  5. make//phpfensi.com
  6. makeinstall
  7. /usr/local/apache/bin/apachectl-kstart#启动httpd
  8. vim/usr/local/apache/conf/httpd.conf#编辑配置文件

找到:#ServerName www.example.com:80

修改为:ServerName localhost:80

找到:DirectoryIndex index.html

修改为:DirectoryIndex index.html index.php

找到:Options Indexes FollowSymLinks

修改为:Options FollowSymLinks #不显示目录结构

找到AllowOverride None

修改为:AllowOverride All #开启apache支持伪静态,注意有两处都做修改.

LoadModule rewrite_module modules/mod_rewrite.so #取消前面的注释,开启apache支持伪静态.

cp /usr/local/apache/bin/apachectl /etc/rc.d/init.d/httpd #加入到系统启动

vim /etc/init.d/httpd

在#!/bin/sh下面添加以下两行:

  1. #chkconfig:23451090
  2. #description:Activates/DeactivatesApacheWebServer
  3. chowndaemon.daemon-R/usr/local/apache/htdocs#更改默认项目目录所有者
  4. chmod700/usr/local/apache/htdocs-R#更改apache默认网站目录权限
  5. chkconfighttpdon#设置开机自动启动httpd
  6. /etc/init.d/httpdstart#启动httpd
  7. servicehttpdrestart#重启httpd

编译或者配置时可能会出现以下错误.

1:错误信息:

  1. httpd-2.4.4/support/ab.c:2271:undefinedreferenceto`TLSv1_1_client_method’

解决办法:这个是openssl的版本问题,版本低于1.0建议编译安装高版本的1.0.0c,然后编译安装apache时候加上–with-ssl=/usr/local/openssl 这个参数,问题解决.

2:错误信息:

  1. /usr/local/ssl/lib/libssl.a:couldnotreadsymbols:Badvalue
  2. collect2:ldreturned1exitstatus
  3. make[4]:***[mod_ssl.la]Error1
  4. make[4]:Leavingdirectory`/usr/local/src/httpd-2.4.9/modules/ssl’
  5. make[3]:***[shared-build-recursive]Error1
  6. make[3]:Leavingdirectory`/usr/local/src/httpd-2.4.9/modules/ssl’
  7. make[2]:***[shared-build-recursive]Error1
  8. make[2]:Leavingdirectory`/usr/local/src/httpd-2.4.9/modules’
  9. make[1]:***[shared-build-recursive]Error1
  10. make[1]:Leavingdirectory`/usr/local/src/httpd-2.4.9′
  11. make:***[all-recursive]Error1

解决办法:这段错误说明ssl方面的错误,需要重新编译.

a:编译时候没带上–with-ssl=/usr/local/openssl

b:带上了–with-ssl的参数,但是openssl编译的时候没有带上:fPIC这个参数

  1. PositionIndependentCodeisnecessaryforamodulelikemod_sslwhichmaygetplacedanywhereinmemoryatruntime.ItisnotnecessaryforthestandaloneOpenSSLtestprogram,whichiswhymaketestworkedOKwithout-fPIC.

3:错误信息:

error while loading shared libraries: libssl.so.1.0.0: cannot open shared object file: No such file or directory

解决办法:

因为我们加载的模块是 mod_ssl.so,到openssl目录的lib下发现有这两个库,如果要让mod_ssl.so找到这两个库必须将ssl/lib添加到 LD_LIBRARY_PATH变量下.

~/.bashrc(每次登录每次打开shell读取一次) ,

修改完用户的环境变量后不会马上生效,执行 source ~/.bashrc 使其生效,这样就可以启动apache了.

4:错误信息:

chkconfig httpd on后,利用service httpd start 出现错误:error while loading shared libraries: libssl.so.1.0.0: cannot open shared object file: No such file or directory

原因是:启动时候找不到库文件libssl.so.1.0.0,因为/usr/lib64(64位的用户库文件)没有这个文件.

解决办法:

利用ln 软链接去共用 /usr/local/openssl/lib 的库文件.

  1. ln-s/usr/local/openssl/lib/libssl.so.1.0.0/usr/lib64/libssl.so.1.0.0
  2. ln-s/usr/local/openssl/lib/libcrypto.so.1.0.0/usr/lib64/libcrypto.so.1.0.0

service httpd start 成功.

5:错误信息:

configure时候出现错误

configure: error: Bundled APR requested but not found at ./srclib/. Download and unpack the corresponding apr and apr-util packages to ./srclib/.

解决办法:

因为:apache-2.2与新出的apache-2.4安装不同的地方在于,2.4版的已经不自带apr库,所以在安装apache-2.4之前,需要下载apr.

  1. cp-rfapr-1.4.4httpd-2.4.9/srclib/apr
  2. cp-rfapr-util-1.5.3httpd-2.4.9/srclib/apr-util

再configure 即可.

三:安装mysql

mysql官网:http://dev.mysql.com/downloads/ 下载源码包

groupadd mysql #添加mysql组

useradd -g mysql mysql -s /bin/false #创建用户mysql并加入到mysql组,不允许mysql用户直接登录系统.

  1. mkdir-p/usr/local/mysql#创建MySQL安装目录
  2. mkdir-p/usr/local/mysql/data#创建MySQL数据存放目录
  3. tarzxvfmysql-5.5.21.tar.gz
  4. cdmysql-5.5.21
  5. cmake.-DCMAKE_INSTALL_PREFIX=/usr/local/mysql-DMYSQL_DATADIR=/usr/local/mysql/data-DSYSCONFDIR=/etc-DMYSQL_UNIX_ADDR=/tmp/mysql.sock-DWITH_INNOBASE_STORAGE_ENGINE=1-DWITH_MYISAM_STORAGE_ENGINE=1-DENABLED_LOCAL_INFILE=1-DMYSQL_TCP_PORT=3306-DWITH_EXTRA_CHARSETS:STRING=utf8,gbk-DDEFAULT_CHARSET=utf8-DDEFAULT_COLLATION=utf8_general_ci-DWITH_DEBUG=0-DWITH_READLINE=1-DWITH_SSL=yes
  6. #(有时候会出现找不到/usr/local/mysql/data等警告,不管他,直接继续编译)
  7. make
  8. makeinstall
  9. cd/usr/local/mysql
  10. cp./support-files/my-huge.cnf/etc/my.cnf#提示文件存在的话直接覆盖
  11. vim/etc/my.cnf#在[mysqld]部分增加
  12. datadir=/usr/local/mysql/data#数据库存放路径
  13. ./scripts/mysql_install_db--basedir=/usr/local/mysql--datadir=/usr/local/mysql/data--user=mysql#生成mysql系统数据库
  14. cp./support-files/mysql.server/etc/rc.d/init.d/mysqld#把Mysql加入系统启动
  15. chmod755/etc/init.d/mysqld#增加执行权限
  16. chkconfigmysqldon#加入开机启动
  17. vim/etc/rc.d/init.d/mysqld#编辑
  18. basedir=/usr/local/mysql#MySQL程序安装路径
  19. datadir=/usr/lcoal/mysql/data#MySQl数据库存放目录
  20. servicemysqldstart#启动
  21. /usr/local/mysql/bin/mysql-uroot–p#登录mysql
  22. #安装成功后进行root用户密码修改:
  23. /usr/local/mysql/bin/mysqladmin-uroot-ppassword"新密码"#回车后提示输入旧密码,输入成功后密码修稿成功
  24. /etc/init.d/mysqldrestart#重启mysql,安装成功!

四:安装php

  1. wgethttp://cn2.php.net/get/php-5.3.27.tar.gz/from/ar2.php.net/mirror
  2. ./configure--prefix=/usr/local/php--with-config-file-path=/usr/local/php/etc--with-apxs2=/usr/local/apache/bin/apxs--with-mysql=/usr/local/mysql--with-mysqli=/usr/local/mysql/bin/mysql_config--with-mysql-sock=/tmp/mysql.sock--with-gd--with-iconv--with-freetype-dir=/usr/local/freetype--with-jpeg-dir=/usr/local/jpeg9--with-png-dir=/usr/local/libpng--with-zlib--with-libxml-dir=/usr/local/libxml2--enable-xml--enable-discard-path--enable-magic-quotes--enable-safe-mode--enable-bcmath--enable-shmop--enable-sysvsem--enable-inline-optimization--with-curlwrappers--enable-mbregex--enable-fastcgi--enable-force-cgi-redirect--enable-mbstring--enable-ftp--enable-gd-native-ttf--with-openssl--enable-pcntl--enable-sockets--with-xmlrpc--enable-zip--enable-soap--without-pear--with-gettext--with-mime-magic--enable-suhosin--enable-session--with-mcrypt
  3. make
  4. makeinstall

–with-jpeg-dir 使用yum安装的默认版本

configure配置的时候可能出现的问题:

checking for cURL in default path… not found

configure: error: Please reinstall the libcurl distribution -

因为:curl的dev包没有安装

解决办法:yum -y install curl-devel

make编译的时候可能出现的问题:

virtual memory exhausted: Cannot allocate memory

原因:编译过程是一个内存消耗较大的动作,内存吃紧,无法分配

解决办法:配置项加上 –disable-fileinfo这个参数,重新编译

  1. cpphp.ini-production/usr/local/php/etc/php.ini#复制php配置文件到安装目录
  2. rm-rf/etc/php.ini#删除系统自带的配置文件
  3. ln-s/usr/local/php/etc/php.ini/etc/php.ini#创建配置文件软链接
  4. vim/usr/local/php/etc/php.ini#编辑

找到:;open_basedir =

修改为:open_basedir = .:/tmp/ #防止php木马跨站

找到:;date.timezone =

修改为:date.timezone = PRC

找到:expose_php = On

修改为:expose_php = OFF #禁止显示php版本的信息

找到:display_errors = On

修改为:display_errors = OFF #关闭错误提示

wq!#保存 php安装完成

五:配置apache支持php

  1. vim/usr/local/apache/conf/httpd.conf#编辑apache配置文件
  2. 添加下面两行
  3. LoadModulephp5_modulemodules/libphp5.so
  4. AddHandlerapplication/x-httpd-php.php(注意:php.php这个点前面有一个空格)
  5. servicehttpdrestart#重启apache
  6. servicemysqldrestart#重启mysql
  7. cd/usr/local/apache/htdocsviindex.php#输入下面内容
  8. :wq!#保存
  9. [cclang="php"]

在客户端浏览器输入服务器IP地址,可以看到php等相关配置信息.

广告内容

LAMP 源码编译安装 (Apache MySQL5.5.21 PHP5.3.10) LAMP 源码编译安装 (Apache MySQL5.5.21 PHP5.3.10) LAMP 源码编译安装 (Apache MySQL5.5.21 PHP5.3.10)

相关阅读

热门评论

精选文章

RMAN中catalog和nocatalog区别介绍 小技巧:为Linux下的文件分配多个权限 zimbra8.5.1安装第三方签名ssl证书的步骤 解决mysql不能远程连接数据库方法 windows服务器mysql增量备份批处理数据库 mysql中slow query log慢日志查询分析 JavaScript跨域问题总结 Linux下负载均衡软件LVS配置(VS/DR)教程 mysql中权限参数说明 MYSQL(错误1053)无法正常启动

SEO最新算法