2018年11月27日 星期二

2018年11月16日 星期五

Mount Google Cloud Storage in Linux

How to mount cloud storage (bucket)

If not in GCP, Setting Up Authentication for Server to Server Production Applications

Refer to https://cloud.google.com/docs/authentication/production#auth-cloud-app-engine-python
1. Generate service account credentials (a json file)
2. Set GOOGLE_APPLICATION_CREDENTIALS environment variable
# export GOOGLE_APPLICATION_CREDENTIALS="[PATH]"

Install FUSE

1. Configure the gcsfuse using yum repo:

# vi /etc/yum.repos.d/gcsfuse.repo

[gcsfuse]
name=gcsfuse (packages.cloud.google.com)
baseurl=https://packages.cloud.google.com/yum/repos/gcsfuse-el7-x86_64
enabled=1
gpgcheck=0
repo_gpgcheck=0

2. Install gcsfuse:

# yum install gcsfuse

3. To mount a bucket using gcsfuse over an existing directory /path/to/mount, invoke it like this:

# gcsfuse my-bucket /path/to/mount
or
# gcsfuse --implicit-dirs my-bucket /path/to/mount


Umount ----
# fusermount -u /path/to/mount

2018年1月15日 星期一

如何以系統(SYSTEM)帳號MAP網路磁碟機

1. 先下載pstools
2. 執行pstools中的psexec如下:

psexec -i -s cmd.exe
.......
此時會開啟cmd的command window. 此時echo %USERNAME%則會出現主機名稱而不是登入者名稱

3. 在新視窗中以 net use X: \\xxxxx\share_name /User:user_name password
mappping network device

2016年9月13日 星期二

Apache says DocumentRoot doesn't exist when it does or permission denied

Here's a tutorial approach to the SELinux case:
Find out if SELinux is active:
 $ sestatus
 SELinux status:                 enabled
 SELinuxfs mount:                /selinux
 Current mode:                   enforcing
 Mode from config file:          enforcing
 Policy version:                 24
 Policy from config file:        targeted
If so, some comparative checking might help. For instance, a server has a default DocumentRoot at /var/www/html, but we want it somewhere else like /path/to/document/root.
If SELinux is not actively messing with the resource, ls -dZ on the directory will show something like:
$ ls -dZ /path/to/document/root
? /path/to/document/root/
On the other hand, if SELinux contexts are applied, ls -dZ looks more like:
$ ls -dZ /path/to/document/root
drwxrws--x+ cfgadm cfgadmin system_u:object_r:file_t:s0 /path/to/documentroot
If we compare to a working DocumentRoot, it would look something like:
$ ls -dZ /var/www/html
drwxr-xr-x. root root system_u:object_r:httpd_sys_content_t:s0 /var/www/html
The _r and _t relate to -r (--role and -t (--type) arguments to chcon. Here is a cut-down man page:
NAME
   chcon - change file security context

SYNOPSIS
   chcon [OPTION]... CONTEXT FILE...
   chcon [OPTION]... [-u USER] [-r ROLE] [-l RANGE] [-t TYPE] FILE...
   chcon [OPTION]... --reference=RFILE FILE...

DESCRIPTION
   Change the security context of each FILE to CONTEXT.  With --reference,
   change the security context of each FILE to that of RFILE.

   --reference=RFILE
          use RFILE's security context rather than  specifying a CONTEXT value

   -R, --recursive
          operate on files and directories recursively
At first guess, the following might seem to work, but might not.
$ sudo chcon -R -t httpd_sys_content_t /path/to/document/root
If the web server still cannot see the DocumentRoot, note that the context matters all the way back to root:
$ sudo chcon -R -t httpd_sys_content_t /path/to/document
$ sudo chcon -R -t httpd_sys_content_t /path/to
$ sudo chcon -R -t httpd_sys_content_t /path
At this point, the web server can see the directory.
Yes, I learned the hard way tonight.

2014年9月5日 星期五

Apache Server新增資料目錄程序

於apache http server 新增一個資料目錄步驟

1. 建立目錄如

# mkdir /home/backup

2. 設定目錄權限,必須是執行apache的帳號可以讀取

3. 若為SELinux系列OS,則需執行

# chcon -R --reference=/var/www /home/backupStore

4. 修改設定檔 httpd.conf