树莓派俱乐部 树莓派俱乐部
  • 首页
  • 树莓派
  • OpenWrt
  • Python
  • Linux
  • 注册
    登录
现在登录。
  • 首页
  • 树莓派
  • OpenWrt
  • Python
  • Linux
首页 Linux CentOS8安装LNMP/LAMP环境

CentOS8安装LNMP/LAMP环境

hatlujam 5 年 前

刷入系统

首先从下面链接下载镜像,这是CentOS的arm64的官方系统,只是对于树莓派做了引导和优化,使树莓派能使用。解压后刷入,要等那么一会用root用户登录,密码raspberrypi.club登录后记得改密码。

基于CentOS 8的适用于64位树莓派的服务器镜像

通过yum安装nginx

yum install -y nginx

启动

systemctl start nginx

设为开机启动

systemctl enable nginx

访问树莓派ip地址,能访问表示安装成功默认主页index.html位于nginx默认目录/usr/share/nginx/html中。若要发布自己的网站内容,替换index.html主页内容即可。

如果要安装LAMP的话,把安装nginx换成以下命令:

yum install httpd
systemctl start httpd
systemctl enable httpd

接下来安装MYSQL

yum install -y mariadb-server

同样的,启动,设置开机启动。

systemctl start mariadb
systemctl enable mariadb

接下来讲讲如何配置和创建数据库用户:

配置

设置root密码(讲这里的yourpassword换成你的想设置的)

mysqladmin -uroot password yourpassword

登录:

mysql -uroot -p

输入你刚才设置的密码

然后添加用户:

MariaDB[(none)]>grant all on . to ‘webuser’@‘%’ identified by ‘123456’;
MariaDB[(none)]>flush privileges;

这里的webuser和123456分别替换为你想创建的用户名和密码,在设置网页(如wordpress)时填入。

退出

MariaDB[(none)]> quit;

然后安装PHP

yum install php -y

它会自动安装http(apache),神奇的逻辑由于你需要需要nginx的话,卸载httpd。如果你一开始就安装LAMP的就没有这些问题。

yum remove httpd*

它又会把php-fpm给卸了。。
把php-fpm安装回来

yum install php-fpm -y

发现附带安装了httpd-filesystem,我们也就知道了它的依赖逻辑。

测试php是否正常运行(这里使用的是nginx的网页根目录路径,搭建LAMP的自行替换):

echo “<?php phpinfo(); ?>” > /usr/share/nginx/html/index.php

访问页面,能显示php的一些信息。

#arm64#Centos#CentOS8#LAMP#LNMP#网页搭建
8
等 8 人赞过
hatlujam
用自己的眼睛去读世间这一部书。
评论 (0)
返回
    发表评论
猜你喜欢
  • 树莓派4B安装Windows10桌面版
  • 在树莓派上使用RaspAP开启热点
  • 树莓派3B Windows 10桌面版安装GPU驱动
  • 树莓派3B安装Windows10桌面版
hatlujam
8
文章
2
评论
125
获赞
文章聚合
如何在 Raspberry Pi 上安装 Node.js 和 npm
5 年 前
如何在 Raspberry Pi 上启用SSH
5 年 前
树莓派64位启动过程概述
6 年 前
树莓派SD卡超频参数,增加SD卡的读写速度
6 年 前
如何构建树莓派64位系统(4)制作镜像
5 年 前
  • 首页
Copyright © 2018-2025 树莓派俱乐部. Designed by nicetheme.