当前位置:Gxlcms > 数据库问题 > 在CenterOS 6.5上安装Apache mysql php

在CenterOS 6.5上安装Apache mysql php

时间:2021-07-01 10:21:17 帮助过:3人阅读

2.编译环境的安装

yum -y install gcc  gcc  gcc-c 

3.需要将自带的httpd给卸载掉

yum erase httpd

4.安装zlib-devel libtool ncurses-devel libxml2-devel

yum install zlib-devel libtool ncurses-devel libxml2-devel

二、安装 MySQL
1.直接进行MySQL安装

[root@localhost ~]# yum install mysql mysql-server

2.安装完后,让MySQL随系统启动

[root@localhost ~]# chkconfig --levels 235 mysqld on
[root@localhost ~]# /etc/init.d/mysqld start

3.设置MySQL的密码

[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]

4.重启MySQL

/etc/init.d/mysqld restart #重启
/etc/init.d/mysqld stop #停止
/etc/init.d/mysqld start #启动

三、安装 Apache
1.由于 CentOS 已经封装了 Apache,直接运行安装

[root@localhost ~]# yum install httpd

2.同样配置系统让 Apache 随系统启动:

[root@localhost ~]# chkconfig --levels 235 httpd on

3.启动Apache

[root@localhost ~]# /etc/init.d/httpd start

如果在启动过程中出现

[root@localhost ~]# Starting httpd: httpd: Could not reliably determine the server‘s fully qualified domain name, using payment.meijialclub.com for ServerName [  OK  ]

那就修改一下httpd.conf,其实不修改也无所谓

4.配置完毕,启动 Apache:

[root@localhost ~]# vi /etc/httpd/conf/httpd.conf

找到#ServerName www.example.com:80然后在下面加入如下

ServerName 127.0.0.1:80

5.重启apache

/etc/init.d/httpd restart

6.此时apache已经安装好了,访问你的ip地址(服务器地址)就ok了
四、安装php

1.安装 PHP

[root@localhost ~]# yum install php

2.重启Apache

[root@localhost ~]# /etc/init.d/httpd restart

四、测试 PHP 相关信息
你可以新建一个 PHP 页面进行测试,使用 vim 编辑器新建:

[root@localhost ~]# vi /var/www/html/test.php

按 “i” 键进行编辑,输入:

<?php   echo "test";    ?>

在按:wq退出
最后在浏览器上输入

你的ip/test.php

如果看到测试页面就成功了

在CenterOS 6.5上安装Apache mysql php

标签:

人气教程排行