CentOS源安装LAMP全过程
时间:2014-02-26 02:56 来源:linux.it.net.cn 作者:IT网
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成功。
(责任编辑:IT)
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成功。 (责任编辑:IT) |