CentOS — 搭建 LAMP 运行环境 & Webmin

以 CentOS 5.8 32位的系统为例。 

安装 CentOS RPM 签署金钥

你须要安装 CentOS RPM 签署金钥。基于安全理由,这个金钥在基本系统安装时不会被安装。如此你就可以在核实金钥的真确性后才将它安装在你的系统上。RPM 有能力从一个 CentOS 镜像中取得金钥:参考:我可以从哪里取得 CentOS 的组件签署金钥?

rpm --import http://www.jasonlitka.com/media/RPM-GPG-KEY-jlitka

 

添加外部源

因为系统基本的源的MySQL和PHP程序比较旧,所以我们添加比较新的外部源。

vi /etc/yum.repos.d/CentOS-Base.repo

在底部增加下面信息:

[utterramblings]
name=Jason's Utter Ramblings Repo
baseurl=http://www.jasonlitka.com/media/EL$releasever/$basearch/
enabled=1
gpgcheck=1
gpgkey=http://www.jasonlitka.com/media/RPM-GPG-KEY-jlitka

 

安装 Apache

默认CentOS都安装了Apache,你可以通过在终端输入如下命令来启动Apache服务器:

apachectl start

启动,停止,重启的命令如下:

apachectl start
apachectl stop
apachectl restart

默认配置文件的路径在:

/etc/httpd/conf/httpd.conf

默认的网页文件的存放路径在:

/var/www/html/

* 如果您的Server没有安装Apache,那么请参考以下命令安装Apache

yum install httpd
chkconfig --levels 235 httpd on
/etc/init.d/httpd start

 

安装 MySQL

执行yum程序安装MySQL

yum install mysql mysql-server

添加MySQL进启动项(这样系统启动时会自动启动MySQL),并立即启动MySQL服务器:

chkconfig --levels 235 mysqld on
/etc/init.d/mysqld start

设置MySQL root帐号密码:

mysql_secure_installation

Shell交互:

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!
 
 
In order to log into MySQL to secure it, we'll need the current
password for the root user.  If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
 
Enter current password for root (enter for none):
OK, successfully used password, moving on...
 
Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.
 
Set root password? [Y/n] <-- ENTER
New password: <-- 你的MySQL root密码
Re-enter new password: <-- 你的MySQL root密码
Password updated successfully!
Reloading privilege tables..
 ... Success!
 
 
By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.
 
Remove anonymous users? [Y/n] Y<-- ENTER #删除匿名用户?
 ... Success!
 
Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.
 
Disallow root login remotely? [Y/n] n<-- ENTER #不允许远程连接?
 ... Success!
 
By default, MySQL comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.
 
Remove test database and access to it? [Y/n] Y<-- ENTER #删除测试数据库?
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!
 
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
 
Reload privilege tables now? [Y/n] Y<-- ENTER #立刻刷新权限表?
 ... Success!
 
Cleaning up...
 
 
 
All done!  If you've completed all of the above steps, your MySQL
installation should now be secure.
 
Thanks for using MySQL!

 这里我设置了允许MySQL远程连接,所以需要重启MySQL服务器:

/etc/init.d/mysqld restart

 MySQL默认的配置文件路径为

/etc/my.cnf

 

安装 PHP

我们可以按照下面的命令安装PHP和Apache PHP模块:

yum install php

安装相关模块使用PHP支持MySQL:为了让PHP支持MySQL,我们可以安装php-mysql软件包;你也可以安装其它的php模块;

可以使用以下命令搜索可用的php模块:

yum search php

选择一些你需要的模块进行安装:

yum install php-mysql php-common php-mbstring php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-pdo php-mcrypt

现在重启Apache:

apachectl restart

 

安装 Webmin

Webmin是目前功能最强大的基于Web的Unix系统管理工具。管理员通过浏览器访问Webmin的各种管理功能并完成相应的管理动作。

下载Webmin RPM包

wget http://prdownloads.sourceforge.net/webadmin/webmin-1.580-1.noarch.rpm

请到官网查看是否是最新版本的链接。Webmin Download

安装Webmin

rpm -U webmin-1.550-1.noarch.rpm

* 在我的机器上出现了如下的错误:

Header V3 DSA signature: NOKEY, key ID 11f63c51

解决办法如下:可参考 linux Header V3 DSA signature: NOKEY, key ID 错误解决方法

rpm --import /etc/pki/rpm-gpg/RPM*
rpm -U webmin-1.550-1.noarch.rpm

在终端命令行下启动Webmin

/etc/rc.d/init.d/webmin start

通过浏览器访问Webmin,假设您的Ip地址为:192.168.100.100,那么访问Webmin的URL为 http://192.168.100.100:10000,用户名为 root, 密码为 root 的密码。

 

参考:

CentOS 5.x yum安装LAMP(Apache+MySQL+PHP) 

CentOS 5安装免费主机控制面板Webmin

linux Header V3 DSA signature: NOKEY, key ID 错误解决方法

Centos下webmin安装

 


 

到这里就完成了 LAMP 运行环境的搭建。对于MySQL的备份,请参考 CentOS — MySQL备份 Shell 脚本

posted @ 2012-05-16 12:12  Old  阅读(1484)  评论(0编辑  收藏  举报