新灌的一台Centos7可以做以下的設定
語系設定:
- sudo localectl set-locale LC_CTYPE=zh_TW.UTF-8
修改ssh port
- http://linux.vbird.org/linux_server/0310telnetssh.php#ssh_port
- sudo firewall-cmd --add-port 2222/tcp --permanent
- sudo systemctl restart sshd
修改mail server
- http://choons-world.blogspot.com/2017/11/
- 開機發信排程:
| # wait 2min to sure all service open
| (sleep 120
| echo -e "`who -b`\n`ifconfig`\n`systemctl list-units | grep running`\n\n\n\nSettings of mail: https://choons-world.blogspot.com/2017/11/centos-sendmail-by-gmail.html" | mail -s "Server on" xxxxx@gmail.com
| )&
XRDP設定:
- http://choons-world.blogspot.com/2017/07/centos7-xrdp.html
Lamp設定教程:
- http://choons-world.blogspot.com/2017/07/centos7-apachephp7mariadbphpmyadmin.html
- selinux可以設為perminant 這樣比較好設定
- 注意:如果用yum方式安裝 請先安裝php才安裝phpmyadmin
- Webserver路徑:/var/www/html/
- 注意權限問題 要讓apache可讀(如要修改及生成文件就要可寫)
Wordpress 移機(可忽略)
- 路徑: /var/www/html/wordpress
- 需要備份的話直接備份這個資料夾和資料庫,資料庫密碼詳見wp-config.php
- 移機簡略步驟:
| 1 複製及權限
| > sudo mv wordpress/ /var/www/html/
| > ll
| > cd /var/www/html/
| > lll
| > ll
| > chgrp -R apache wordpress
| > sudo chgrp -R apache wordpress
| 2 備份資料庫然後再匯入到新的一台 (帳號看 wp-config.php)
| 3 修改基礎設定(例如:網址等)
| 4 開帳號讓ftp使用 記得設為nologin
| > sudo useradd -d /var/www/html/ -s /sbin/nologin wordpress
| > sudo passwd wordpress
| 5 設置 ftp
| - http://linux.vbird.org/linux_server/0410vsftpd.php#server
| | > yum -y install vsftpd
| | > firewall-cmd --permanent --add-service=ftp
| | > vim /etc/vsftpd/vsftpd.conf
| | ====
| | anonymous_enable=NO
| | local_enable=YES
| | write_enable=YES
| | xferlog_std_format=YES
| | chroot_local_user=YES
| | use_localtime=YES
| | allow_writeable_chroot=YES
| | userlist_deny=YES
| | ==== #userlist_deny為YES 則user_list文件裡的user可以登入ftp; 假如為NO 則user_list文件裡user不可以登入ftp
| | > systemctl restart vsftpd
| | > systemctl enable vsftpd
| | > firewall-cmd --permanent --add-port=21/tcp
| | > firewall-cmd --permanent --add-service=ftp
| | > firewall-cmd —reload
| 6 更換owner
| > sudo chown -R wordpress wordpress
| 7 新增user wordpress登入ftp權限,給予wordpress權限給user
| > vim /etc/vsftpd/user_list
| | ==
| | wordpress
| | ==
crontab設定:
| $ cat /etc/crontab
| SHELL=/bin/bash
| PATH=/sbin:/bin:/usr/sbin:/usr/bin
| MAILTO=root
|
| # For details see man 4 crontabs
|
| # Example of job definition:
| # .---------------- minute (0 - 59)
| # | .------------- hour (0 - 23)
| # | | .---------- day of month (1 - 31)
| # | | | .------- month (1 - 12) OR jan,feb,mar,apr ...
| # | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
| # | | | | |
| # * * * * * user-name command to be executed
| 0 0 1,15 * * root /opt/gitlab/bin/gitlab-rake gitlab:backup:create CRON=1
| 0 0 1,15 * * root gitlab-ctl restart
| 0 3 * * * root sh -c "sync; echo 3 > /proc/sys/vm/drop_caches"
gitlab (可忽略)
- http://choons-world.blogspot.com/2017/08/install-gitlab-to-own-pc.html
- 記得備份後再更新
| > sudo yum install -y gitlab-ce
| - 更新時如果跨minor version 必須更新到該minor最後一版才能再升級到新的minor version
| - 例如:1.2.3 > 1.2.9 > 1.3.9 > 1.4.2
- 備份查看crontab每15天備份一次 還有重啟動1次
- 本地備份位置: /var/opt/gitlab/backups/
- 備份指令 /opt/gitlab/bin/gitlab-rake gitlab:backup:create CRON=1
- 因為現在的gitlab內容較大 如果備份頻率較高,建議把舊的版本刪掉(可能只保留3個檔案)
- 跨機還原需要安裝與原版本的gitlab,如果需要新版本,則還原後再更新,choonsword裡有簡易的指令,但建議觀看網絡教程
- 設定檔 /etc/gitlab/gitlab.rb
| 每次修改完需要下以下兩個指令
| > sudo gitlab-ctl reconfigure
| > sudo gitlab-ctl restart
==============================
Choon's World
2018年9月1日 星期六
2018年8月27日 星期一
SSH 修改port
1. vim /etc/ssh/sshd_config
====
Port 2222
====
2. systemctl restart sshd.service
4. firewall-cmd --permanent --zone=public --add-port=2222/tcp
5. firewall-cmd --reload
#https://www.globo.tech/learning-center/change-ssh-port-centos-7/
====
Port 2222
====
2. systemctl restart sshd.service
3. By default, SELinux only allows SSH on the port 22. We must change this to our new port. In our example, we are using 2222 but you should replace this number with the number of your port in the below command, which uses semanage port to configure ports in the SELinux policy:
semanage port -a -t ssh_port_t -p tcp 22224. firewall-cmd --permanent --zone=public --add-port=2222/tcp
5. firewall-cmd --reload
#https://www.globo.tech/learning-center/change-ssh-port-centos-7/
2018年8月23日 星期四
Drupal安裝
Drupal是一個強大的CMS/CMF。他提供給專業的工程師進行開發
安裝過程:
1. 官網下載最新版
https://www.drupal.org/download
2. 把檔案解壓縮的document root
3. 把group給予apache,並可以rewrite
3. 複製 /sites/default 地下的default檔案
4. 新增 /sites/default/files/translations folder
5. apache必須可以rewrite同時 AllowOverride 設 All 以讓htaccess可控制
6. 新增db user並給drupal
7. 報告》狀態報告 檢查 紅黃色提示
- trusted_host_patterns 白名單
| $settings['trusted_host_patterns'] = array(
| '^localhost$',
| '^127\.0\.0\.1$',
| '^www\.pcsetting\.com$',
|);
8. 模組下載頁面:https://www.drupal.org/project/project_module
擴展》安裝新模組,直接輸入要安裝的模組或直接把解壓縮檔放到modules裡,然後再到擴展裡按安裝 例子:滑鼠clickon就dropdown的套件 https://www.drupal.org/project/admin_toolbar
9. themes下載頁面:https://www.drupal.org/project/project_theme
方法同上
#參考教材:https://www.pcsetting.com/devtools/60?page=0%2C0
三大CMS比較:https://www.kingman.idv.tw/technology-news/142-how-to-choose-wordpress-joomla-and-drupal-to-build-a-website.html
台灣支援站:https://drupaltaiwan.org/
安裝過程:
1. 官網下載最新版
https://www.drupal.org/download
2. 把檔案解壓縮的document root
3. 把group給予apache,並可以rewrite
3. 複製 /sites/default 地下的default檔案
4. 新增 /sites/default/files/translations folder
5. apache必須可以rewrite同時 AllowOverride 設 All 以讓htaccess可控制
6. 新增db user並給drupal
7. 報告》狀態報告 檢查 紅黃色提示
- trusted_host_patterns 白名單
| $settings['trusted_host_patterns'] = array(
| '^localhost$',
| '^127\.0\.0\.1$',
| '^www\.pcsetting\.com$',
|);
8. 模組下載頁面:https://www.drupal.org/project/project_module
擴展》安裝新模組,直接輸入要安裝的模組或直接把解壓縮檔放到modules裡,然後再到擴展裡按安裝 例子:滑鼠clickon就dropdown的套件 https://www.drupal.org/project/admin_toolbar
9. themes下載頁面:https://www.drupal.org/project/project_theme
方法同上
#參考教材:https://www.pcsetting.com/devtools/60?page=0%2C0
三大CMS比較:https://www.kingman.idv.tw/technology-news/142-how-to-choose-wordpress-joomla-and-drupal-to-build-a-website.html
台灣支援站:https://drupaltaiwan.org/
2018年3月19日 星期一
Docker command
Docker 是在本機OS上執行虛擬化,與傳統的虛擬方法不太一樣。
以下是Docker的常用指令
docker images //show local docker images
docker search python //search docker images online
docker pull python // pull store images to local
docker run -t -i python /bin/bash //run docker images(name:python) by bash
-i : Keep STDIN open even if not attached ,無論有無 Attach ,都會確保 STDIN 有持續開啟
-t : Allocate a pseudo-tty 分配一個 tty
docker commit -m "Add pandas" -a "add pandas" f446ce29c915 python
-m : same like git
-a : 指定更新的使用者信息
(一堆數字) 建立映像檔的容器的 ID
(string) images and tag
docker save -o python3.tar python //save imaes to tar file
docker rmi centos/python-35-centos7 //delete local docker images
以下是Docker的常用指令
docker images //show local docker images
docker search python //search docker images online
docker pull python // pull store images to local
docker run -t -i python /bin/bash //run docker images(name:python) by bash
-i : Keep STDIN open even if not attached ,無論有無 Attach ,都會確保 STDIN 有持續開啟
-t : Allocate a pseudo-tty 分配一個 tty
docker commit -m "Add pandas" -a "add pandas" f446ce29c915 python
-m : same like git
-a : 指定更新的使用者信息
(一堆數字) 建立映像檔的容器的 ID
(string) images and tag
docker save -o python3.tar python //save imaes to tar file
docker rmi centos/python-35-centos7 //delete local docker images
2017年11月28日 星期二
Centos sendmail by gmail
#install ssmtp
sudo yum install ssmtp -y
sudo cp /etc/ssmtp/ssmtp.conf /etc/ssmtp/ssmtp.conf.bak
sudo yum install ssmtp -y
sudo cp /etc/ssmtp/ssmtp.conf /etc/ssmtp/ssmtp.conf.bak
vim /etc/ssmtp/ssmtp.conf
====
root=xxxxx@gmail.com
mailhub=smtp.gmail.com:587
Hostname=localhost
FromLineOverride=YES
UseTLS=YES
UseSTARTTLS=YES
AuthUser=xxxx@gmail.com
AuthPass=xxxxx
=====
#send test mail by ssmtp
echo "This is a test" | ssmtp recipient@your.domain.com
#change command mail default
alternatives --config mta
(choose)
echo "This is a test" | mail -s "Title" xxxxx@gmail.com
#set server reboot and mail to admin
sudo vim /etc/rc.d/rc.local
===
# wait 2min to sure all service open
(sleep 120
echo -e "`who -b`\n`ifconfig`\n`systemctl list-units | grep running`" | mail -s "Server on" xxxx@gmail.com
)&
====
sudo chmod u+x /etc/rc.d/rc.local
Install Juypter
#install jupyter
sudo pip3 install jupyter
# generate config file
jupyter notebook --generate-config
## if open multijuyter must type following command first
unset XDG_RUNTIME_DIR
sudo pip3 install jupyter
# generate config file
jupyter notebook --generate-config
#generate hashcode
python3
===
from notebook.auth import passwd
passwd()
(password)
(password)
...
sha1:63d137bxxxxxxxxxxxxxxxxxxxxxxxxxx
exit()
=====
vim ~/.jupyter/jupyter_notebook_config.py
====
c.NotebookApp.ip='*'
c.NotebookApp.password = u'sha:ce...刚才复制的那个密文'
c.NotebookApp.open_browser = False
c.NotebookApp.port =8888 #随便指定一个端口
====
# firewall
firewall-cmd --zone=public --add-port=8888/tcp --permanent
systemctl restart firewalld.service
#or use ssh tunnel
ssh username@address_of_remote -L127.0.0.1:1234:127.0.0.1:8888
#centos restart autostart by screen
vim /etc/crontab
===
@reboot username screen -dmS jupyter jupyter notebook
===
screen -r jupyter
#===Int Screen: Jupyter====
#can see information
#========
## if open multijuyter must type following command first
unset XDG_RUNTIME_DIR
ref:
http://blog.leanote.com/post/jevonswang/%E8%BF%9C%E7%A8%8B%E8%AE%BF%E9%97%AEjupyter-notebook
http://jupyter.org/install.html
2017年8月13日 星期日
Install Gitlab to own PC
Install Gitlab to own PC
1. Install and configure the necessary dependencies
sudo yum install curl policycoreutils openssh-server openssh-clients -y
sudo systemctl enable sshd
sudo systemctl start sshd
sudo yum install postfix
sudo systemctl enable postfix
sudo systemctl start postfix
sudo firewall-cmd --permanent --add-service=http
sudo systemctl reload firewalld
2. Add the GitLab package server and install the package
curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
sudo yum install gitlab-ce -y
3. Configure and start GitLab
sudo gitlab-ctl reconfigure
4. Change hostname and port number
vim /etc/gitlab/gitlab.rb
===
external_url "http://localhost:9999" #change port to 9999
gitlab_rails['gitlab_shell_ssh_port'] = 9998 #change ssh port to xxxxx,if your ssh port changed
# set mail server(gmail)
gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.gmail.com"
gitlab_rails['smtp_port'] = 587
gitlab_rails['smtp_user_name'] = "my.email@gmail.com"
gitlab_rails['smtp_password'] = "my-gmail-password"
gitlab_rails['smtp_domain'] = "smtp.gmail.com"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['smtp_tls'] = false
gitlab_rails['smtp_openssl_verify_mode'] = 'peer' # Can be: 'none', 'peer', 'client_once', 'fail_if_no_peer_cert', see http://api.rubyonrails.org/classes/ActionMailer/Base.html
===
sudo gitlab-ctl reconfigure
sudo gitlab-ctl restart
Backup:
> /opt/gitlab/bin/gitlab-rake gitlab:backup:create CRON=1
> ls
1510848068_2017_11_17_9.4.4_gitlab_backup.tar
Auto Backup:
>vi /etc/crontab
=======
// Backup in 1st & 15th day month
0 0 1,15 * * root /opt/gitlab/bin/gitlab-rake gitlab:backup:create CRON=1
=======
Recovery:
Must same version gitlab
After set gitlab.rb
Stop gitlab servies
> gitlab-ctl stop unicorn
> gitlab-ctl stop sidekiq
> gitlab-ctl status
Paste the backup file to /var/opt/gitlab/backups/
> 1530366625_2018_06_30_10.1.4_gitlab_backup.tar
recovery (use timestamp of backup file)
> gitlab-rake gitlab:backup:restore BACKUP=1530366625_2018_06_30_10.1.4
> gitlab-ctl restart
Check gitlab:
> gitlab-rake gitlab:check SANITIZE=true
ref:
https://about.gitlab.com/installation/#centos-7
1. Install and configure the necessary dependencies
sudo yum install curl policycoreutils openssh-server openssh-clients -y
sudo systemctl enable sshd
sudo systemctl start sshd
sudo yum install postfix
sudo systemctl enable postfix
sudo systemctl start postfix
sudo firewall-cmd --permanent --add-service=http
sudo systemctl reload firewalld
2. Add the GitLab package server and install the package
curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
sudo yum install gitlab-ce -y
3. Configure and start GitLab
sudo gitlab-ctl reconfigure
4. Change hostname and port number
vim /etc/gitlab/gitlab.rb
===
external_url "http://localhost:9999" #change port to 9999
gitlab_rails['gitlab_shell_ssh_port'] = 9998 #change ssh port to xxxxx,if your ssh port changed
# set mail server(gmail)
gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.gmail.com"
gitlab_rails['smtp_port'] = 587
gitlab_rails['smtp_user_name'] = "my.email@gmail.com"
gitlab_rails['smtp_password'] = "my-gmail-password"
gitlab_rails['smtp_domain'] = "smtp.gmail.com"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['smtp_tls'] = false
gitlab_rails['smtp_openssl_verify_mode'] = 'peer' # Can be: 'none', 'peer', 'client_once', 'fail_if_no_peer_cert', see http://api.rubyonrails.org/classes/ActionMailer/Base.html
sudo gitlab-ctl reconfigure
sudo gitlab-ctl restart
Backup:
> /opt/gitlab/bin/gitlab-rake gitlab:backup:create CRON=1
> ls
1510848068_2017_11_17_9.4.4_gitlab_backup.tar
Auto Backup:
>vi /etc/crontab
=======
// Backup in 1st & 15th day month
0 0 1,15 * * root /opt/gitlab/bin/gitlab-rake gitlab:backup:create CRON=1
=======
Recovery:
Must same version gitlab
After set gitlab.rb
Stop gitlab servies
> gitlab-ctl stop unicorn
> gitlab-ctl stop sidekiq
> gitlab-ctl status
Paste the backup file to /var/opt/gitlab/backups/
> 1530366625_2018_06_30_10.1.4_gitlab_backup.tar
recovery (use timestamp of backup file)
> gitlab-rake gitlab:backup:restore BACKUP=1530366625_2018_06_30_10.1.4
> gitlab-ctl restart
Check gitlab:
> gitlab-rake gitlab:check SANITIZE=true
Update Gitlab:
1. Make a backup (Optional)
If you would like to make a backup before updating, the below command will backup data in /var/opt/gitlab/backups by default.
> sudo gitlab-rake gitlab:backup:create STRATEGY=copy
2. Update GitLab
Update to the latest version of GitLab.
> sudo yum install -y gitlab-ce
https://about.gitlab.com/installation/#centos-7
訂閱:
文章 (Atom)
Centos GUI Webserver 設定
新灌的一台Centos7可以做以下的設定 語系設定: - sudo localectl set-locale LC_CTYPE=zh_TW.UTF-8 修改ssh port - http://linux.vbird.org/linux_server/0310telne...
-
現在市面上的智慧家居玲琅满目,上週的課程剛好有學到繼電器,所以就順帶做個智慧插座。這次DIY的智慧插座功能很簡單,純粹只用網頁開關插座,沒有其他功能。(RaspberryPi使用Python編寫,其實蠻容易擴充功能的。) 1. 首先,準備好RaspberryPi,麵包板、繼電...
-
安裝Anaconda 前往官網 https://www.continuum.io/downloads 下載sh bash Anaconda3-4.4.0-MacOSX-x86_64.sh #安裝設定 #新建環境 conda create --name crawlerP...
-
近期在玩 RaspberryPi,需要Lamp功能,邊裝邊紀錄過程,方便下次直接複製XD RaspberryPi + Apache + PHP + MariaDB + Phpmyadmin # 更新套件 sudo apt-get update & sudo apt...
