前提说明:本人服务器版本为Debian 11.3,如果不是Debian和Ubuntu,需要自行搜索docker安装教程,对后续步骤并不影响。需要具备vim基础操作能力。
贴一下本人的小站 — 阿冬の小窝 – 分享日常的小站
安装docker
-
命令行执行以下命令
# 更新系统源 sudo apt-get update # 安装依赖库 sudo apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common # 添加 Docker 的官方 GPG 密钥 curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg # 添加 Docker 的稳定版软件源 echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null # 再次更新系统源 sudo apt-get update # 安装docker sudo apt-get install docker-ce docker-ce-cli containerd.io # 测试docker安装是否成功 sudo docker run hello-world # 开机自启 sudo systemctl enable docker
配置镜像源加速
这里不直接推荐镜像源链接,授人以鱼不如授人以渔。推一个教学视频,通过Github+Cloudflare 可三分钟自制镜像源
【【仅自用】三分钟!快速解决Dockerhub镜像站无法访问问题!】 https://www.bilibili.com/video/BV1H442197oQ/?share_source=copy_web&vd_source=9c46c4e3403bb19d927aac07cfb109dc安装WordPress
# 拉去WordPress镜像 docker pull wordpress # 运行WordPress镜像容器 docker run -it --name wordpress -p 8000:80 -v /usr/local/share/wordpress:/var/www/html -d wordpress # 修改WordPress默认配置文件 vim /usr/local/share/wordpress/wp-config-sample.php
-
将下面代码复制
wp-config-sample.php
中,且必须修改WP_HOME、WP_SITEURL、DB_HOST
define('WP_HOME', 'x.x.x.x'); define('WP_SITEURL', 'x.x.x.x'); define( 'DB_NAME', 'wordpress' ); /** MySQL database username */ define( 'DB_USER', 'root' ); /** MySQL database password */ define( 'DB_PASSWORD', '123456' ); /** MySQL hostname */ define( 'DB_HOST', 'x.x.x.x' ); /** Database charset to use in creating database tables. */ define( 'DB_CHARSET', 'utf8mb4' ); /** The database collate type. Don't change this if in doubt. */ define( 'DB_COLLATE', '' );
-
配置说明:
WP_HOME、WP_SITEURL
:均填写自己的IPDB_NAME
:创建的数据库名DB_USER
:数据库用户名DB_PASSWORD
:数据库密码DB_HOST
:服务器公网IP
安装MySQL
-
安装mysql并创建数据库
# 运行mysql镜像容器,可根据个人情况修改 docker run -d --name mysql -v /usr/local/share/mysql/data:/var/lib/mysql -v /usr/local/share/mysql/conf:/etc/mysql/conf.d -v /usr/local/share/mysql/logs:/var/log/mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=123456 mysql:8 # 进入mysql容器内 docker exec -it mysql /bin/bash # 登录数据库 (需要输入密码:123456) mysql -u root -p # 配置外部访问 GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION; FLUSH PRIVILEGES; # 创建WordPress数据库 create database wordpress;
-
修改配置文件减少内存占用(如果服务器内存较小可以配置一下)
vim /usr/local/share/mysql/conf/mysql.cnf
[mysqld] bind-address = 0.0.0.0 performance_schema_max_table_instances=400 table_definition_cache=400 performance_schema=off table_open_cache=64 innodb_buffer_pool_chunk_size=64M innodb_buffer_pool_size=64M
打开防火墙端口
firewall-cmd --zone=public --add-port=8000/tcp --permanent
firewall-cmd --zone=public --add-port=3306/tcp --permanent
systemctl restart firewalld
并且在云服务提供方防火墙开启对应端口(比如阿里云)
打开WordPress
在浏览器访问 http://ip:8000/wp-admin/setup-config.php 进行初始化
安装Argon
https://github.com/solstice23/argon-theme/releases
下载主题的 zip 压缩包,之后上传即可
贴一下个人配置
- Argon配置json
{"argon_theme_color":"#5e72e4","argon_theme_color_hex_preview":"#5e72e4","argon_show_customize_theme_color_picker":true,"argon_enable_immersion_color":"true","argon_darkmode_autoswitch":"time","argon_enable_amoled_dark":"false","argon_card_radius":"25","argon_card_shadow":"default","argon_page_layout":"double","argon_article_list_waterflow":"1","argon_article_list_layout":"1","argon_font":"serif","argon_assets_path":"default","argon_custom_assets_path":"","argon_wp_path":"/","argon_dateformat":"YMD","argon_enable_headroom":"true","argon_toolbar_title":"--hidden--","argon_toolbar_icon":"https://picture-o.oss-cn-beijing.aliyuncs.com/%E9%9B%AA%E8%8A%B1.png","argon_toolbar_icon_link":" ","argon_toolbar_blur":"true","argon_banner_title":"Adong","argon_banner_subtitle":"时也、运也、命也!","argon_banner_size":"fullscreen","argon_page_background_banner_style":"transparent","argon_show_toolbar_mask":true,"argon_banner_background_url":"https://picture-o.oss-cn-beijing.aliyuncs.com/20240203154606.png","argon_banner_background_color_type":"shape-primary","argon_banner_background_hide_shapes":true,"argon_enable_banner_title_typing_effect":"true","argon_banner_typing_effect_interval":"100","argon_page_background_url":"https://picture-o.oss-cn-beijing.aliyuncs.com/20240203154606.png","argon_page_background_dark_url":"https://picture-o.oss-cn-beijing.aliyuncs.com/20240203154606.png","argon_page_background_opacity":"1","argon_sidebar_banner_title":"共勉","argon_sidebar_banner_subtitle":"功不唐捐,玉汝于成","argon_sidebar_auther_name":"阿冬","argon_sidebar_auther_image":"https://picture-o.oss-cn-beijing.aliyuncs.com/20240401153312.png","argon_sidebar_author_description":"慢慢学习的小菜狗","argon_sidebar_announcement":"每日搬砖... 缓慢更新...","argon_fab_show_settings_button":"false","argon_fab_show_darkmode_button":"true","argon_fab_show_gotocomment_button":"true","argon_seo_description":"阿冬的小窝","argon_seo_keywords":"阿冬,小窝","argon_article_meta":"time|categories|views|comments","argon_show_readingtime":"true","argon_reading_speed":"580","argon_reading_speed_en":"80","argon_reading_speed_code":"10","argon_show_thumbnail_in_banner_in_content_page":"false","argon_first_image_as_thumbnail_by_default":"false","argon_reference_list_title":"参考","argon_show_sharebtn":"true","argon_show_headindex_number":"false","argon_donate_qrcode_url":"","argon_additional_content_after_post":"","argon_related_post":"category,tag","argon_related_post_sort_orderby":"meta_value_num","argon_related_post_sort_order":"ASC","argon_related_post_limit":"3","argon_article_header_style":"article-header-style-1","argon_outdated_info_time_type":"createdtime","argon_outdated_info_days":"1","argon_outdated_info_tip_type":"inpost","argon_outdated_info_tip_content":"本文最后更新于%modify_date_delta% 天前,其中的信息可能已经过时,如有错误请发送邮件到[email protected]","argon_archives_timeline_show_month":"true","argon_archives_timeline_url":"https://adong.org.cn/?page_id=76","argon_footer_html":"<style>n/* 核心样式 */n.github-badge {ndisplay: inline-block;nborder-radius: 4px;ntext-shadow: none;nfont-size: 13.1px;ncolor: #fff;nline-height: 15px;nmargin-bottom: 5px;nfont-family: "Open Sans", sans-serif;n}n.github-badge .badge-subject {ndisplay: inline-block;nbackground-color: #4d4d4d;npadding: 4px 4px 4px 6px;nborder-top-left-radius: 4px;nborder-bottom-left-radius: 4px;nfont-family: "Open Sans", sans-serif;n}n.github-badge .badge-value {ndisplay: inline-block;npadding: 4px 6px 4px 4px;nborder-top-right-radius: 4px;nborder-bottom-right-radius: 4px;nfont-family: "Open Sans", sans-serif;n}n.github-badge-big {ndisplay: inline-block;nborder-radius: 6px;ntext-shadow: none;nfont-size: 14.1px;ncolor: #fff;nline-height: 18px;nmargin-bottom: 7px;n}n.github-badge-big .badge-subject {ndisplay: inline-block;nbackground-color: #4d4d4d;npadding: 4px 4px 4px 6px;nborder-top-left-radius: 4px;nborder-bottom-left-radius: 4px;n}n.github-badge-big .badge-value {ndisplay: inline-block;npadding: 4px 6px 4px 4px;nborder-top-right-radius: 4px;nborder-bottom-right-radius: 4px;n}n.bg-orange {nbackground-color: #ec8a64 !important;n}n.bg-red {nbackground-color: #cb7574 !important;n}n.bg-apricots {nbackground-color: #f7c280 !important;n}n.bg-casein {nbackground-color: #dfe291 !important;n}n.bg-shallots {nbackground-color: #97c3c6 !important;n}n.bg-ogling {nbackground-color: #95c7e0 !important;n}n.bg-haze {nbackground-color: #9aaec7 !important;n}n.bg-mountain-terrier {nbackground-color: #99a5cd !important;n}n</style>n <div class="github-badge-big">n <span class="badge-subject"><i class="fa fa-id-card"></i> 备案号 </span>n <span class="badge-value bg-orange">n <!-- 备案链接 -->n <a href="https://beian.miit.gov.cn/" target="_blank" one-link-mark="yes">皖ICP备2023004451号-2</a>n </span>n </div>nn <div class="github-badge-big">n <span class="badge-subject"><i class="fa fa-copyright" aria-hidden="true"></i>Copyright </span>n <span class="badge-value bg-red">2023-2024</i>n <a href="http://adong.org.cn/" target="_blank" one-link-mark="yes">@ 阿冬の小窝n </span>n </script>n </div>nnt<!-- 运行时间 -->n <div class="github-badge-big">n <span class="badge-subject"><i class="fa fa-clock-o"></i> Running Time</span><spann class="badge-value bg-apricots"><span id="blog_running_days" class="odometer odometer-auto-theme"></span>n daysn <span id="blog_running_hours" class="odometer odometer-auto-theme"></span> Hn <span id="blog_running_mins" class="odometer odometer-auto-theme"></span> Mn <span id="blog_running_secs" class="odometer odometer-auto-theme"></span>Sn </span>n <script no-pjax="">nvar blog_running_days = document.getElementById("blog_running_days");nvar blog_running_hours = document.getElementById("blog_running_hours");nvar blog_running_mins = document.getElementById("blog_running_mins");nvar blog_running_secs = document.getElementById("blog_running_secs");nfunction refresh_blog_running_time() {nvar time = new Date() - new Date(2024, 9, 23, 0, 0, 0); /*此处日期的月份改为自己真正月份的前一个月*/nvar d = parseInt(time / 24 / 60 / 60 / 1000);nvar h = parseInt((time % (24 * 60 * 60 * 1000)) / 60 / 60 / 1000);nvar m = parseInt((time % (60 * 60 * 1000)) / 60 / 1000);nvar s = parseInt((time % (60 * 1000)) / 1000);nblog_running_days.innerHTML = d;nblog_running_hours.innerHTML = h;nblog_running_mins.innerHTML = m;nblog_running_secs.innerHTML = s;n}nrefresh_blog_running_time();nif (typeof bottomTimeIntervalHasSet == "undefined") {nvar bottomTimeIntervalHasSet = true;nsetInterval(function () {nrefresh_blog_running_time();n}, 500);n}n</script>","argon_enable_code_highlight":"true","argon_code_theme":"vs2015","argon_code_highlight_hide_linenumber":"false","argon_code_highlight_break_line":"true","argon_code_highlight_transparent_linenumber":"false","argon_math_render":"katex","argon_mathjax_cdn_url":"//cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml-full.js","argon_mathjax_v2_cdn_url":"//cdn.jsdelivr.net/npm/[email protected]/MathJax.js?config=TeX-AMS_HTML","argon_katex_cdn_url":"//cdn.jsdelivr.net/npm/[email protected]/dist/","argon_enable_lazyload":"true","argon_lazyload_threshold":"800","argon_lazyload_effect":"fadeIn","argon_lazyload_loading_style":"1","argon_enable_fancybox":"true","argon_enable_zoomify":"false","argon_zoomify_duration":"200","argon_zoomify_easing":"cubic-bezier(0.4,0,0,1)","argon_zoomify_scale":"0.9","argon_enable_pangu":"article","argon_custom_html_head":"","argon_custom_html_foot":"","argon_enable_smoothscroll_type":"1_pulse","argon_enable_into_article_animation":"true","argon_disable_pjax_animation":"false","argon_comment_pagination_type":"page","argon_comment_emotion_keyboard":"true","argon_hide_name_email_site_input":"false","argon_comment_need_captcha":"false","argon_get_captcha_by_ajax":"false","argon_comment_allow_markdown":"true","argon_comment_allow_editing":"true","argon_comment_allow_privatemode":"true","argon_comment_allow_mailnotice":"true","argon_comment_mailnotice_checkbox_checked":true,"argon_comment_enable_qq_avatar":"true","argon_comment_avatar_vcenter":"false","argon_who_can_visit_comment_edit_history":"commentsender","argon_enable_comment_pinning":"true","argon_enable_comment_upvote":"true","argon_comment_ua":"platform,browser","argon_show_comment_parent_info":"true","argon_fold_long_comments":"true","argon_gravatar_cdn":"gravatar.pho.ink/avatar/","argon_text_gravatar":"true","argon_enable_search_filters":"true","argon_search_filters_type":"*post,*page,*shuoshuo","argon_pjax_disabled":"false","argon_hide_categories":"","argon_enable_login_css":"true","argon_home_show_shuoshuo":"true","argon_fold_long_shuoshuo":"true","argon_enable_timezone_fix":"true","argon_hide_shortcode_in_preview":"true","argon_trim_words_count":"75","argon_enable_mobile_scale":"false","argon_disable_googlefont":"false","argon_disable_codeblock_style":"false","argon_update_source":"github","argon_hide_footer_author":"true"}
- 使用的额外CSS
/* 头像自动缩放、高亮 / 暗 */ #leftbar_overview_author_image { width: 100px; height: 100px; margin: auto; background-position: center; background-repeat: no-repeat; background-size: cover; background-color: rgba(127, 127, 127, 0.1); overflow: hidden; box-shadow: 0 0 5px rgba(116, 8, 204, 0.3); transition: transform 0.3s ease; /*变化速度*/ } #leftbar_overview_author_image:hover { transform: scale(1.2); /*缩放大小*/ filter: brightness(110%); /*调节亮度*/ } /* 作者名称 */ #leftbar_overview_author_name { margin-top: 15px; font-size: 18px;align-content; color:#FFA500; } /* 作者名称自动缩放 */ #leftbar_overview_author_name { background-position: center; background-repeat: no-repeat; background-size: cover; overflow: hidden; transition: transform 0.3s ease; /*变化速度*/ } #leftbar_overview_author_name:hover { transform: scale(1.2); /*缩放大小*/ filter: brightness(110%); /*调节亮度*/ } /* 简介 */ #leftbar_overview_author_description { font-size: 14px; margin-top: -4px; opacity: 0.8; color:#7E79E2; } /*更改默认字体大小*/ /*文章标题*/ .post-title { font-size: 30px } /*正文内容(不包含代码)*/ .post-content p{ font-size: 1.2rem; } li{ font-size: 1.2rem; } /*尾注*/ .additional-content-after-post{ font-size: 1.2rem } /*日间模式背景透明*/ .card{ background-color:rgba(255, 255, 255, 0.8) !important; -webkit-backdrop-filter:blur(6px); } /*夜间模式背景透明*/ html.darkmode.bg-white,html.darkmode .card,html.darkmode #footer{ background:rgba(66, 66, 66, 0.9) !important; } html.darkmode #fabtn_blog_settings_popup{ background:rgba(66, 66, 66, 0.95) !important; } /*小工具栏背景透明*/ .card .widget,.darkmode .card .widget,#post_content > div > div > div.argon-timeline-card.card.bg-gradient-secondary.archive-timeline-title{ background-color:#ffffff00 !important; backdrop-filter:none; -webkit-backdrop-filter:none; } .emotion-keyboard,#fabtn_blog_settings_popup{ background-color:rgba(255, 255, 255, 0.95) !important; }
-
页脚
<style> /* 核心样式 */ .github-badge { display: inline-block; border-radius: 4px; text-shadow: none; font-size: 13.1px; color: #fff; line-height: 15px; margin-bottom: 5px; font-family: "Open Sans", sans-serif; } .github-badge .badge-subject { display: inline-block; background-color: #4d4d4d; padding: 4px 4px 4px 6px; border-top-left-radius: 4px; border-bottom-left-radius: 4px; font-family: "Open Sans", sans-serif; } .github-badge .badge-value { display: inline-block; padding: 4px 6px 4px 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; font-family: "Open Sans", sans-serif; } .github-badge-big { display: inline-block; border-radius: 6px; text-shadow: none; font-size: 14.1px; color: #fff; line-height: 18px; margin-bottom: 7px; } .github-badge-big .badge-subject { display: inline-block; background-color: #4d4d4d; padding: 4px 4px 4px 6px; border-top-left-radius: 4px; border-bottom-left-radius: 4px; } .github-badge-big .badge-value { display: inline-block; padding: 4px 6px 4px 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; } .bg-orange { background-color: #ec8a64 !important; } .bg-red { background-color: #cb7574 !important; } .bg-apricots { background-color: #f7c280 !important; } .bg-casein { background-color: #dfe291 !important; } .bg-shallots { background-color: #97c3c6 !important; } .bg-ogling { background-color: #95c7e0 !important; } .bg-haze { background-color: #9aaec7 !important; } .bg-mountain-terrier { background-color: #99a5cd !important; } </style> <div class="github-badge-big"> <span class="badge-subject"><i class="fa fa-id-card"></i> 备案号 </span> <span class="badge-value bg-orange"> <!-- 备案链接 --> <a href="https://beian.miit.gov.cn/" target="_blank" one-link-mark="yes">皖ICP备2023004451号-2</a> </span> </div> <div class="github-badge-big"> <span class="badge-subject"><i class="fa fa-copyright" aria-hidden="true"></i>Copyright </span> <span class="badge-value bg-red">2023-2024</i> <a href="http://adong.org.cn/" target="_blank" one-link-mark="yes">@ 阿冬の小窝 </span> </script> </div> <!-- 运行时间 --> <div class="github-badge-big"> <span class="badge-subject"><i class="fa fa-clock-o"></i> Running Time</span><span class="badge-value bg-apricots"><span id="blog_running_days" class="odometer odometer-auto-theme"></span> days <span id="blog_running_hours" class="odometer odometer-auto-theme"></span> H <span id="blog_running_mins" class="odometer odometer-auto-theme"></span> M <span id="blog_running_secs" class="odometer odometer-auto-theme"></span>S </span> <script no-pjax=""> var blog_running_days = document.getElementById("blog_running_days"); var blog_running_hours = document.getElementById("blog_running_hours"); var blog_running_mins = document.getElementById("blog_running_mins"); var blog_running_secs = document.getElementById("blog_running_secs"); function refresh_blog_running_time() { var time = new Date() - new Date(2024, 9, 23, 0, 0, 0); /*此处日期的月份改为自己真正月份的前一个月*/ var d = parseInt(time / 24 / 60 / 60 / 1000); var h = parseInt((time % (24 * 60 * 60 * 1000)) / 60 / 60 / 1000); var m = parseInt((time % (60 * 60 * 1000)) / 60 / 1000); var s = parseInt((time % (60 * 1000)) / 1000); blog_running_days.innerHTML = d; blog_running_hours.innerHTML = h; blog_running_mins.innerHTML = m; blog_running_secs.innerHTML = s; } refresh_blog_running_time(); if (typeof bottomTimeIntervalHasSet == "undefined") { var bottomTimeIntervalHasSet = true; setInterval(function () { refresh_blog_running_time(); }, 500); } </script>
通过nginx绑定域名且开启https安全访问
- 在cloudflare上代理域名
- 添加自己的域名代理
- 添加自己的域名代理
-
使用免费计划
-
填写DNS配置
名称填写域名,IPv4地址填写IP地址,保存即可 -
修改SSL模式为灵活
-
配置始终使用HTTPS
-
nginx配置
vim /etc/nginx/conf.d/deafult.conf
server_name、proxy_pass
处要修改为自己的域名和IPserver { listen 80; server_name adong.org.cn; # client_max_body_size 1024m; location / { proxy_pass http://x.x.x.x:8000; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_redirect off; } error_log /var/log/nginx/error.log; access_log /var/log/nginx/access.log; }
- WordPress配置
# 修改WordPress默认配置文件 vim /usr/local/share/wordpress/wp-config-sample.php
WP_HOME、WP_SITEURL
改成自己的域名define('WP_HOME', 'https://yourdomain.com'); define('WP_SITEURL', 'https://yourdomain.com'); $_SERVER['HTTPS'] = 'on'; define('FORCE_SSL_LOGIN', true); define('FORCE_SSL_ADMIN', true);