發佈日期:

WordPress on Centos 7 + Nginx + PHP 7 + Mariadb

1.Update the epel-release and install the REPO for remi-php 7

sudo yum -y install epel-release
sudo rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
yum install yum-utils
yum-config-manager --enable remi-php72

2.add nginx REPO

sudo nano /etc/yum.repos.d/nginx.repo

add code in /etc/yum.repos.d/nginx.repo

[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/7/$basearch/
gpgcheck=0
enabled=1

3.install nginx , mariadb , php

sudo yum -y update
sudo yum -y install nginx mariadb-server git libpng12
yum -y install php-devel php-mysql php-opcache php-gd php-common php-xmlrpc php-mcrypt php-zip php-cli php-xml php-mbstring php-curl php-fpm 

4.Open firewall port for service

sudo firewall-cmd --permanent --zone=public --add-service=http
sudo firewall-cmd --permanent --zone=public --add-service=https
sudo firewall-cmd --permanent --zone=public --add-service=ftp
sudo firewall-cmd --reload

5.Setup nginx & PHP

sudo systemctl restart nginx
sudo systemctl enable nginx
sudo vi /etc/nginx/conf.d/lab.conf
sudo vi /etc/opt/remi/php71/php.ini
   cgi.fix_pathinfo=0
sudo vi /etc /php-fpm.d/www.conf
   user = nginx
   group = nginx
   listen.owner = nobody
   listen.group = nobody
sudo systemctl restart php-fpm
sudo systemctl enable php-fpm

6.copy the wordpress rouce code to /usr/share/nginx/wordpress/

chown -R nginx:nginx /usr/share/nginx/wordpress/
sudo systemctl restart nginx

7.setup the database

sudo systemctl restart mariadb
sudo systemctl enable mariadb 
mysql_secure_installation

8.Create Database for wordpress
mysql –u root –p

create database wordpress;
grant all on wordpress.* to 'wordpress'@'localhost' identified by 'password';
flush privileges;
exit
發佈日期:

[Centos]用rsync+ssh+crontab做主機自動同步備份

製作不需詢問密碼就可以登入的ssh用戶

接下來我們要讓client透過ssh登入server時不再詢問密碼,這樣當我們用rsync透過ssh將資料同步備份到client時,就能全自動進行,不會卡在詢問密碼那裡

首先在client端製作公鑰和私鑰

$ ssh-keygen -t rsa

這中間會問你鑰匙要放在哪個目錄,還有passphrase,按三次Enter採用預設值

Generating public/private rsa key pair.
Enter file in which to save the key (/home/davidpai/.ssh/id_rsa):
Created directory ‘/home/davidpai/.ssh’.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/davidpai/.ssh/id_rsa.
Your public key has been saved in /home/davidpai/.ssh/id_rsa.pub.

最後鑰匙會產生在家目錄的.ssh目錄下,id_rsa.pub是公鑰,id_rsa就是私鑰,把公鑰傳到server上,然後到server上,將公鑰加入authorized_keys
authorised_keys放在家目錄的.ssh目錄下,如果還沒有這個目錄,手動把它建立起來

$ mkdir .ssh

第一次還沒有authorized_keys,直接用cat把id_rsa.pub的內容加進去

$ cat id_rsa.pub >> authorized_keys

以後要加其他的公鑰,也是用cat附加到該檔案後面就可以

回到client端,試試看是否不需要詢問密碼就能登入

$ ssh xxx@xxx.xxx.xxx

3. rsync同步備份

再來我們就可以用rsync來同步備份server端的資料

在client端輸入以下指令

$ rsync -av –delete -e ssh xxx@xxx.xxx.xxx:/var/www /home/backup

這樣就是把遠端server主機上的/var/www目錄全部資料同步備份到client端的/home/backup目錄裡,之後server端有任何異動,只會同步備份異動的部份,這就是所謂的差異備份。

那個-e參數後面要空一個寫ssh,表示傳輸過程我們要使用ssh通道加密。

那個–delete參數的意思是說,server端檔案如果刪除,client端也會刪除,如果不加這個參數,client端檔案就會留著不刪除,這個參數加不加可以自己斟酌。

4. 設定cron讓備份自動執行

最後我們想要讓server端的資料可以定時自動同步備份到client端,這就輪到crontab上場了
在client端把上述指令寫到crontab裡

$ crontab -e
2 4 * * * rsync -av –delete -e ssh xxx@xxx.xxx.xxx:/var/www /home/backup

這樣就是在每天凌晨04:02自動同步備份遠端server的/var/www目錄到/home/backup

發佈日期:

使用centos 7+nginx+mariadb+bedrock架設wordpress網站

1.sudo yum -y install epel-release

2.sudo rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm

wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

wget http://rpms.remirepo.net/enterprise/remi-release-7.rpm

rpm -Uvh remi-release-7.rpm epel-release-latest-7.noarch.rpm

yum install yum-utilsyum-config-manager –enable remi-php71

 

 

3.sudo vi /etc/yum.repos.d/nginx.repo

[nginx]

name=nginx repo

baseurl=http://nginx.org/packages/centos/7/$basearch/

gpgcheck=0

enabled=1

4.sudo yum -y update

5.sudo yum -y install nginx mariadb-server git libpng12

  1. yum -y install php-devel php-mysql php-opcache php-gd php-common php-xmlrpc php-mcrypt php-zip php-cli php-xml php-mbstring php-curl php-fpm

7.sudo firewall-cmd –permanent –zone=public –add-service=http

8.sudo firewall-cmd –permanent –zone=public –add-service=https

9.sudo firewall-cmd –permanent –zone=public –add-service=ftp

10.sudo firewall-cmd –reload

11.sudo systemctl restart nginx

12.sudo systemctl enable nginx

13.sudo vi /etc/nginx/conf.d/lab.conf

14.sudo vi /etc/opt/remi/php71/php.ini

   cgi.fix_pathinfo=0

15.sudo vi /etc /php-fpm.d/www.conf

user = nginx

group = nginx

listen.owner = nobody

listen.group = nobody

16.sudo systemctl restart php-fpm

17.sudo systemctl enable php-fpm
17-1 install composer

17-2 install nodejs

17-3 install yarn

18.

cd ~/.ssh

ssh-keygen -t rsa

 

git clone git@github.com:Alter-Studio/aopen.git

mkdir /usr/share/nginx/lab.web.aopen.com

19.copy alter source code to /usr/share/nginx/lab.web.aopen.com

19-1.yum install tomcat

19-2 run ‘composer install’ in folder /usr/share/nginx/lab.web.aopen.com/web

19-3 run ‘composer install’ in folder /usr/share/nginx/lab.web.aopen.com/web

19-4 run ‘yarn” in folder /usr/share/nginx/lab.web.aopen.com/web

19-5 run ‘yarn build:production” in folder /usr/share/nginx/lab.web.aopen.com/web

19-6 chown -R nginx:nginx /usr/share/nginx/lab.web.aopen.com/

20.sudo systemctl restart nginx

  1. sudo systemctl restart mariadb
    22.sudo systemctl enable mariadb

23. mysql_secure_installation24.mysql –u root –p25. create database alter_DB;26. grant all on alter_DB.* to ‘alter’@’localhost’ identified by ‘Aopen@1122’;27. flush privileges;28.exit