Centos 7 配置 LAMP

Wu Jun 2019-12-25 15:59:03
Categories: > Tags:

LAMP是Linux、Apache HTTP,MySQL(或MariaDB)和PHP(或Perl、Python)的首字母缩写,下面讨论如何在RHEL/CentOS/Scientific Linux 7上搭建LAMP环境。

一、Install Apache HTTP Server

在终端以root权限运行以下命令:

yum install httpd -y

启动Apache

systemctl start httpd

设置开机启动

systemctl enable httpd

firewall设置允许远程登录:

firewall-cmd --permanent --add-service=http

systemctl restart firewalld

测试Apache

浏览器访问 http://localhost/ or http://server-ip-address/

二、Install MariaDB

安装MariaDB

yum install mariadb-server mariadb -y

启动MariaDB

systemctl start mariadb

设置开机启动

systemctl enable mariadb

设置root密码

mysql_secure_installation

三、Install PHP

使用以下的命令安装php

yum install php php-mysql php-gd php-pear -y
//或安装所有php modules
yum install php* -y

测试PHP:

//在Apache文档根目录创建“testphp.php”
vi /var/www/html/testphp.php

//编辑内容如下
<?php
phpinfo();
?>

重启 httpd 服务:

systemctl restart httpd

浏览器访问 http://server-ip-address/testphp.php。