在Ubuntu 22.04上部署WendaSNS

一、前提条件

由于WendaSNS不支持PHP8,因此这里再安装php 7.4版本

1. 增加ondrej/php PPA,提供了多个PHP 版本(会因为网络原因,下载较慢)

sudo add-apt-repository ppa:ondrej/php

2.更新包列表

sudo apt update

3.安装 PHP 7.4 及相关扩展

sudo apt-get install -y php7.4-cli php7.4-common php7.4-mysql php7.4-zip php7.4-gd php7.4-mbstring php7.4-curl php7.4-xml php7.4-bcmath php7.4-fpm

4. 安装 Apache 模块

sudo apt-get install libapache2-mod-php7.4

5.切换终端的php 版本

sudo update-alternatives --config php

安装php 7.4版本输入1 ,如图所示: 

6.查看切换后的php版本

php -v

如图所示: 

7.停止php8.1-fpm,启动php7.4-fpm,重新启动apache2

sudo systemctl stop php8.1-fpm
sudo systemctl start php7.4-fpm

8.在Apache中设置php模块为php7.4版本

a.将目录切换到 Apache 的启用模块目录

cd /etc/apache2/mods-enabled/

 b.禁用了 PHP 8.1 模块

sudo rm php8.1.*

c. 启用了 PHP 7.4 模块

sudo ln -s ../mods-available/php7.4.* .

d. 启用 Apache 的 rewrite 模块

sudo a2enmod rewrite

如图所示: 

e. 重启 Apache 服务

sudo systemctl restart apache2

二、安装Nginx

1.更新系统包

sudo apt update

2.通过apt命令安装Nginx:

sudo apt install -y nginx

3.查看Nginx版本:

nginx -v

效果如下: 

4.启用并启动Nginx 服务:

sudo systemctl enable nginx
sudo systemctl start nginx

5.检查Nginx 服务的状态:

sudo systemctl status nginx

效果如图: 

按 q 退出。 

6.验证Nginx:

浏览器输入http://云服务器实例的公网IP 

8.使用systemctl 管理Nginx 服务

  • ➢停止Nginx 服务
sudo systemctl stop nginx
  • ➢启动Nginx服务
sudo systemctl start nginx
  • ➢要重新启动Nginx的服务
sudo systemctl restart nginx
  • ➢进行一些配置更改后,重新加载Nginx 服务
sudo systemctl reload nginx
  • ➢Nginx 服务开机启动
sudo systemctl enable nginx
  • ➢如果要禁用Nginx 服务开机启动
sudo systemctl disable nginx 

三、安装Wendasns

1.下载Wendasns

2.上传Wendasns软件包

进入特定目录:

cd /var/www/html/

上传安装包: 

sudo rz -b

如果你发现在Ubuntu上无法使用sudo rz -b命令,请确保你已经正确安装了lrzsz软件包。你可以通过以下命令来安装它: 

sudo apt update
sudo apt install lrzsz

 再次运行,效果如下:

3.解压

a.解压至指定目录

sudo unzip Wendasns-v2.0.2.zip -d wendasns

b.添加权限

sudo chmod 777 -R wendasns

c.查看内容

cd wendasns
ls -l

效果如下: 

四、配置

1.修改Apache主目录至wendasns下的public目录并配置htaccess:

sudo vim /etc/apache2/sites-available/000-default.conf

 效果如下:

2.public下.htaccess内容:

<IfModule mod_rewrite.c>
    Options +FollowSymlinks -Multiviews
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
</IfModule>

3.重新启动Apache:

sudo systemctl restart apache2

五、验证,访问应用

1.进入应用

浏览器的地址栏输入http://云服务器实例的公网IP:

2.在数据库命令行中手动创建WendaSNS数据库:

1.登录到MySQL数据库服务器

mysql -u 用户名 -p

效果如图: 2.创建名为 WendaSNS 的数据库

CREATE DATABASE WendaSNS CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

效果如下: 

3.查看数据库:

SHOW DATABASES;

效果如下: 

 

3.在网页上进行配置,创建数据库:

成功如图: 

  • 10
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值