LAMP 环境是指 Linux 系统下,由 Apache + MariaDB + PHP 及其它相关辅助组件组成的网站服务器架构。本文本文档介绍如何在腾讯云云服务器(CVM)上手动搭建 LAMP 环境。
进行手动搭建 LAMP 环境,您需要熟悉 Linux 命令,例如 CentOS 环境下通过 YUM 安装软件 等常用命令,并对所安装软件使用的版本特性比较了解。
本文档搭建 LAMP 环境组成及使用版本说明如下:
已购买 Linux 云服务器。如果您还未购买云服务器,请参考 快速配置 Linux 云服务器。
使用标准方式登录 Linux 实例(推荐)。您也可以根据实际操作习惯,选择其他不同的登录方式:
yum install httpd -y
systemctl start httpd
systemctl enable httpd
http://云服务器实例的公网 IP
显示如下,则说明 Apache 安装成功。rpm -qa | grep -i mariadb
yum -y remove 包名
/etc/yum.repos.d/
下创建 MariaDB.repo
文件。 vi /etc/yum.repos.d/MariaDB.repo
# MariaDB 10.4 CentOS repository list - created 2019-11-05 11:56 UTC
# http://downloads.mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.4/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
您可前往 MariaDB 官网 获取其他版本操作系统的安装信息。
yum -y install MariaDB-client MariaDB-server
systemctl start mariadb
systemctl enable mariadb
mysql
显示结果如下,则成功安装。\q
rpm -Uvh https://mirrors.cloud.tencent.com/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
yum -y install php70w php70w-opcache php70w-mbstring php70w-gd php70w-xml php70w-pear php70w-fpm php70w-mysql php70w-pdo
vi /etc/httpd/conf/httpd.conf
ServerName www.example.com:80
下另起一行,输入以下内容:ServerName localhost:80
<Directory>
中的 Require all denied
修改为 Require all granted
。<IfModule dir_module>
中内容替换为 DirectoryIndex index.php index.html
。AddType application/x-gzip .gz .tgz
下另起一行,输入以下内容:AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
systemctl restart httpd
echo "<?php phpinfo(); ?>" >> /var/www/html/index.php
http://云服务器实例的公网 IP/index.php
显示结果如下,则说明 LAMP 环境配置成功。在完成了 LAMP 环境搭建后,您可在此基础上进行 手动搭建 Drupal 网站 实践,了解并掌握更多关于云服务器的相关功能。
如果您在使用云服务器的过程中遇到问题,可参考以下文档并结合实际情况分析并解决问题:
本页内容是否解决了您的问题?