wordpress更新时弹出ftp登录

原因

因为更新本身就是对本地文件的更新覆盖,而wordpress的更新程序无法完成本地文件更新所以就会出现ftp的方式提示,所以就是文件的更新权限问题。

权限检查

因为是wordpress的php部分的逻辑负责更新,所以就是查看这部分php的运行用户权限。如果我们的php是运行在fpm模式,这个我们可以用:

ps aux |grep  php-fpm

这条指令来查看,输出第一列就是当前归属的用户组信息。然后我们对当前的wordpress根目录或者主题插件的目录进行用户权限修改:

 chown -R xxx:xxx /DDD

xxx为用户和组,DDD为需要更新权限的目录,-R表示递归所有子目录。

mysql错误日志

mysql的默认错误日志为:hostname.err
完整路径:/usr/local/mysql/var/xxxxxx.err

如果我们要重新设置日志的路径,在[mysqld] 中輸入

#log  
log-error=/usr/local/mysql/log/error.log  
log=/usr/local/mysql/log/mysql.log  
long_query_time=2  
log-slow-queries= /usr/local/mysql/log/slowquery.log 

需要注意的是这里文件和路径需要mysql用户可访问,所以需要通过chown将log设置为mysql用户:

chown -R mysql:mysql log

apt-get update -qqy命令参数说明

第一次看到-qq参数,觉得比较新奇,特意确认了下:

-q, --quiet

Quiet. Produces output suitable for logging, omitting progress indicators. More q's will produce more quiet up to a maximum of two. You can also use -q=# to set the quiet level, overriding the configuration file. Note that quiet level 2 implies -y, you should never use -qq without a no-action modifier such as -d, --print-uris or -s as APT may decided to do something you did not expect.

所以按照说明,-qq一般是搭配y选项的。
这个参数经常在docker的静默安装指令中使用。

参考:
https://linux.die.net/man/8/apt-get

nrf52832 memory layout

协议栈

版本:nRF5_SDK_15.3.0_59ac345

#define SD_FLASH_SIZE 0x26000

app:
0x26000-0x77000

bootloader
0x77000-0x7e000

MBR params
0x7e000-7f000

bootloader setting:
7f000-80000

ref:
https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sr3nrf52.firmware/memory_configuration.html

Dockerfile中RUN CMD ENTRYPOINT命令区别

简单总结如下:
1. run用于docker的构建,可以理解为构建docker本身的单次的程序安装,只是为了生成docker image的,在docker build阶段执行。
2. entrypoint 理解为docker run时的shell指令,一般实现需要每次开机动态更新的设置或者文件操作等
3. cmd只能支持一条,代表entrypoint额外的默认运行参数,当在外层通过 docker run传递参数时,cmd的参数可以被覆盖。

参考:
1. https://www.cnblogs.com/klvchen/p/9238410.html
2. https://www.jianshu.com/p/f0a0f6a43907

基于ubuntu的LAMP dockerfile示例

简单的dockerfile例子

这里先给一个简单的例子,用来说明基本的dockerfile的组成:

# Barebones Apache installation on Ubuntu

FROM ubuntu

MAINTAINER DockerFan version 1.0

ENV DEBIAN_FRONTEND noninteractive

ENV APACHE_RUN_USER www-data
ENV APACHE_RUN_GROUP www-data
ENV APACHE_LOG_DIR /var/log/apache2
ENV APACHE_LOCK_DIR /var/lock/apache2
ENV APACHE_PID_FILE /var/run/apache2.pid

RUN apt-get update && apt-get install -y apache2

EXPOSE 8080

CMD ["/usr/sbin/apache2ctl", "-D", "FOREGROUND"]

解释

Here’s what the instructions do:

  • FROM is always your first instruction, because it names the base image you’re building your new image from.

  • MAINTAINER is the creator of the Dockerfile.

  • ENV sets environment variables, in the form ENV [key] [value]. This assigns a single value to the key, as in our example Dockerfile. The value can be any string, including spaces and punctuation, so you can configure values like IP addresses, URLs, and passphrases. Note that when you set DEBIAN_FRONTEND noninteractive (for an unattended installation) in your Dockerfile there is no equals sign, as there is when you script a standard Debian or Ubuntu installation with export DEBIAN_FRONTEND=noninteractive.

  • There are multiple instructions for setting environment variables: ADD, COPY, ENV, EXPOSE, LABEL, USER, WORKDIR, VOLUME, STOPSIGNAL, and ONBUILD.

  • RUN executes commands. The example above, RUN apt-get update && apt-get install -y apache2, demonstrates two important steps. It is a good practice to use apt-get update && apt-get install foo together to ensure that an updated packaged will be installed. Docker makes generous use of caching, so this prevents a cached packaged from being installed. If you’re sure your cached packages are fresh enough then it’s not necessary, and will save you some download time. apt-get install -y must be used together with ENV DEBIAN_FRONTEND noninteractive; it means answer Yes to all prompts and run non-interactively.

  • EXPOSE defines which ports you want open at runtime, in a space-delimited list.

  • CMD can be used only once in your Dockerfile. If you have more than one, only the last one will run. The preferred syntax is CMD [“executable”,”param1″,”param2″]. The parameters are optional and comma-separated if you have more than one.

完整的LAMP dockerfile

# Ubuntu LAMP stack with Apache, MariaDB, PHP, and SSL

FROM ubuntu

MAINTAINER DockerFan version 1.0

ENV DEBIAN_FRONTEND noninteractive

ENV APACHE_RUN_USER www-data
ENV APACHE_RUN_GROUP www-data
ENV APACHE_LOG_DIR /var/log/apache2
ENV APACHE_LOCK_DIR /var/lock/apache2
ENV APACHE_PID_FILE /var/run/apache2.pid

# Install Apache, SSL, PHP, and some PHP modules

RUN apt-get update && apt-get install -y apache2 
 openssl 
 php5 
 php5-cli 
 php5-apcu

# Install MariaDB and set default root password

RUN echo 'mariadb-server mariadb-server/root_password  password mypassword' | debconf-set-selections
RUN echo 'mariadb-server mariadb-server/root_password_again password mypassword' | debconf-set-selections
RUN apt-get install mariadb-server -y

# Disable the default Apache site config
# Install your site's Apache configuration and activate SSL

ADD my_apache.conf /etc/apache2/sites-available/
RUN a2dissite 000-default
RUN a2ensite my_apache
RUN a2enmod ssl

# Remove APT files
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

EXPOSE 443 8080

CMD ["/usr/sbin/apache2ctl", "-D", "FOREGROUND"]

The section that installs Apache, SSL, and PHP shows the proper Docker way to install multiple packages at once, with each package on its own line ending in a backslash. The MariaDB installation sections shows how to use debconf to automatically set the root DB password.

You will need your own Apache virtual host configuration file, and it should be in the same directory as your Dockerfile. Use the ADD instruction to build it into your image. I like to do a little housecleaning to keep my image as small as possible by running apt-get clean, and removing temp files.

Since we are using SSL, we’ll need port 443 available. On a production system, you would probably want only port 443 enabled, and use mod_rewrite to automatically redirect HTTP requests to HTTPS.

DEBIAN_FRONTEND选项

ENV DEBIAN_FRONTEND noninteractive
在基于ubuntu的dockerfile中我们经常看到如上的配置,那么,DEBIAN_FRONTEND到底是什么东西呢?

因为ubuntu是基于apt工具包进行软件安装的,而apt工具包是基于DebianPackageManagement的。而DEBIAN_FRONTEND就是DebianPackageManagement的基本选项。

dpkg-reconfigure 可以让我们简单的配置/重新配置包选项,而不需要重新安装。在配置的过程中我们就要面临frontend的选择。

正常情况下我们会选择交互式的配置过程,但是在很多脚本过程中,我们也需要自动化整个过程,而frontend就是用来指定我们的包配置模式的。DEBIAN_FRONTEND=noninteractive 实际上就是通过环境变量模式来指定的方式。

DEBIAN_FRONTEND支持的配置方式如下:

noninteractive
Do not ask any questions and assume the defaults.

dialog
Presents the user with the familiar text gray window on blue background. This is the default.

text
This removes the dialog interface and asks the configuration questions in a pure text-based format. This is well suited for slow connections or terminal emulators that don’t cooperate well with the dialog-based input and windowing system.

gtk
Prompts the user graphically using the GTK libraries. This may not work correctly on KDE. Also requires the package cdebconf-gtk and gkdebconf to be installed before use.

所以在dockerfile的自动化配置脚本中,我们一般选择noninteractive

蓝牙uart透传技术摘要

蓝牙uart透传技术摘要

基于 nRF5_SDK_15.3.0_59ac345

app->mcu->uart

  1. BLE_NUS_DEF(m_nus, NRF_SDH_BLE_TOTAL_LINK_COUNT); 执行时将ble_nus_on_ble_evt,进行了注册了绑定。
  2. nrf_sdh_ble_evts_poll 执行时,通过回调,调用ble_nus_on_ble_evt。
  3. 当有蓝牙数据发送时,会触发BLE_GATTS_EVT_WRITE,调用on_write
  4. 在on_write中会调用我们在业务中注册的nus service 回调nus_data_handler,这个回调作为参数在ble_nus_init中注册。
  5. 在nus_data_handler中我们就可以将数据通过串口发送函数app_uart_put发出了

uart->mcu->app

  1. uart_event_handle回调函数到nus发送函数ble_nus_data_send
  2. sd_ble_gatts_hvx协议栈函数会将内容通过蓝牙发送给app