2018-05-16 Server建置

Published on:

Ubuntu
php7.1
nginx
mysql

https://dan381006472.gitbooks.io/laravelnote-kfk-me/content/laravel/lnmp_php71.html

sudo apt-get update
sudo apt-get install -y language-pack-en-base
sudo locale-gen en_US.UTF-8
sudo apt-get install software-properties-common
sudo LC_ALL=en_US.UTF-8 add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get -y install php7.1  (會連apache 也順便裝了)
改用  sudo apt install php7.1 php7.1-fpm 
sudo apt-get -y install php7.1-mysql
sudo apt-get install php7.1-fpm
sudo apt-get install php7.1-curl php7.1-xml php7.1-mcrypt php7.1-json php7.1-gd php7.1-mbstring php7.1-zip

sudo  apt-get -y install nginx
sudo apt-get -y install mysql-server-5.7

若Nginx安裝有問題,有可能是apache佔住了port

sudo netstat -tulpn | grep :80
sudo apachectl stop //停apache
要移除 apache :
sudo apt-get --purge remove apache2*
sudo apt-get autoremove apache2
sudo service nginx start //啟用nginx

Mysql:
https://www.digitalocean.com/community/tutorials/how-to-install-mysql-on-ubuntu-16-04

nginx doc
webmin ?

freessl

https://blog.gtwang.org/linux/secure-nginx-with-lets-encrypt-ssl-certificate-on-ubuntu-and-debian/

安裝時可能會出現問題,解法參考網站 找最多人讚的那個

I resolved the issue by setting the locale variables. Without these, the script seems to break.
export LC_ALL="en_US.UTF-8"
export LC_CTYPE="en_US.UTF-8"

 fressl 實際安裝流程

 0.先將/etc/nginx/sites-available/xxx.com 的設定檔備份(等一下certbot-auto會自動寫入設定)
 1.從 Certbot 官方網站下載 certbot-auto 指令稿,並設定其執行權限
   wget https://dl.eff.org/certbot-auto  
   chmod a+x certbot-auto
   mkdir /opt/letsencrypt
   mv certbot-auto /opt/letsencrypt/
 
 2.執行 certbot-auto,讓它自動安裝所有相依套件
   export LC_ALL="en_US.UTF-8"
   export LC_CTYPE="en_US.UTF-8"
   /opt/letsencrypt/certbot-auto
   自動安裝時,會自動寫入設定
 3.重啟 nginx 
   sudo service nginx restart 
 4.修改Larvel專案  config\admin.php  'secure' => false 改成 true 。這樣開後台開才不會有問題
 5.設定SSL自動更新 
   (1) 測試: /opt/letsencrypt/certbot-auto renew --dry-run 
   (2) 正式:/opt/letsencrypt/certbot-auto renew --quiet --no-self-upgrade
   (3) 將此指令寫到 /opt/letsencrypt/renew.sh檔
       /opt/letsencrypt/certbot-auto renew --quiet --no-self-upgrade --post-hook "sudo service nginx reload"
       sudo chmod a+x renew.sh
   (4) 把這個 /opt/letsencrypt/renew.sh 指令稿寫進 crontab 中
       vi /etc/crontab
       分 時   日 月 週         
       30 2    * * 7   root    /opt/letsencrypt/renew.sh
       每週日 早2:30 執行檢查更新

laravel php 相關套件

wordpress

sudo ln -s /etc/nginx/sites-available/heskare.com

laravel 的資料夾權限問題 :storage
https://www.itechempires.com/2017/06/laravel-5-files-folders-permission-ownership-setup/

//看有哪些群組
cat /etc/group | grep www

// 看誰佔著Nginx
ps aux -P | grep nginx
//將 www這個資料夾的擁有者改為 wwww-data
sudo chown -R www-data:www-data www

//將 ubuntu 這個人加入 www-data群組
usermod -a -G www-data ubuntu
//將 ubuntu 這個人移除 www-data群組
gpasswd -d ubuntu www-data
//看ubuntu加入了哪些群組
groups ubuntu

php artisan cache:clear
php artisan view:clear
php artisan config:clear

nginx 的設定
/etc/nginx/
修改php的設定
/etc/php/7.1/fpm/pool.d/www.conf
user =ubuntu
group =ubuntu

sudo service php7.1-fpm restart

wordpress 建置

  1. copy wordpress到指定目錄
  2. copy一個/etc/nginx/sites-available/nginx的設定
  3. 到 /etc/nginx/sites-enabled/ sudo ln -s /etc/nginx/sites-available/...
  4. 新增資料庫
  5. 到指定的網址進行安裝 root 名象 el_前綴

上傳 外掛時,發生 413 Request Entity Too Large,修改 nginx

client_max_body_size 100M;

安裝 Admin Meun editor 外掛
Admin Menu editor Seris: ATMRQ0NPKKJ6Z92BALB9W7LHOQXQBQV0

BackWPup

php sendmail

BeTheme seris:

purchse code: 7c145e92-7c96-460b-8d94-d557d12a003f

Bethem seris:
My purchase code: 48e15b9d-a01e-4258-a175-720ab1ce800a

Comments

comments powered by Disqus