CentOS 安装 LAMP
CentOS源使用的范围很广泛。这次我们要来讲一下如何用CentOS源安装LAMP。为了方便大家的理解,我们使用了很简单的安装方法。希望大家可以很好的理解。昨天又换了VPS,来自DiaHosting。这次最主要的目的是用作Web服务器。为了习惯,还是决定先用Apache。
首先做一些准备工作,准备好CentOS源安装包:
接着CentOS源安装编译器,运行库等需要的东西:
- yuminstallmake
- yuminstallgccgcc-c++
- yuminstalllibxml2libxml2-devel
- yuminstalllibmcryptlibmcrypt-devel
- yuminstalllibtool-ltdl
- yuminstallaprapr-*
- yuminstallncursesncurses-*
CentOS源安装sendmail:
- yuminstallsendmailsendmail-*
- servicesendmailstart
接下来开始CentOS源安装配置MySQL:
- cd/usr/local/src
- tarzxvfmysql-5.1.44.tar.gz
- cdmysql-5.1.44
- ./configure--prefix=/usr/local/mysql
- make
- makeinstall
- cpsupport-files/my-medium.cnf/etc/my.cnf
- cd/usr/local/mysql
- groupaddmysql
- useradd-gmysql-d/usr/local/mysql/varmysql
- chown-Rmysql.
- chgrp-Rmysql.
- bin/mysql_install_db--user=mysql
- chown-Rmysqlvar
将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--addmysql
- servicemysqlstart
MySQL启动之后,设置root密码:
- /usr/local/mysql/bin/mysqladmin-uroot\
- -ppasswordnewpassword
下一步安装Apache:
- cd/usr/local/src
- tarzxvfhttpd-2.2.13.tar.gz
- cdhttpd-2.2.13
- ./configure--prefix=/usr/local/apache\
- --with-mysql=/usr/local/mysql\
- --enable-rewrite=shared\
- --enable-module=so\
- --enable-shared=max
- make
- makeinstall
最后CentOS源安装PHP:
- cd/usr/local/src
- tarzxvfphp-5.2.13.tar.gz
- cdphp-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
- makeinstall
- cpphp.ini-dist/usr/local/php/lib/php.ini
配置httpd.conf:
- vi/usr/local/apache/conf/httpd.conf
找到“AddType application/x-gzip .tgz”这一行,在下面添加:
- AddTypeapplication/x-httpd-php.php
- AddTypeapplication/x-httpd-php-source.phps
找到“DirectoryIndex index.html”,改为:
- DirectoryIndexindex.phpindex.html
找到“#ServerName”,去掉注释的#号。
将所有“AllowOverride None”,改为:
- AllowOverrideAll
注册服务,并启动Apache:
- cp/usr/local/apache/bin/apachectl\
- /etc/rc.d/init.d/httpd
- vi/etc/rc.d/init.d/httpd
找到“#!/bin/sh”,另起一行,增加:
- #chkconfig:357030
- #description:Apache
继续:
- chkconfig--addhttpd
- servicehttpdstart
LAMP安装完成,新建一个测试页面:
- vi/usr/local/apache/htdocs/index.php
写入:
下面根据需要,CentOS源安装phpMyAdmin:
- cd/usr/local/src
- tarzxvfphpMyAdmin-3.2.5-all-languages.tar.gz
- mvphpMyAdmin-3.2.5-all-languages/usr/local/apache/htdocs/phpmyadmin
配置phpMyAdmin:
- cd/usr/local/apache/htdocs/phpmyadmin
- cpconfig.sample.inc.phpconfig.inc.php
- viconfig.inc.php
找到“blowfish_secret”,在后面的单引号之间添加任意字符串。
以MySQL用户登陆,CentOS上安装LAMP的方法,CentOS源安装LAMP就安装成功啦!