一、安装 MySQL
首先来进行 MySQL 的安装。打开超级终端,输入:
[root@localhost
~]# yum install mysql mysql
-server
安装完毕,让 MySQL 能够随系统自动启动:
[root@localhost
~]# chkconfig
--levels
235 mysqld on
[root@localhost
~]#
/etc/init
.
d
/mysqld start
设置 MySQL 数据 root 账户的密码:
[root@localhost
~]# mysql_secure_installation
当出现如下提示时候直接按回车:
Enter current password
for root
出现如下再次回车:
Set root password
?
[
Y
/n
]
出现如下提示输入你需要设置的密码,回车后在输入一次确认:
New password
:
接下来还会有四个确认,分别是:
Remove anonymous users
?
[
Y
/n
]
Disallow root login remotely
?
[
Y
/n
]
Remove test database and access to it
?
[
Y
/n
]
Reload privilege tables now
?
[
Y
/n
]
直接回车即可。
二、安装 Apache 组件
由于 CentOS 已经封装了 Apache,直接运行安装:
[root@localhost
~]# yum install httpd
同样配置系统让 Apache 随系统启动:
[root@localhost
~]# chkconfig
--levels
235 httpd on
配置完毕,启动 Apache:
[root@localhost
~]#
/etc/init
.
d
/httpd start
此时已经可以访问你的服务器,不出意外的话,能够看到 “Apache 2 Test Page powered by CentOS” 的测试页面。注意,如果其他机器访问这台服务无法显示这个页面,而直接在这台服务器上可以访问的话,一般情况下是 CentOS 自带的防火墙禁止了。你只需要进入防火墙,将 “WWW” 对应的 “80” 端口打开即可。
[root@localhost html]# /sbin/iptables -I INPUT -p TCP --dport 80 -j ACCEPT