赞
踩
前提条件:请确保你以具有root 权限的用户身份登录,并且你没有在端口80 或443 上运行Apache 或任何其他服务。
sudo apt update
sudo apt install -y nginx
nginx -v
- sudo systemctl enable nginx
-
- sudo systemctl start nginx
检查Nginx 服务的状态:
sudo systemctl status nginx
sudo ufw allow 80
若防火墙处于关闭状态,则不需要操作
sudo apt-get install -y php8.1-cli php8.1-common php8.1-mysql php8.1-zip php8.1-gd php8.1-mbstring php8.1-curl php8.1-xml php8.1-bcmath php8.1-fpm
安装的是8.1的版本
php -v
- sudo systemctl start php8.1-fpm
- sudo systemctl enable php8.1-fpm
sudo vim /etc/nginx/sites-available/default
sudo systemctl restart nginx
sudo vim /var/www/html/phpinfo.php
<?php echo phpinfo(); ?>
访问结果如下图所示,表示LNMP 环境部署成功:
sudo apt install -y mysql-server
sudo mysql_secure_installation
sudo systemctl start mysq
sudo systemctl enable mysq
sudo mysql alter user 'root'@'localhost' identified with mysql_native_password by 'xxxxxxxxx'
flush privileges;
mysql -uroot -pxxxxxxxx
sudo vim /var/www/html/mysql.php
- <?php
- $servername = "localhost";
- $username = "root";
- $password = "123456789";//替换成root的密码
- // 创建连接
- $conn = mysqli_connect($servername, $username, $password);
- // 检测连接
- if (!$conn)
- {
- die("Connection failed: " . mysqli_connect_error());
- }
- echo "php连接MySQL数据库成功";
- ?>
浏览器的地址栏输入http://云服务器实例的公网IP /mysql.php进行访问
若结果显示为:“php连接Mysql数据库成功”
则mysql与php通信正常。
sudo apt update
sudo apt-get -y install apache2
apache2 -v
效果如下:(表示Apache已成功安装)
- sudo systemctl start apache2
- sudo systemctl enable apache2
运行效果:
sudo systemctl status apache2
效果如下:(表示Apache已启动)
浏览器输入http://云服务器实例的公网IP
最新:6.5.2 https://cn.wordpress.org/download/
- cd /var/www/html/
-
- sudo rz -b
- cd /var/www/html/
- sudo rz -be
sudo unzip wordpress-6.5.2-zh_CN.zip
#添加权限
sudo chmod 777 -R wordpress
#查看内容
- cd wordpress
- ls
sudo vim /etc/nginx/sites-available/default
在server{........}中修改:
重新启动Nginx:
sudo systemctl restart nginx
CREATE DATABASE wordpress CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
如果未将wordpress目录的权限设置为777,则会弹出下个这个界面,需要手动创建wp-config.php后点击运行安装程序:
sudo vim wp-config.php
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。