使用CentOS源安装LAMP全过程

系统 Linux
本文主要讲解如何使用CentOS源安装LAMP,之前的一些准备工作,配置httpd.conf,注册服务,并启动Apache。LAMP安装完成后测试等。

CentOS源使用的范围很广泛。这次我们要来讲一下如何用CentOS源安装LAMP。为了方便大家的理解,我们使用了很简单的安装方法。希望大家可以很好的理解。昨天又换了VPS,来自DiaHosting。这次最主要的目的是用作Web服务器。为了习惯,还是决定先用Apache。

首先做一些准备工作,准备好CentOS源安装包:
cd /usr/local/src
wget http://mysql.easynet.be/Downloads/MySQL-5.1/mysql-5.1.44.tar.gz
wget http://apache.etoak.com/httpd/httpd-2.2.13.tar.gz
wget http://cn.php.net/distributions/php-5.2.13.tar.gz
wget http://ncu.dl.sourceforge.net/project/phpmyadmin/phpMyAdmin/3.2.5/phpMyAdmin-3.2.5-all-languages.tar.gz

接着CentOS源安装编译器,运行库等需要的东西:
yum install make
yum install gcc gcc-c++
yum install libxml2 libxml2-devel
yum install libmcrypt libmcrypt-devel
yum install libtool-ltdl
yum install apr apr-*
yum install ncurses ncurses-*

CentOS源安装sendmail
yum install sendmail sendmail-*
service sendmail start

接下来开始CentOS源安装配置MySQL:
cd /usr/local/src
tar zxvf mysql-5.1.44.tar.gz
cd mysql-5.1.44
./configure --prefix=/usr/local/mysql
make
make install
cp support-files/my-medium.cnf /etc/my.cnf
cd /usr/local/mysql
groupadd mysql
useradd -g mysql -d /usr/local/mysql/var mysql
chown -R mysql .
chgrp -R mysql .
bin/mysql_install_db --user=mysql
chown -R mysql var

将MySQL注册为服务,开机自启动:
cp /usr/local/src/mysql-5.1.44/support-files/mysql.server \
/etc/rc.d/init.d/mysql
chmod +x /etc/rc.d/init.d/mysql
chkconfig --add mysql
service mysql start

MySQL启动之后,设置root密码:
/usr/local/mysql/bin/mysqladmin -u root \
-p password newpassword

下一步安装Apache:
cd /usr/local/src
tar zxvf httpd-2.2.13.tar.gz
cd httpd-2.2.13
./configure --prefix=/usr/local/apache \
--with-mysql=/usr/local/mysql \
--enable-rewrite=shared \
--enable-module=so \
--enable-shared=max
make
make install

***CentOS源安装PHP:
cd /usr/local/src
tar zxvf php-5.2.13.tar.gz
cd php-5.2.13
./configure --prefix=/usr/local/php \
--with-mysql=/usr/local/mysql \
--with-apxs2=/usr/local/apache/bin/apxs \
--with-mcrypt \
--enable-mbstring
make
make install
cp php.ini-dist /usr/local/php/lib/php.ini

配置httpd.conf:
vi /usr/local/apache/conf/httpd.conf
找到“AddType application/x-gzip .tgz”这一行,在下面添加:
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
找到“DirectoryIndex index.html”,改为:
DirectoryIndex index.php index.html
找到“#ServerName”,去掉注释的#号。

将所有“AllowOverride None”,改为:
AllowOverride All

注册服务,并启动Apache:
cp /usr/local/apache/bin/apachectl \
/etc/rc.d/init.d/httpd
vi /etc/rc.d/init.d/httpd

找到“#!/bin/sh”,另起一行,增加:
# chkconfig: 35 70 30
# description: Apache
继续:
chkconfig --add httpd
service httpd start

LAMP安装完成,新建一个测试页面:
vi /usr/local/apache/htdocs/index.php
写入:
打开浏览器,http://localhost/index.php。

下面根据需要,CentOS源安装phpMyAdmin:
cd /usr/local/src
tar zxvf phpMyAdmin-3.2.5-all-languages.tar.gz
mv phpMyAdmin-3.2.5-all-languages /usr/local/apache/htdocs/phpmyadmin
配置phpMyAdmin:
cd /usr/local/apache/htdocs/phpmyadmin
cp config.sample.inc.php config.inc.php
vi config.inc.php
找到“blowfish_secret”,在后面的单引号之间添加任意字符串。
访问 http://localhosst/phpmyadmin,以MySQL用户登陆,CentOS源安装LAMP成功。
 

【编辑推荐】

  1. 更新后比较好的国内CentOS源代码
  2. ***修改CentOS源代码更新
  3. 简单介绍CentOS安装
  4. 初学者如何对linux CentOS安装
  5. 快速解决CentOS安装后的初始化问题
责任编辑:小霞
相关推荐

2011-03-11 10:39:02

YUM安装LAMP

2010-11-19 09:30:29

2011-02-22 10:46:02

Samba配置

2011-01-21 17:51:52

2011-09-06 15:38:20

QT安装

2009-06-10 16:55:42

cygwin netb安装

2010-03-10 13:24:45

Zend Debugg

2010-03-26 14:48:03

Ylmf OS 2.0

2011-04-02 09:20:23

freebsdmrtg安装

2011-04-18 15:56:10

软件测试

2009-12-08 17:56:16

WCF配置

2009-11-26 11:30:12

VS2003控件

2009-04-13 12:37:18

2009-10-21 09:14:26

Visual Stud

2009-03-04 10:10:49

PVS服务器桌面虚拟化Xendesktop

2012-11-06 10:19:18

Java自定义加载Java类

2010-11-19 10:11:49

Oracle物化视图

2010-03-01 17:01:03

Python编程技巧

2010-06-17 13:10:09

Linux Grub修

2009-06-15 16:05:00

NetBeans ID编译odinms
点赞
收藏

51CTO技术栈公众号