Skip to content

通过知识获得解放,通过技术获得自由

Menu
  • 专题目录
  • 液压相关
    • 液压技术
    • 液压相邻技术
    • 液压应用
  • 计算机相关
    • 计算机和软件
    • 网络和网站技术
  • 哲学
  • 关于本站
Menu

手动安装wordpress[0]

Posted on 2023年11月14日 by

本篇是《手动部署php——软件包安装》的后续。

在已经完成的nginx,mysql和php安装的情况,可以手动配置安装wordpress了,以验证以上环境搭建的情况。需要了解nginx和mysql以及php安装的请见以下说明:

  1. 手动部署nginx——软件包安装
  2. 手动部署mysql——软件包安装
  3. 手动部署php——软件包安装

安装wordpress需要配置的文件,可以参考一下设置。

  • 设定wordpress的文件位置
cd /opt
ll
wget https://cn.wordpress.org/latest-zh_CN.tar.gz
tar -zxvf latest-zh_CN.tar.gz
cd wordpress
cp wp-config-sample.php wp-config.php
nano wp-config.php

配置wordpress与mysql的连接:

  • 设定nginx和网站配置文件

打开nginx.conf

nano /etc/nginx/nginx.conf

查看

因此在/etc/nginx/conf.d/目录下新建wordpress.conf

nano /etc/nginx/conf.d/wordpress.conf

放置以下内容:

#
# The default server
#
server {
listen 80;
server_name test.fanlog.xyz;

#charset koi8-r;

#access_log logs/host.access.log main;

location / {
root /opt/wordpress;
index index.php index.html index.htm;
}

error_page 404 /404.html;
location = /404.html {
root /usr/share/nginx/html;
}

# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}

# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
root /opt/wordpress;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}

# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}

测试nginx设置:

nginx -t

重启nginx,使得配置生效

systemctl restart nginx
  • 打开网址进行安装wordpress

进入后台:

  • 赋予wordpress目录权限
cd /opt/wordpress
chown nginx:nginx * -R
usermod -a -G nginx username
  • 发布一篇新博客

  • 部署SSL,详细见此centos7 安装Let’s Encrypt证书

停止nginx

systemctl stop nginx

安装自动获取证书服务

cd ~
yum install certbot
certbot certonly --standalone -w /var/www/test.fanlog.xyz -d test.fanlog.xyz

效果如下:

重新配置nginx的配置文件wordpress.conf

效果如下:

  • 强制开启ssl转换

参考的最终wordpress.conf:wordpress2

  • wordpress伪静态

  • 后续工作
  1. 设置php插件
  2. 设置firewall+fail2ban,见centos7/8 安装denyhosts防止SSH破解
  3. 关闭默认ssh账号,见linux创建root权限用户并禁用root登录
  • 验证过的vps
  1. vutrl
  2. aws lightsail

参考资料:

  1. https://my.oschina.net/u/1861878/blog/3098693
  2. https://www.linuxprobe.com/install-wordpress-nginx.html
  3. https://juejin.im/post/6844904100589469703

欢迎回来

希望本站对你有所帮助!

如有疑问请联系info@fanlog.org
2023 年 11 月
一二三四五六日
 12345
6789101112
13141516171819
20212223242526
27282930 
« 6 月    

AI辅助 (17)

© 2025 | Powered by Superbs Personal Blog theme
We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept All”, you consent to the use of ALL the cookies. However, you may visit "Cookie Settings" to provide a controlled consent.
Cookie SettingsAccept All
Manage consent

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
Non-necessary
Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.
SAVE & ACCEPT