新增使用者spencerchang

sudo adduser spencerchang

spencerchang加入群組sudo,www-data

sudo adduser spencerchang sudo
sudo adduser spencerchang www-data

Add php5.6 PPA(php7.0以上,不用新增)

sudo add-apt-repository ppa:ondrej/php

更新PPA資料源

sudo apt-get update

安裝apache2

sudo apt-get install apache2

安裝mysql 5.7

sudo apt-get install mysql-client-5.7 mysql-server-5.7

安裝php 5.6 和其他套件

sudo apt-get install php5.6 php5.6-bz2 php5.6-cgi php5.6-cli php5.6-common php5.6-curl php-dev php5.6-fpm php5.6-gd php5.6-imap php5.6-intl php5.6-json php5.6-ldap php5.6-mbstring php5.6-mcrypt php5.6-mysql php5.6-odbc php5.6-sybase php5.6-xml php5.6-zip

安裝 libapache2-mod-php5.6

sudo apt-get install libapache2-mod-php5.6

安裝phpmyadmin

sudo apt-get install phpmyadmin

enable rewrite

sudo a2enmod rewrite

php版本顯示錯誤的話

sudo ln -sfn /usr/bin/php5.6 /etc/alternatives/php

更新到最新的軟體更新

sudo apt-get dist-upgrade
  • 系統分割和掛載mount

列出所有裝置

lsblk

裝置的 UUID 等參數

blkid

超過2T用gdisk分割, 否則用fdisk分割

sudo gdisk /dev/sdb

格式化成 ext4

mkfs.ext4 /dev/sdb1

掛載mount

sudo mount -o auto UUID="435453f6-902f-4184-a8da-3da91033b4ea" /web

新增/web到 自動掛載mount fstab

# web
UUID=435453f6-902f-4184-a8da-3da91033b4ea       /web ext4 defaults   0       0
sudo vim /etc/fstab
  • 系統設定

去除80port,新增監聽port在ports.conf

#Listen 80
Listen 8888
Listen 8889
Listen 8890
Listen 8989
sudo vim /etc/apache2/ports.conf

新增nginx 監聽80 port

sudo apt-get install nginx

新增/etc/nginx/sites-available/api

新增/etc/nginx/sites-available/gitlab_ci

Enabled site

sudo ln -s /etc/nginx/sites-available/api /etc/nginx/sites-enabled/api
sudo ln -s /etc/nginx/sites-available/gitlab_ci /etc/nginx/sites-enabled/gitlab_ci

在/etc/nginx/ 新增www-allow資料夾,新增client-allow.conf 填入該有的ip

sudo vim /etc/nginx/www-allow/client-allow.conf
allow 60.248.78.61;
allow 60.248.78.57;
allow 178.79.141.223;
allow 172.16.0.0/12;
allow 127.0.0.1;
allow 192.168.0.0/16;
allow 178.79.153.148;

在/etc/hosts新增hosts

127.0.1.1       gmktapi.viewsonic.com   gmktapi
127.0.1.1       gitlab.api.viewsonic.com
127.0.1.1       lstage-pj_app_admin.vsi.viewsonic.com
127.0.1.1       lstage-pj_app_admin
172.21.1.123    stage-ap stage-eu

在/etc/nginx/sites-enabled/api 將root先改為

root /var/www/html;

將/web/ 檔案 全部rsync

sudo rsync -avh spencerchang@172.21.1.77:/web/ /web/

匯出所有的資料庫

mysqldump -u root -p --all-databases > lstage_all.sql

匯入所有的資料庫

mysql -u root -p < lstage_all.sql

編輯 /etc/phpmyadmin/config-db.php

sudo vim /etc/phpmyadmin/config-db.php

改為
$dbuser='';
$dbpass='';
$basepath='';
$dbname='';
$dbserver='';
$dbport='';
$dbtype='mysql';

關閉mysql strict mode,新增一個disable_strict_mode.cnf

sudo vim /etc/mysql/conf.d/disable_strict_mode.cnf

[mysqld]
sql_mode=IGNORE_SPACE,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

只安裝安全性更新

sudo unattended-upgrade

sendmail

安裝sendmail

sudo apt-get install sendmail

加入gmktapi.viewsonic.com 到local-host-names,一行一個domain,允許收發信

sudo vim /etc/mail/local-host-names

samba

安裝samba

sudo apt-get install samba

變更密碼

sudo smbpasswd -a spencerchang

變更設定檔

sudo vim /etc/samba/smb.conf

directory mask = 0755

[ap_vstw_web]等等各個資料夾的設定檔案

samba restart

sudo service smbd restart

phantomjs

安裝phantomjs

sudo mv phantomjs-2.1.1-linux-x86_64 /usr/local/share/

sudo ln -sf /usr/local/share/phantomjs-2.1.1-linux-x86_64/bin/phantomjs /usr/local/share/phantomjs
sudo ln -sf /usr/local/share/phantomjs-2.1.1-linux-x86_64/bin/phantomjs /usr/local/bin/phantomjs
sudo ln -sf /usr/local/share/phantomjs-2.1.1-linux-x86_64/bin/phantomjs /usr/bin/phantomjs

gitlab

升版需要一個一個小版本升版,非常容易失敗

匯出gitlab backups

sudo -u git -H bundle exec rake gitlab:backup:create RAILS_ENV=production

gitlab backups path

cd /var/opt/gitlab/backups

gitlab 依照官網標準流程,安裝 10.5.3-ee,port設為8787,不然會吃掉nginx的80 port

sudo vim /etc/gitlab/gitlab.rb

加入8787 port

external_url 'http://gmktapi.viewsonic.com:8787/gitlab'

執行gitlab-ctl reconfigure 使修改生效

sudo gitlab-ctl reconfigure

nginx 加入gitlab conf 將http://gmktapi.viewsonic.com 轉址到8787 port

update gitlab ee

sudo apt-get update
sudo apt-get install gitlab-ee

Crontab

查看root的crontab

sudo crontab -l

編輯crontab

sudo crontab -e

目前的crontab 時程

0 1 * * * /web/backup/geoip_bin.sh
0 2 * * * /web/backup/vse_finchclub/feu_backup.sh
0 4 * * * /web/backup/vscn_web/cn_backup.sh
0 6 * * * /web/backup/mvb/mvb_backup.sh
0 21 * * * /web/backup/qr_web/qr_backup.sh
0 22 * * * /web/backup/lstage_database/lstage_database.sh
0 23 * * * /web/backup/lstage_web_set/lstage_web_set.sh
0 5 * * * /web/backup/vsei_web/vsei_backup.sh
0 8 * * * /web/backup/reconfig_gitlab.sh
0 13 * * * /web/backup/reconfig_gitlab.sh
30 21 * * * /web/backup/reconfig_gitlab.sh
30 10 * * * sh /web/ap_web/serial_import_vse/cron.sh
30 9 * * * sh /web/ap_web/serial_import_vse/cron_vsi.sh
#00 05 * * * sh /web/ap_web/serial_import_vse/cron_vsi_laravel.sh
30 7 15 * * sh /web/ap_web/regulation_sync/pcs_regulation.sh
#* * * * * php /web/pss/artisan schedule:run >> /dev/null 2>&1

Freetds

編輯freetds conf

sudo vim /etc/freetds/freetds.conf

新增mssql server連線資訊

# vsi mssql server
[vsiweb02]
        host = 172.21.1.4
        port = 1433
        tds version = 8.0

[vsiweb02old]
        host = 172.21.1.28
        port = 1433
        tds version = 8.0

results matching ""

    No results matching ""