`
txf2004
  • 浏览: 6883539 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

CentOS上安装LAMP的方法

 
阅读更多

CentOS 安装 LAMP

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

首先做一些准备工作,准备好CentOS源安装包:

接着CentOS源安装编译器,运行库等需要的东西:

  1. yuminstallmake
  2. yuminstallgccgcc-c++
  3. yuminstalllibxml2libxml2-devel
  4. yuminstalllibmcryptlibmcrypt-devel
  5. yuminstalllibtool-ltdl
  6. yuminstallaprapr-*
  7. yuminstallncursesncurses-*

CentOS源安装sendmail:

  1. yuminstallsendmailsendmail-*
  2. servicesendmailstart

接下来开始CentOS源安装配置MySQL:

  1. cd/usr/local/src
  2. tarzxvfmysql-5.1.44.tar.gz
  3. cdmysql-5.1.44
  4. ./configure--prefix=/usr/local/mysql
  5. make
  6. makeinstall
  7. cpsupport-files/my-medium.cnf/etc/my.cnf
  8. cd/usr/local/mysql
  9. groupaddmysql
  10. useradd-gmysql-d/usr/local/mysql/varmysql
  11. chown-Rmysql.
  12. chgrp-Rmysql.
  13. bin/mysql_install_db--user=mysql
  14. chown-Rmysqlvar

将MySQL注册为服务,开机自启动:

  1. cp/usr/local/src/mysql-5.1.44/support-files/mysql.server\
  2. /etc/rc.d/init.d/mysql
  3. chmod+x/etc/rc.d/init.d/mysql
  4. chkconfig--addmysql
  5. servicemysqlstart

MySQL启动之后,设置root密码:

  1. /usr/local/mysql/bin/mysqladmin-uroot\
  2. -ppasswordnewpassword

下一步安装Apache:

  1. cd/usr/local/src
  2. tarzxvfhttpd-2.2.13.tar.gz
  3. cdhttpd-2.2.13
  4. ./configure--prefix=/usr/local/apache\
  5. --with-mysql=/usr/local/mysql\
  6. --enable-rewrite=shared\
  7. --enable-module=so\
  8. --enable-shared=max
  9. make
  10. makeinstall

最后CentOS源安装PHP:

  1. cd/usr/local/src
  2. tarzxvfphp-5.2.13.tar.gz
  3. cdphp-5.2.13
  4. ./configure--prefix=/usr/local/php\
  5. --with-mysql=/usr/local/mysql\
  6. --with-apxs2=/usr/local/apache/bin/apxs\
  7. --with-mcrypt\
  8. --enable-mbstring
  9. make
  10. makeinstall
  11. cpphp.ini-dist/usr/local/php/lib/php.ini

配置httpd.conf:

  1. vi/usr/local/apache/conf/httpd.conf

找到“AddType application/x-gzip .tgz”这一行,在下面添加:

  1. AddTypeapplication/x-httpd-php.php
  2. AddTypeapplication/x-httpd-php-source.phps

找到“DirectoryIndex index.html”,改为:

  1. DirectoryIndexindex.phpindex.html

找到“#ServerName”,去掉注释的#号。

将所有“AllowOverride None”,改为:

  1. AllowOverrideAll

注册服务,并启动Apache:

  1. cp/usr/local/apache/bin/apachectl\
  2. /etc/rc.d/init.d/httpd
  3. vi/etc/rc.d/init.d/httpd

找到“#!/bin/sh”,另起一行,增加:

  1. #chkconfig:357030
  2. #description:Apache

继续:

  1. chkconfig--addhttpd
  2. servicehttpdstart

LAMP安装完成,新建一个测试页面:

  1. vi/usr/local/apache/htdocs/index.php

写入:

下面根据需要,CentOS源安装phpMyAdmin:

  1. cd/usr/local/src
  2. tarzxvfphpMyAdmin-3.2.5-all-languages.tar.gz
  3. mvphpMyAdmin-3.2.5-all-languages/usr/local/apache/htdocs/phpmyadmin

配置phpMyAdmin:

  1. cd/usr/local/apache/htdocs/phpmyadmin
  2. cpconfig.sample.inc.phpconfig.inc.php
  3. viconfig.inc.php

找到“blowfish_secret”,在后面的单引号之间添加任意字符串。

以MySQL用户登陆,CentOS上安装LAMP的方法,CentOS源安装LAMP就安装成功啦!

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics