开始安装MySQL5 首先我们应该先用下面的命令安装MySQL:
yum install mysql mysql-server
然后我们需要创建MySQL系统的启动键链接启动MySQL
服务器,这样以便于MySQL在系统启动时自动启动
chkconfig --levels 235 mysqld on
/etc/init.d/mysqld start
为MySQL root帐户设置密码:
mysql_secure_installation
会出现下面的一系列提示:
root@server1 ~]# mysql_secure_installation
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: <-- yourrootsqlpassword
Re-enter new password: <-- yourrootsqlpassword
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] <-- 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] <-- 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] <-- 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] <-- 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!
[root@server1 ~]#
安装阿帕奇2 Apache2的是作为一个CentOS的软件包,因此我们可以直接用下面命令安装它:
yum install httpd
现在配置系统在引导时启动Apache
chkconfig --levels 235 httpd on
并启动Apache
/etc/init.d/httpd start
Apache的默认文档根目录是在CentOS上的/var/www/html 目录 ,配置文件是/etc/httpd/conf/httpd.conf。配置存储在的/etc/httpd/conf.d/目录。
4.安装PHP5
我们可以用下面的命令来安装PHP5
yum install php
安装完需要重启
/etc/init.d/httpd restart
5.我们可以安装PHP5和Apache的PHP5的模块如下:
默认网站的文件根目录是在/srv/www/html中。现在我们将在该目录中创建一个小型PHP文件(info.php的)在浏览器中调用它。该文件将显示很多关于我们的PHP安装,如安装的PHP版本和有用的一些细节。
vi /var/www/html/info.php
6.PHP5获得MySOL的支持
让PHP在MySQL中获得支持,我们可以安装的php-mysql软件包。安装一些其他的PHP5模块,以及您可能需要的应用程序,这是一个好主意:
yum search php
还安装需要安装的
yum install php-mysql php-gd php-imap php-ldap php-mbstring php-odbc php-pear php-xml php-xmlrpc
现在重新启动Apache2的:
/etc/init.d/httpd restart
现在,重载http://192.168.0.100/info.php在您的浏览器,并再次向下滚动到模块部分。现在,你应该找到许多新的模块,包括MySQL模块:
7.安装phpMyAdmin
phpMyAdmin是一个网络接口,通过它可以管理你的MySQL数据库。
首先,我们使CentOS系统RPMForge软件库的phpMyAdmin,而不是官方的CentOS 6.2库:
所以需要导入RPMForge的GPG密钥:
rpm --import http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt
x86_64系统:
yum install http://pkgs.repoforge.org/rpmfor ... 2.el6.rf.x86_64.rpm
在i386系统:
yum install http://pkgs.repoforge.org/rpmfor ... 2-2.el6.rf.i686.rpm
安装phpmyadmin
yum install phpmyadmin
现在我们可以设置phpMyAdmin,了我们可以改变Apache的配置来让phpMyAdmin不仅仅只能从localhost登录。
vi /etc/httpd/conf.d/phpmyadmin.conf
[
本帖最后由 xiexie 于 2013-11-7 23:55 编辑 ]