CentOs上安装Apache服务器,Mysql数据库,PHP环境常用的命令

由于公司服务器是CentOS的,所以需要在本地测试一个项目,然后就下载6个ISO在VirtualBox里安装成功。但还需要安装LAMP (Linux, apache, php, mysql)才能开始项目,因此就试着用Ubuntu的命令进行安装,但发现很多命令不尽相同,特发此文留个记录。

CentOS is an Enterprise-class Linux Distribution derived from sources freely provided to the public by a prominent North American Enterprise Linux vendor. CentOS conforms fully with the upstream vendors redistribution policy and aims to be 100% binary compatible. (CentOS mainly changes packages to remove upstream vendor branding and artwork.) CentOS is free.

以下是安装的具体步骤:

1 命令行安装Apache服务器:

yum install httpd

2 命令行安装PHP:

yum install php

3 命令行安装Mysql数据库:

yum install mysql-server mysql

4 启动/重启/停止/重载Apache服务器:

/sbin/service httpd start|restart|stop|reload

5 启动/重启/停止Mysql数据库服务器:

service mysqld start|restart|stop

6 打开/var/www/html目录,输入:

vim index.php

然后输入以下内容:

<?php

phpinfo();

?>

按ESC键,再输入:wq!保存退出VIM.

7 打开FF浏览器在地址栏输入http://localhost ,可以看到PHPINFO信息即表示LAMP已经安装成功了.

Leave a Reply