CentOS5.2下LAMP环境的搭建
时间:2009-04-21
来源:互联网
1.最小化安装CentOS5.2
2.设置防火墙以及关闭不必要的服务
# setup
选择Firewall configuration进入防火墙设置,选择自定义,然后用空格键选择允许WWW(HTTP)和FTP,其它可根据情况设置,保存退出到入口界面。
选择system service选项进入服务设置,以空格键选定需要的服务。以下仅列出需要启动的服务,其它一律关闭:crond,irqbalance,microcode_ctl,network,vsftpd,sshd,syslog
3.修改/etc/yum.repos.d/CentOS-Base.repo,将镜像站点地址改为在中国的镜像地址。如将[base]部分的mirrorlist行注释掉,baseurl行改为baseurl= http://ftp.hostrino.com/pub/centos/5.2/os/$basearch/,其它部分类似.
然后执行:# yum upgrade
4.使用yum程序安装所需开发包
# yum install gcc gcc-c++ flex bison autoconf automake bzip2-devel zlib-devel ncurses-devel libjpeg-devel libpng-devel libtiff-devel freetype-devel pam-devel openssl-devel libxml2-devel gettext-devel libtool libtool-ltdl libtool-ltdl-devel
5.编译安装GD2
# cd /usr/local/src
# wget –c http://www.boutell.com/gd/http/gd-2.0.35.tar.gz
# tar zxvf gd-2.0.35.tar.gz
# cd gd-2.0.35
#./configure --prefix=/usr/local/gd2 --mandir=/usr/share/man
# make
# make install
6.编译安装MySQL
# cd /usr/local/src
# wget –c http://mysql.skynet.be/Downloads/MySQL-5.1/mysql-5.1.33.tar.gz
# tar zxvf mysql-5.1.33.tar.gz
# cd mysql-5.1.33
# ./configure --prefix=/usr/local/mysql --localstatedir=/usr/local/mysql --with-comment=Source --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-ndb-debug --without-isam --with-unix-socket-path=/usr/local/mysql/var/mysql.sock
# make
# make install
# 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,出现错误。查看MySQL错误日志,显示是usr local mysql libexec mysqld unknown option '--skip-federated'错误,在my.cnf文件中找到skip-federated,将其注释掉,再启动MySQL即可
# bin/mysqladmin -u root password "123456"
7.安装Apache
# cd /usr/local/src
# wget -c http://archive.apache.org/dist/httpd/httpd-2.2.11.tar.gz
# tar zxvf httpd-2.2.11.tar.gz
# cd httpd-2.2.11
依次安装apr和apr-util
# cd srclib/apr
#./configure --prefix=/usr/local/apr --enable-threads --enable-other-child --enable-static
# make
#make install
# cd ../apr-util
# ./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.11
# ./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 --enable-cgi --with-apr=/usr/local/apr/ --with-apr-util=/usr/local/apr-util/ --enable-ssl --with-ssl=/usr/include/openssl
#make
#make install
启动Apache
#/usr/local/apache2/bin/apachectl start
configure注解:
./configure //配置源代码树
--prefix=/usr/local/apache2 //指定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
--enable-cgi //启用CGI
--enable-ssl // 编译ssl模块。
将apache设置成开机自启动:
在/etc/rc.d/rc.local文件中加入一行
/usr/local/apache2/bin/apachectl start
这样每次重新启动系统以后,apache也会随系统一起启动.
8.安装PHP
# cd /usr/local/src
# wget -c http://cn.php.net/distributions/php-5.2.9.tar.gz
# wget -c http://download.suhosin.org/suhosin-patch-5.2.8-0.9.6.3.patch.gz
# tar zxvf php-5.2.9.tar.gz
# gunzip suhosin-patch-5.2.8-0.9.6.3.patch.gz
# cd php-5.2.9
# patch -p 1 -i ../suhosin-patch-5.2.8-0.9.6.3.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-sockets --with-mysql-sock=/usr/local/mysql/var/mysql.sock --enable-soap --with-openssl --enable-suhosin
#make
#make install
9.整合Apache和PHP
# vi /usr/local/apache2/conf/httpd.conf
加上如下一行:
AddType application/x-httpd-php .php
搜索DirectoryIndex index.html,将index.php添加到后面
搜索AllowOverride none,更改为AllowOverride all //允许apacherewrite
搜索DocumentRoot “/usr/local/apache2/htdocs”改为DocumentRoot “/home/www” //更改网站根目录为/home/www
将<Directory “/usr/local/apache2/htdocs”>改为<Directory “/home/www”>
保存httpd.conf,退出。
# chmod 755 -R /home/www //设置网站根目录权限
# /usr/local/apache2/bin/apachectl restart //重启Apache
如果出现错误,则关闭selinux:
# vi /etc/selinux/config
把SELINUX=enforcing注释掉:#SELINUX=enforcing.然后新加一行:SELINUX=disabled 保存,退出。
重启系统:# reboot
10.安装phpmyadmin
# cd /usr/local/src
# wget -c http://jaist.dl.sourceforge.net/sourceforge/phpmyadmin/phpMyAdmin-3.1.4-rc2-all-languages.tar.gz
# tar zxvf phpMyAdmin-3.1.4-rc2-all-languages.tar.gz
# cp -rf phpMyAdmin-3.1.4-rc2-all-languages /home/www/phpmyadmin
作者: cgh43 发布时间: 2009-04-21
作者: cnkiller 发布时间: 2009-04-22
作者: londit.cn 发布时间: 2009-04-22
那是测试开发用的吧
楼上的编译GD太过简单了
作者: sunweiyan 发布时间: 2009-04-24
对啊,只是说比较好用,呵呵
作者: cnkiller 发布时间: 2009-04-24
5.编译安装GD2
# cd /usr/local/src
# wget –c http://www.boutell.com/gd/http/gd-2.0.35.tar.gz
gd-2.0.35.tar.gz 不存在,下载了gd-2.0.9.tar.gz的,结果make失败!
出错了~~~
作者: langcier 发布时间: 2009-12-28
作者: fyp83 发布时间: 2010-02-02
作者: luoshengmiao 发布时间: 2011-10-28
作者: 剑侠情缘 发布时间: 2011-10-28
其一比较省事儿,不用面对编译过程中各种困扰的问题
其二这个会比新手随意编译出来的稳定,因为发行商都作了一定的优化和测试
作者: lovehaw 发布时间: 2011-10-31
作者: cyjjiji 发布时间: 2012-03-04
作者: aljoin 发布时间: 2012-05-04
作者: jy02550649 发布时间: 2013-01-29
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28