Fat's 杂物屋

  • 首页
  • 关于我
Fat's 杂物屋
python语言工作自动化技术
  1. 首页
  2. 网站构建
  3. 正文

ubuntu构建LNMP环境和安装WordPress

2023年5月6日 2508点热度 0人点赞 0条评论

前两天为了在这个服务器同时跑python的神经网络,把整个系统重装了。

然后又把过去的坑再踩了一遍……

为免重蹈覆彻还是在这里记录一下手顺。

 

1)LNMP环境安装

用oneinstask准备LNMP环境。
https://oneinstack.com/auto/
自动脚本命令需要以root用户进行(sudo -i命令)

2)准备好MySQL数据库

登录MySQL Shell

mysql -u root -p

创建一个新的database

CREATE DATABASE wordpress;

创建一个用户和密码

CREATE USER wordpress_user@localhost;
SET PASSWORD FOR wordpress_user@localhost= PASSWORD("password");

完成通过授予新用户的所有权限。 没有这个命令,wordpress安装程序将无法启动:

GRANT ALL PRIVILEGES ON wordpress.* TO wordpress_user@localhost IDENTIFIED BY 'password';

最后刷新数据

FLUSH PRIVILEGES;

退出MySQL shell

exit

 

3)配置好wordpress

下载最近版本wordpress

wget http://wordpress.org/latest.tar.gz

解压缩

tar -xzvf latest.tar.gz

修改wordpress的配置文件
先从sample创建一个新的配置文件

cp ~/wordpress/wp-config-sample.php ~/wordpress/wp-config.php

用vim修改配置文件

vi ~/wordpress/wp-config.php

要修改下述数据库相关的字段

// ** Database settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define( 'DB_NAME', 'database_name_here' );

/** Database username */
define( 'DB_USER', 'username_here' );

/** Database password */
define( 'DB_PASSWORD', 'password_here' );

将wordpress文件夹放到相应目录

sudo mkdir -p /data/wwwroot/wordpress
sudo cp -r ~/wordpress/* /data/wwwroot/wordpress

修改wordpress文件夹的用户权限(在oneinstack的脚本中,www是运行nginx的用户)

sudo chown www:www /data/wwwroot/wordpress -R

4)配置nginx

还是使用oneinstack提供的脚本配置nginx
~/oneinstack/vhost.sh(先要sudo -i切换根用户)

留意这里要用wordpress的文件夹

留意rewrite要选wordpress

Please input the directory for the domain:blog.fat.plus :
(Default directory: /data/wwwroot/blog.fat.plus): /data/wwwroot/wordpress
Please input the rewrite of programme : wordpress,opencart,magento2,drupal,joomla,codeigniter,laravel thinkphp,pathinfo,discuz,typecho,ecshop,nextcloud,zblog,whmcs rewrite was exist. (Default rewrite: other): wordpress 

根据提示上传证书到/usr/local/nginx/conf/ssl/文件夹
如果遇到权限问题,可以先改文件夹权限属性为777

sudo chmod 777 /usr/local/nginx/conf/ssl

 

(可选)这里,我顺便把www.fat.plus强制跳转到blog.fat.plus
nginx配置中增加

server_name blog.fat.plus www.fat.plus;

if ($host = 'www.fat.plus' ) {
rewrite ^(.*) https://blog.fat.plus/$request_uri permanent;
}

上传完证书,reload一下nginx就完成配置啦

nginx -s reload

5)最后

进入网站地址(譬如这里的blog.fat.plus),按wordpress的提示完成配置就可以了。

本作品采用 知识共享署名 4.0 国际许可协议 进行许可
标签: 暂无
最后更新:2023年5月6日

fat

我只是一只海獭。

点赞
< 上一篇
下一篇 >

文章评论

razz evil exclaim smile redface biggrin eek confused idea lol mad twisted rolleyes wink cool arrow neutral cry mrgreen drooling persevering
取消回复

fat

我只是一只海獭。

分类
  • python / 5篇
  • 数码硬件 / 5篇
  • 杂谈 / 1篇
  • 网站构建 / 13篇
最新 热点 随机
最新 热点 随机
laravel 11.x 及 Vue3安装,作为SPA单网页应用框架 ubuntu中部署基于Gradio框架的AI demo(nginx反向代理) ubuntu构建LNMP环境和安装WordPress ubuntu使用flask错误:ImportError: libGL.so.1: cannot open shared object file: No such file or directory解决办法 uWSGI提示错误uwsgi: unrecognized option '--wsgi-file'解决办法 Laravel优化SQL分页查询语句
ubuntu中部署基于Gradio框架的AI demo(nginx反向代理) ubuntu构建LNMP环境和安装WordPress 基于Laravel和Vue的匿名论坛网站构建 —— 服务器环境配置 总之开了个blog Laravel中安装Bootstrap-vue时提示You are using the runtime-only build错误 ubuntu使用flask错误:ImportError: libGL.so.1: cannot open shared object file: No such file or directory解决办法

COPYRIGHT © 2023 Fat's 杂物屋. ALL RIGHTS RESERVED.

Theme Kratos Made By Seaton Jiang

粤ICP备2020113573号