https://kinsta.com/knowledgebase/sorry-this-file-type-is-not-permitted-for-security-reasons/
如何实现头图带下拉菜单
目标的样子是这样的 :
注意到图像下方有菜单
来源网站是 : http://seanelvidge.com/ stack overflow expert for math
how to reset wordpress login pwd
- loging mysql
- find current user :
1 |
SELECT ID, user_login, user_pass FROM wp_users; |
- update user password
1 |
UPDATE wp_users SET user_pass=MD5('newstrongpassword') WHERE ID = usersID; |
How to backup and restore wordpress site
- 目标: 备份远程 bandwagong的 wordpress到本地 centos 机器, 包括articl , Pic , theme …
- First backup 远程 mysql database
1 |
mysqldump --user=root --password=XXXXXX --opt wordpress > wordpressBK.sql |
然后 ,restore 到 本地
1 |
mysql --user=root --password=Piercing77# wordpress < /home/liuyang/wordpressBK20190812.sql |
- Tools —-> export —-> all contents
and download the generated file
- 在本地 centos 7 , 先翻墙 , 再下载 wordpress最新版本, 翻墙是为了能下载
1 |
cd /tmp |
1 |
wget http://wordpress.org/latest.tar.gz |
- 解压到 /var/www/html/
1 |
sudo tar -xvzf latest.tar.gz -C /var/www/html |
- 在 mysql 建表
1 |
mysql -u root -p |
Piercing77#
1 |
CREATE USER wordpress@localhost IDENTIFIED BY "WordPressPWD77#"; |
1 2 3 4 5 6 7 8 9 10 11 |
## Create New Database ## create database wordpress; ## Grant Privileges to Database ## GRANT ALL ON wordpress.* TO wordpress@localhost; ## FLUSH privileges ## FLUSH PRIVILEGES; ## Exit ## exit |
注: 如果不是第一次见表, 可直接执行:
1 |
mysql --user=wordpress --password=WordPressPWD77# wordpress < /home/mysqlDB/wordpressBK20200927.sql |
- 修改
1/etc/httpd/conf/httpd.conf
在文件最后加上
1 2 3 4 5 6 7 |
<VirtualHost *:80> ServerAdmin webmaster@dummy-host.example.com DocumentRoot /var/www/html/wordpress ServerName wordpress ErrorLog /var/log/httpd/wordpress-error-log CustomLog /var/log/httpd/wordpress-acces-log common </VirtualHost> |
重启 apache
1 |
systemctl restart httpd.service |
- 修改 /etc/hosts
加上
1 2 |
127.0.0.1 wordpress 192.168.3.116 wordpress |
- 这时, 在本机应该就能访问了, 如果想让同一局域网的其他PC能通过
http://192.168.3.116 的形式访问
需要
1 |
sudo firewall-cmd --add-service=http |
learn from https://www.centos.org/forums/viewtopic.php?t=59161
- 但是, 这样图片,视频等仍然存储在远程
是因为在 wp_posts表中, URL 仍然是远程的 ,需要手动改过来
参见: https://wpbeaches.com/updating-wordpress-mysql-database-after-moving-to-a-new-url/
主要是把 http://www.notesoflyang.com 改为 http://192.168.3.116 (公司局域网 IP )
一共4句 sql
1 2 3 4 5 6 7 |
UPDATE wp_options SET option_value = replace(option_value, 'http://www.notesoflyang.com', 'http://192.168.3.116') WHERE option_name = 'home' OR option_name = 'siteurl'; UPDATE wp_posts SET guid = replace(guid, 'http://www.notesoflyang.com','http://192.168.3.116'); UPDATE wp_posts SET post_content = replace(post_content, 'http://www.notesoflyang.com', 'http://192.168.3.116'); UPDATE wp_postmeta SET meta_value = replace(meta_value,'http://www.notesoflyang.com','http://192.168.3.116'); |
此外, 因为远程wordpress最开始是没有域名的, 所以有一部分upload image 是以远程IP而不是域名做地址的,所有, 还需要再执行一遍这4句,但是把 域名改ip
1 2 3 4 5 6 7 |
UPDATE wp_options SET option_value = replace(option_value, 'http://176.122.178.37', 'http://192.168.3.116') WHERE option_name = 'home' OR option_name = 'siteurl'; UPDATE wp_posts SET guid = replace(guid, 'http://176.122.178.37','http://192.168.3.116'); UPDATE wp_posts SET post_content = replace(post_content, 'http://176.122.178.37', 'http://192.168.3.116'); UPDATE wp_postmeta SET meta_value = replace(meta_value,'http://176.122.178.37','http://192.168.3.116'); |
- 最后, 把 /var/www/html/wordpress/wp-content/uploads 文件夹的内容从远程copy到本地即可
- finish backup
- reference article :
how to backup wordpress without any plugin :
https://skillcrush.com/2015/04/23/backing-up-wordpress/
- 如果
1 |
systemctl start mysqld |
失败 ,解决方法是
sudo systemctl start mysqld 这种是用 systemctl 管理程序启动,
很多教程这样写: /etc/init.d/mysqld start
但是 在我的 /etc/init.d 并没有发现mysql
那就找 find / -name mysqld
发现在 /usr/sbin/mysqld
执行 /usr/sbin/mysqld start
- 如果登陆mysql 时出现 :
1 |
Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (13) |
注意最后的数字13
解决方法是 :
1 |
sudo chown -R mysql:root /var/lib/mysql |
可能是因为原来的mysql:mysql 没有这个目录的权限
方法来自 :
https://serverfault.com/questions/497194/mysql-bind-on-unix-socket-permission-denied
如何在wordpress上传并播放视频
-
-
- 视频来源 : yy直播间录像
- 第一次上传, 失败,播放时只有声音没图像
- Google后发现 :
12345Turns out the video was not properly encoded to be supported by HTML5 video tag.HTML5 video requires MP4 videos with H264 video codec and AAC audio codec.The problem video was not of codec H264. Running it through a converter fixed it.
此答案来自 : https://stackoverflow.com/questions/21586128/html5-video-of-type-video-mp4-playing-audio-only - 既然声音可以播,那就只能是vedio格式的问题, 用KMplayer 播放原视频, in “media information ” , 可以看到
-
视频格式是 h.263 。
-
-
-
-
- 尝试下载 Pavtube video converter 解决, 但是, 发现转换后的文件从20M变为100M+
- 最后,用格式工厂, 选择菜单 “To MP4” , 输出配置选 h.264 , 问题解决。
- 总结: a) 录像原始格式是h.263 是yy公司故意的,不想让人很容易的分享视频到网页
b) 柚又真漂亮
-
-
-
wordpress load sequences
wp-hierarchy picture show
Different between functions.php and plugin
A WordPress Plugin:
- Executes only when individually activated via the Plugins panel.
- Applies to all themes.
- Requires specific unique Header text.
- Is stored in wp-content/plugins, usually in a subdirectory.
A functions file:
- Executes only when in the currently activated theme’s directory.
- Applies only to that theme. If the Theme is changed, the functionality is unused.
- Requires no unique Header text.
- Is stored with each Theme in the Theme’s subdirectory in wp-content/themes.
how wordpress works behind
已安装的插件&做的修改
- install plugin —- Crayon Syntax Highlighter
- modify wp-config set debug mode = true
- modify functions.php try to add “view count of post” ,not finish