一、前提条件
由于WendaSNS不支持PHP8,因此这里再安装php 7.4版本
1. 增加ondrej/php PPA,提供了多个PHP 版本(会因为网络原因,下载较慢)
sudo add-apt-repository ppa:ondrej/php2.更新包列表
sudo apt update3.安装 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-fpm4. 安装 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-fpm8.在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 update2.通过apt命令安装Nginx:
sudo apt install -y nginx3.查看Nginx版本:
nginx -v效果如下:
4.启用并启动Nginx 服务:
sudo systemctl enable nginx
sudo systemctl start nginx5.检查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 wendasnsb.添加权限
sudo chmod 777 -R wendasnsc.查看内容
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.创建名为
 2.创建名为 WendaSNS 的数据库
CREATE DATABASE WendaSNS CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;效果如下: 
3.查看数据库:
SHOW DATABASES;
效果如下:
 
3.在网页上进行配置,创建数据库:

成功如图: 
 




















