Change Nginx UID and GID

stop nginx
stop php-fpm

usermod -u 1500 nginx
groupmod -g 1500 nginx

find / -user 998 -exec chown -h 1500 {} \;
find / -group 996 -exec chgrp -h 1500 {} \;

usermod -g 1500 nginx

start nginx
start php-fpm

假如 nginx UID/GID 未取代完成會造成錯誤

CentOS 7 Install NFS Server and Windows 10 NFS Client to Connect

CentOS

1. yum install
yum install nfs-utils

2. systemctl start and enable
systemctl enable rpcbind
systemctl enable nfs-server
systemctl start rpcbind
systemctl start nfs-server

3. create folder and change mod
mkdir /myshare
chmod 777 /myshare

4. edit /etc/exports and reload exportfs
vi /etc/exports
/myshare 192.168.124.0/24(rw,sync,no_root_squash)
exportfs -r

5. close SELiux 
vi /etc/sysconfig/selinux
SELINUX=disabled

6. add firewall rule and reload
firewall-cmd --permanent --zone public --add-service mountd
firewall-cmd --permanent --zone public --add-service rpc-bind
firewall-cmd --permanent --zone public --add-service nfs
firewall-cmd --reload

Windows 10

1. 開啟 Windwos 功能

2. 安裝 Service of NFS 全部

3. 開啟 cmd 

4. 掛載 NFS
mount -o anon \\remote_ip_address\myshare z:

move file by date


find PATH_A -type f ! -newermt 2017-01-01 -exec mv {} PATH_B \;

SELinux 影響 MySQL 連結

MySQL local 連 remote 時, 
要關閉 SELinux 或設定才能連線

PHP upgrade always breaks session folder permissions

PHP 升級後都會自動改成 session owner 回原本設定,
網路建議是為 owner 另建子資料夾對應, 下次就不會被更動.

user = nginx

; Set session path to a directory owned by process user
php_value[session.save_handler] = files
php_value[session.save_path]    = /var/lib/php/nginx/session
php_value[soap.wsdl_cache_dir]  = /var/lib/php/nginx/wsdlcache



ref: https://serverfault.com/questions/582483/php-upgrade-always-breaks-session-folder-permissions

MariaDB Max connect

參考
https://pjstrnad.com/mariadb-raise-number-of-connections/


The issue is that you can’t have more max_connections than open_files_limit.
Indication is at the log
Changed limits: max_open_files: 1024 max_connections: 214 table_cache: 400
So you got to /etc/my.cnf and under [mysqld] add
open_files_limit=12000
max_connections=10000
But it’s not enough. Because of the systemd there are some limits in starting the mysql server – it’s already started with mysql user.
So you need to go to /etc/security/limits.conf and add
mysql soft nofile 4096
mysql hard nofile 10240
Then settings for systemd
mkdir -p /etc/systemd/system/mariadb.service.d
vi /etc/systemd/system/mariadb.service.d/limits.conf
And then enter this to to the file:
[Service]
LimitNOFILE=infinity
that worked to me. After restart of the mysql by
systemctl daemon-reload
systemctl restart mariadb
I got the connections fixed:
mysql
MariaDB [(none)]> select @@max_connections;
+-------------------+
| @@max_connections |
+-------------------+
| 10000             |
+-------------------+
MariaDB [(none)]> SHOW VARIABLES LIKE 'open%';
+------------------+-------+
| Variable_name    | Value |
+------------------+-------+
| open_files_limit | 65536 |
+------------------+-------+

That’s all.