RPM包和源码包存放位置 /usr/local/src
源码包编译安装位置(prefix) /usr/local/xxx
脚本以及维护程序存放位置 /usr/local/sbin
MySQL 位置 /var/lib/mysql
Apache网站根目录 /home/www
Apache虚拟主机根目录 /data/logs/www
yum RPM包信息文件 /etc/yum.list

程序列表

  1. http://download.filehat.com/apache/httpd/httpd-2.2.8.tar.gz
  2. http://opensource.nchc.org.tw/COSA/CNS4/cronolog-1.6.2.tar.gz
  3. http://www.libgd.org/releases/gd-2.0.35.tar.bz2
  4. http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.12.tar.gz
  5. http://mirror.optus.net/sourceforge/m/mc/mcrypt/libmcrypt-2.5.8.tar.gz
  6. http://jaist.dl.sourceforge.net/sourceforge/mcrypt/mcrypt-2.6.7.tar.gz
  7. http://www.openssl.org/source/openssl-0.9.8h.tar.gz
  8. http://openbsd.md5.com.ar/pub/OpenBSD/OpenSSH/portable/openssh-5.0p1.tar.gz
  9. http://mysql.byungsoo.net/Downloads/MySQL-5.0/mysql-5.0.51b.tar.gz
  10. http://cn2.php.net/get/php-5.2.6.tar.bz2/from/this/mirror
  11. http://downloads.phpchina.com/zend/optimizer/3.3.3/ZendOptimizer-3.3.3-linux-glibc23-i386.tar.gz
  12. ftp://ftp.cac.washington.edu/mail/imap.tar.Z
  13. http://puzzle.dl.sourceforge.net/sourceforge/phpmyadmin/phpMyAdmin-2.11.8.1-all-languages-utf-8-only.tar.gz
  14. http://dl.sugarforge.org/sugarcrm/Latest-SugarCE5.1/SugarCE5.1.0/SugarCE-5.1.0.zip
  15. http://mirror.optus.net/sourceforge/m/mh/mhash/mhash-0.9.9.tar.gz

系统环境部署及调整

(1). 检查系统是否正常
# more /var/log/messages //检查有无系统内核级错误信息
# demesg //检查硬件设备是否有错误信息
# ifconfig //检查网卡设置是否正确
# pingwww.163.com// 检查网络是否正常

(2). 关闭不需要的服务
# export LANG='en_US' //设置语言
# setup //选择启动的服务
进入system service 选项。
以space 键选定所需服务。
以下仅列出需要启动的服务,未列出的服务一律关闭:
crond
irqbalance 仅当服务器CPU为S.M.P架构或支持双核心、HT技术时,才需开启,否则关闭。
microcode_ctl
network
vsftpd
sshd
syslog

(3)修改/etc/yum.repos.d/CentOS-Base.repo,将镜象站点地址改为在中国的镜象站点地址。

然后执行:
# yum upgrade

(4)定时校正服务器时间
# yum install ntp
# crontab -e
0 23 * * * root /usr/sbin/ntpdate 210.72.145.44 > /dev/null 2>&1
以上命令设置好后存盘。您的机器将在每天的23:00根据中国国家授时中心的NTP服务器时间自动校准时间。

5. 使用 yum 程序安装所需开发包(以下为标准的 RPM 包名称)
# yum install gcc gcc-c++ gcc-g77 flex bison autoconf automake bzip2-devel zlib-devel ncurses-devel libjpeg-devel libpng-devel libtiff-devel freetype-devel pam-devel openssl-devel libxml2-devel

# 这里我们将编译GD所必须的一些小软件比如libpng,libtiff,freetype,libjpeg,等先用RPM的方式一并安装好,避免手动编 译浪费时间,同时也能避免很多错误,这几个小软件的编译很麻烦。这几个小软件编译错误了,GD当然安装不了,php5的编译当然也没戏了。所以我们抓大放 小,对这些小牛鬼蛇神采取快速简洁的方式进行安装。并且对服务器的性能也不能产生什么影响。
另外libxml2系统已经默认安装了,所以我们不需要手工编译了,直接安装它的开发包就行了。

6. 源码编译安装所需包 (Source)
(1) GD2
# cd /usr/local/src
# wgethttp://www.boutell.com/gd/http/gd-2.0.35.tar.gz
# tar xzvf gd-2.0.35.tar.gz
# cd gd-2.0.34
# CHOST="i686-pc-linux-gnu" CFLAGS="-O3 -msse2 -mmmx -Wall -W -mfpmath=sse -mcpu=pentium4 -march=pentium4 -pipe -fomit-frame-pointer" CXXFLAGS="-O3 -msse2 -mmmx -Wall -W -mfpmath=sse -funroll-loops -mcpu=pentium4 -march=pentium4 -pipe -fomit-frame-pointer" ./configure --prefix=/usr/local/gd2 --mandir=/usr/share/man //./configure 配置。

# make //make 是用来编译的,它从 Makefile 中读取指令,然后编译。
# make install //make install 是用来安装的,它也从 Makefile 中读取指令,安装到指定的位置。

(2)Apache日志截断程序
# cd /usr/local/src
# wgethttp://cronolog.org/download/cronolog-1.6.2.tar.gz
# tar xzvf cronolog-1.6.2.tar.gz
# cd cronolog-1.6.2
# ./configure --prefix=/usr/local/cronolog
# make
# make install

cd /usr/local/src
# wget http://mirror.provenscaling.com/mysql/enterprise/source/5.0/mysql-5.0.46.tar.gz
# tar xzvf mysql-5.0.46.tar.gz
# cd mysql-5.0.46

#./configure --prefix=/usr/local/mysql --localstatedir=/usr/local/mysql --with-comment=Source --with-server-suffix=-enterprise-gpl --with-mysqld-user=mysql --without-debug --with-big-tables --with-charset=utf8 --with-collation=utf8_general_ci --with-extra-charsets=all --with-pthread --enable-static --enable-thread-safe-client --with-client-ldflags=-all-static --with-mysqld-ldflags=-all-static --enable-assembler --without-innodb --without-ndb-debug --without-isam

编译安装完成后执行后续操作:
# useradd mysql //添加 mysql 用户
# cd /usr/local/mysql
# bin/mysql_install_db --user=mysql&
# chown -R root:mysql . //设置权限,注意后面有一个 "."
# chown -R mysql /var/lib/mysql //设置 mysql 目录权限
# chgrp -R mysql . //注意后面有一个 "."
# cp share/mysql/my-medium.cnf /etc/my.cnf
# cp share/mysql/mysql.server /etc/rc.d/init.d/mysqld //开机自动启动 mysql。
# chmod 755 /etc/rc.d/init.d/mysqld
# chkconfig --add mysqld
# /etc/rc.d/init.d/mysqld start //启动 MySQL
# bin/mysqladmin -u root password "password_for_root"
# service mysqld stop //关闭 MySQL

安装APACHE
# cd /usr/local/src
# wget http://archive.apache.org/dist/httpd/httpd-2.2.8.tar.gz
# tar zxvf httpd-2.2.8.tar.gz
# cd httpd-2.2.8

依次安装apr和apr-util
# cd srclib/apr
# CHOST="i686-pc-linux-gnu" CFLAGS="-O3 -msse2 -mmmx -Wall -W -mfpmath=sse -mcpu=pentium4 -march=pentium4 -pipe -fomit-frame-pointer" CXXFLAGS="-O3 -msse2 -mmmx -Wall -W -mfpmath=sse -funroll-loops -mcpu=pentium4 -march=pentium4 -pipe -fomit-frame-pointer" ./configure --prefix=/usr/local/apr --enable-threads --enable-other-child --enable-static
# make && make install

# cd ../apr-util
# CHOST="i686-pc-linux-gnu" CFLAGS="-O3 -msse2 -mmmx -Wall -W -mfpmath=sse -mcpu=pentium4 -march=pentium4 -pipe -fomit-frame-pointer" CXXFLAGS="-O3 -msse2 -mmmx -Wall -W -mfpmath=sse -funroll-loops -mcpu=pentium4 -march=pentium4 -pipe -fomit-frame-pointer" ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/ --with-mysql=/usr/local/mysql
# make && make install

cd /usr/local/src/httpd-2.2.6

./configure --prefix=/usr/local/apache2 --enable-mods-shared=all --with-mysql=/usr/local/mysql --enable-cache --enable-file-cache --enable-mem-cache --enable-disk-cache --enable-static-support --enable-static-htpasswd --enable-static-htdigest --enable-static-rotatelogs --enable-static-logresolve --enable-static-htdbm --enable-static-ab --enable-static-checkgid --disable-cgid --disable-cgi --with-apr=/usr/local/apr/ --with-apr-util=/usr/local/apr-util/ --enable-ssl --with-ssl=/usr/include/openssl
报错:cannot run C compiled programs.

解决:cp /usr/local/mysql/lib/mysql/libmysqlclient_r.so.15 /usr/lib/. 最后面有个点不要忘掉。

解释:

注解:
./configure //配置源代码树
--prefix=/usr/local/apache2 //体系无关文件的顶级安装目录PREFIX ,也就Apache的安装目录。
--enable-module=so //打开 so 模块,so 模块是用来提 DSO 支持的apache核心模块
--enable-mods-shared=all //编译全部的模板,对于不需要我们可以在httpd.conf去掉。
--enable-cache //支持缓存
--enable-file-cache //支持文件缓存
--enable-mem-cache //支持记忆缓存
--enable-disk-cache //支持磁盘缓存
--enable-static-support //支持静态连接(默认为动态连接)
--enable-static-htpasswd //使用静态连接编译 htpasswd - 管理用于基本认证的用户文件
--enable-static-htdigest //使用静态连接编译 htdigest - 管理用于摘要认证的用户文件
--enable-static-rotatelogs //使用静态连接编译 rotatelogs - 滚动Apache日志的管道日志程序
--enable-static-logresolve //使用静态连接编译 logresolve - 解析Apache日志中的IP地址为主机名
--enable-static-htdbm //使用静态连接编译 htdbm - 操作 DBM 密码数据库
--enable-static-ab //使用静态连接编译 ab -ApacheHTTP 服务器性能测试工具
--enable-static-checkgid //使用静态连接编译 checkgid
--disable-cgid //禁止用一个外部 CGI 守护进程执行CGI脚本
--disable-cgi //禁止编译 CGI 版本的 PHP
--enable-ssl // 编译 ssl模块。

我们不再使用worker模式编译apache,worker模式和php貌似有一些不协调不稳定之处。所以使用了默认的perfork模式。

将apache设置成开机自启动:

在/etc/rc.d/rc.local文件中加入一行
/usr/local/apache2/bin/apachectl start
这样每次重新启动系统以后,apache也会随系统一起启动.

或者
# cp /usr/local/apache2/bin/apachectl /etc/rc.d/init.d/httpd
然后 vi /etc/rc.d/init.d/httpd 添加(#!/bin/sh下面)
# chkconfig: 2345 10 90
# descrīption: Activates/DeactivatesApacheWeb Server
最后,运行chkconfig把Apache添加到系统的启动服务组里面:
# chkconfig --add httpd
# chkconfig httpd on

安装PHP

php 5.2.4有点小BUG,无法在centos 5上正常编译,官方已经在php5.2.5中修复了。所以我们使用php 5.2.5进行编译。
Suhosin 是php增强型安全补丁,可以编译到静态内核中,也可以编译成php动态扩展。我个人强烈你建议安装成静态内核。Suhosin已经进入freebsd和 gentoo的ports。下面的以下先说静态安装步骤。当然你也可以在安装php后将它编译成php的动态扩展

安装mcrypt

tar zxvf mcrypt-2.6.7.tar.gz

cd mcrypt-2.6.7/

./configure

make

make install

# cd /usr/local/src
# wget http://cn.php.net/get/php-5.2.6.tar.gz/from/this/mirror
wget http://download.suhosin.org/suhosin-patch-5.2.6-0.9.6.2.patch.gz
# tar zxvf php-5.2.5.tar.gz
# gunzip suhosin-patch-5.2.1-0.9.6.2.patch.gz
# cd php-5.2.5
#patch -p 1 -i ../suhosin-patch-5.2.5-0.9.6.2.patch

./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs --with-pear=/usr/share/php --with-zlib-dir --with-bz2 --with-libxml-dir=/usr --with-gd=/usr/local/gd2 --enable-gd-native-ttf --enable-gd-jis-conv --with-freetype-dir --with-jpeg-dir --with-png-dir --with-ttf=shared,/usr --enable-mbstring --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-config-file-path=/etc --with-iconv --disable-ipv6 --enable-static --enable-maintainer-zts --enable-zend-multibyte --enable-inline-optimization --enable-zend-multibyte --enable-sockets --enable-soap --with-openssl --enable-suhosin --enable-mcrypt

最后提示错误:
configure: error: Please reinstall the BZip2 distribution
解决:yum install bzip2-devel
其它常见错误:
configure: error: …No recognized SSL/TLS toolkit detected
# yum -y install openssl-devel

configure: error: no acceptable cc found in $PATH
yum -y install gcc-c++

configure: error: cannot find output from lex; giving up flex is not installed, install flex.
yum -y install flex

configure: error: xml2-config not found. Please check your libxml2 installation.
yum -y install libxml2-devel

configure: error: Cannot find OpenSSL’s
yum -y install openssl-devel

configure: error: Please reinstall the BZip2 distribution
yum -y install bzip2-devel

configure: error: Please reinstall the libcurl distribution - easy.h should be in /include/curl/
yum -y install curl-devel

configure: error: libjpeg.(a|so) not found.
yum -y install libjpeg-devel

configure: error: libpng.(a|so) not found.
yum -y install libpng-devel

configure: error: freetype2 not found!
yum -y install freetype-devel

configure: error: Unable to locate gmp.h
yum -y install gmp-devel

configure: error: Cannot find pspell
yum -y install aspell-devel

libtool: link: cannot find the library `/usr/lib/libbeecrypt.la’ (librpmio.la: /usr/lib/libbeecrypt.la)
解决:缺少beecrypt包,如:
http://sourceforge.net/projects/beecrypt下载beecrypt-4.1.2.tar.gz
然后运行如下命令:
#tar -zxvf beecrypt-4.1.2.tar.gz
#./configure
#make
#make install

整合apache与php
# vi /usr/local/apache2/conf/httpd.conf
在最后一行加上:
AddType application/x-httpd-php .php
查找:(设置 WEB 默认文件)
DirectoryIndex index.html
替换为:
DirectoryIndex index.php index.html index.htm //在 WEB 目录不到默认文件,httpd 就会执行 /var/www/error/noindex.html

找到这一段:
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride none

更改为AllowOverride all
允许apacherewrite

保存httpd.conf,退出。

#/usr/local/apache2/bin/apachectl restart //重启Apache
这时会出现错误:

/usr/local/apache2/bin/apachectl start
httpd: Syntax error on line 107 of /usr/local/apache2/conf/httpd.conf: Cannot load /usr/local/apache2/modules/libphp5.so into server: /usr/local/apache2/modules/libphp5.so: cannot restore segment prot after reloc: Permission denied

不急,我们慢慢解决。

先重启下机器:
reboot
这个Permission denied问题,在centos 5下面一般是Selinux引起的,作为生产用服务器,我建议你千万别草率地关掉Selinux一了百了。就像家里的防盗网,阻碍了你的猫自由进出窗户,你不能为了猫方便,就把防盗网简单拆除是同样的道理。我看见网上许多人建议把Selinux简单关闭来解决这个问题,很不以为然。
我们可以这样操作:

# audit2allow -d

# cd /etc/selinux/targeted/modules/
# audit2allow -M local -d

屏幕产生如下提示:

产生类型强制文件:local.te
正在编译策略
checkmodule -M -m -o local.mod local.te
semodule_package -o local.pp -m local.mod

********************重要 ***********************

为了在内核中加载这个新创建的策略软件包,
您需要执行
semodule -i local.pp
我们运行
# semodule -i local.pp
这样就让Selinux加载了新的规则。
更详细的内容请看BLOG上的转贴:
http://www.cnprint.org/bbs/blogs/1/blog48.html
reboot

这样我保留了selinux的功能,同时apache也能正常运行。

查看确认 L.A.M.P 环境信息
vi /usr/local/apache2/htdocs/phpinfo.php

新增加下面一行,并保存。
<?php phpinfo(); ?>
# chmod 755 /usr/local/apache2/htdocs/phpinfo.php
用浏览器打开http://127.0.0.1/phpinfo.php
# echo ' ' > /usr/local/apache2/htdocs/testdb.php
# chmod 755 /usr/local/apache2/htdocs/testdb.php
# service mysqld start
用浏览器打开http://127.0.0.1/testdb.php
检查 phpinfo 中的各项信息是否正确。

安装phpmyadmin

  1. cd /usr/local/src
  2. wget http://jaist.dl.sourceforge.net/sourceforge/phpmyadmin/phpMyAdmin-3.1.3-all-languages.tar.gz
  3. tar zxvf phpMyAdmin-3.1.3-all-languages.tar.gz
  4. cp -rf phpMyAdmin-3.1.3-all-languages /data/www/wwwroot/test.com/phpmyadmin

在浏览器里输入地址。如果出现

You don't have permission to access / on this server 错误

解决:httpd.conf内找到如下

< Directory / >
     Options FollowSymLinks
     AllowOverride None
     Order deny,allow
     Deny from all
< /Directory >

去掉红色部分就可以了,

注:如果还是不行。检查下WEB目录权限。

进入PHPMYADMIN后出现:

无法载入 mcrypt 扩展 错误 的话

解决:yum -y install php-mcrypt

安装下插件OK

转载于:https://blog.51cto.com/ylj798/1063375

centos5.2 lamp安装指南相关推荐

  1. lamp安装指南(转)

    主要软件包, 1. httpd-2.2.6.tar.gz 2. mysql-5.0.45-linux-i686-glibc23.tar.gz ( 这个版本是已编译好的压缩包,解压后稍做配置即可使用 ) ...

  2. Centos5.5下安装LAMP完整版

    Centos5.5(32bit) Author:hx10 Date: 2010/7/25  hangzhou Blog :http://hi.baidu.com/hx10 转载:http://hx10 ...

  3. LAMP环境搭建之编译安装指南(php-5.3.27.tar.gz)

    测试环境:CentOS release 6.5 (Final) 软件安装:httpd-2.2.27.tar.gz   mysql-5.1.72.tar.gz   php-5.3.27.tar.gz 1 ...

  4. LAMP环境搭建过程中出现的问题——基于VM虚拟CentOS-5.6

    出现问题并给出解决方法:   1. 出错一:configure libpng时出错:   checking for zlibVersion in -lz... no configure: error: ...

  5. centos6.5 安装php探针,Centos5.5下安装LAMP完整版

    冰鱼客:以下保存为web.config|@|<?xml version="1.0" encoding="UTF-8"?>|@||@| |@||@| ...

  6. LAMP 关键数据集锦技术选项参考

    LAMP 关键数据集锦技术选项参考 源自日积月累自己的其他人的经验总结 负载均衡 LVS 工作在四层,内核态,性能极高,有VIP功能,配合 keepalived 做有效的 心跳检查和负载均衡安装配置 ...

  7. linux下的lamp环境的搭建!!!

    本篇文章转自http://hx100.blog.51cto.com/44326/359296 如果涉及侵权请作者及时通知!!感谢作者的分享!! Centos5.5下安装LAMP完整版 Centos5. ...

  8. CentOS下LAMP实战与心得

    可能说对有一些老鸟来说LAMP环境搭建很简单,但是对菜鸟来说,自己动手就会出现各种问题,以下是我遇到的问题:  提问1:http://bbs.php100.com/read.php?tid=62434 ...

  9. 模块式lamp fpm式lamp

    Linux+Apache+Mysql/MariaDB+Perl/PHP/Python一组常用来搭建动态网站或者服务器的开源软件,本身都是各自独立的程序,但是因为常被放在一起使用,拥有了越来越高的兼容度 ...

最新文章

  1. 精选Spring Boot三十五道必知必会知识点!
  2. 【Luogu】P3950部落冲突(树链剖分)
  3. 例4:写一个把字符串的所有大写字母改为小写的程序。设字符串以0结尾。
  4. html 后# 号的作用,及html 如何传参
  5. 映射文件中增删改查标签中的parameterType和resultType
  6. WCF发布到IIS 7.0,并以https访问
  7. OpenPilot 0.3.2 发布,开源自动驾驶技术
  8. 存储单位 KB MB bit
  9. 【Alpha】Scrum Meeting 2
  10. 经典算法大全之费式数列
  11. python中spider的用法_Python爬虫从入门到放弃(十五)之 Scrapy框架中Spiders用法
  12. photoshop制作gif动画
  13. 数字人枫灵Lynn,获得江苏省文化产业周刊关注!
  14. 1.5 人工智能迅速发展的技术领域
  15. SQL入门SQL基本介绍
  16. 使用Aurora在Word中插入算法伪代码教程,亲测有效,写论文必备
  17. postman接口自动化图文案例介绍
  18. 07 | 接头暗语:如何利用 Netty 实现自定义协议通信?
  19. android杀死 后台服务,android怎么样做到相似于微信那样后台服务不会被杀死
  20. 欧盟调查显示100Mbps宽带网络建设需5020亿欧元资金

热门文章

  1. 《我的第一本算法书》读书笔记
  2. c语言getchar在哪个头文件_c语言入门(一)
  3. 为什么两个controller的session的id不一样_新笑傲江湖手游服务器名字为什么不一样解答...
  4. 学了一年matlab,我到现在还不会读论文~
  5. BERT-BiLSTM-CRF基于BERT预训练的中文命名实体识别TensorFlow实现
  6. 信息抽取:SPO三元组知识
  7. BAT面试问题--算法工程师(机器学习)
  8. vue 怎么设置 项目ico_vue项目如何优雅地设置favicon.ico
  9. c++贪吃蛇_细致的C语言写贪吃蛇教程+详细思路-适合新手附源码
  10. html5 input选择文件,input文件选择,限定文件类型。