UBUNTU 18.04/19.10 安裝 PHP7.2 +Composer +nginx+Laravel+nodejs+github專案流程建立

PHP7.2+Composer+Larave+nodejs+github流程建立,從無到有的建立出一個php程式開發的環境,並加入GITHUB 上傳的專案流程

1.INSTALL PHP

sudo apt-get install php7.2 php7.2-cli php7.2-common php7.2-fpm php7.2-json php7.2-mbstring php7.2-mysql php7.2-readline php7.2-sqlite3 php7.2-xml php7.2-zip



2.INSTALL Composer

sudo apt-get install composer



3.Install Node.JS & npm

sudo apt-get install npm



4.Create First Laravel project

#composer create-project laravel/laravel [專案名] --prefer-dist composer create-project laravel/laravel laravel --prefer-dist





5.start npm & webpack

#cd [專案名]
cd laravel
npm install




6.RUN NPM

npm run watch




7.new Screen: Start Laravel http service:

php artisan serve


打完收工:
測試網址:http://127.0.0.1:8000
對外測試:
php artisan serve host 0.0.0.0

8.Install php-fmp & enable php7.2-fpm

sudo systemctl enable php7.2-fpm
service php7.2-fpm start


8. Install Nginx

sudo apt-get install nginx


10.edit nginx config file

sudo vi /etc/nginx/sites-enabled/default

################################
#root /var/www/html;
root /home/pi/laravel/public;

#Add index.php to the list if you are using PHP
#index index.html index.htm index.nginx-debian.html;
index index.php index.html index.htm index.nginx-debian.html;
 
location ~ .php$ {
     include snippets/fastcgi-php.conf; 
     fastcgi_pass unix:/var/run/php/php7.2-fpm.sock; 
}
location ~ /\.ht {             
    deny all;     
}



11.啟動nginx 並設定開機重啟

sudo service nginx restart
sudo systemctl enable nginx

http://localhost/index.php

終於完成了這篇好長的過程~ 謝謝大家的收看。

番外篇:

Github :https://github.com

i.在github 建立[你的專案]

mkdir temp
cd temp
git clone https://github.com/[你的帳號]/[你的專案]
mv [你的專案]/.git ../
cd ../
rm -rm temp




ii.建立上傳的過濾資料:.gitignore

vi .gitignore

以下是.gitignore的內容.這裡面的東西不會被git 傳上server

#內容:
/node_modules
/public/hot
/public/storage
/storage/*.key
/vendor
.env
.phpunit.result.cache
Homestead.json
Homestead.yaml
npm-debug.log
yarn-error.log
#結束


iii.加入/COMMIT/然後上傳GIT

git.add .
git commit -m "init project"
git push

打完虛脫…..GG ….


Conclustion:

我們使用LINUX平台設定出php環境,開始開發PHP程式.




關於我:

JACCH SCRATCH 教學

JACCH是一個長期教自己小朋友的爸爸,在某個小小的工廠擔任資訊管理人員,編寫公司的ERP系統. 平時喜觀研究PYTHON,PHP,LINUX 等等的技術,也喜歡購買分享和開箱.
Facebook: https://www.facebook.com/twmakers
Discord 群: https://discord.gg/GPXbgqa






























Ubuntu server 18.04 install laravel+nginx

deb http://tw.archive.ubuntu.com/ubuntu/ bionic main restricted
deb http://tw.archive.ubuntu.com/ubuntu/ bionic-updates main restricted
deb http://tw.archive.ubuntu.com/ubuntu/ bionic universe
deb http://tw.archive.ubuntu.com/ubuntu/ bionic-updates universe
deb http://tw.archive.ubuntu.com/ubuntu/ bionic multiverse
deb http://tw.archive.ubuntu.com/ubuntu/ bionic-updates multiverse
deb http://tw.archive.ubuntu.com/ubuntu/ bionic-backports main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu bionic-security main restricted
deb http://security.ubuntu.com/ubuntu bionic-security universe
deb http://security.ubuntu.com/ubuntu bionic-security multiverse

 

sudo apt install composer php-mysql php-fpm php-mbstring php-tokenizer php-xml php-json php-common nginx

 

Youtuber被使用未授權字型公司控告侵權建議大家可以下載以政府提供的字體

最近許多Youtuber被字型公司控告侵權.

也就是說只要使用在圖像或影片不能用於未授權的字型製作字幕.
否則會以每個月2萬元的費用支付給字型創作公司.

所以建議大家可以下載以政府提供的字體:
CNS11643中文標準交換碼全字庫(簡稱全字庫)
https://data.gov.tw/dataset/5961

這個是全字庫的字體,可以在政府開放平台中下載取得.

因為沒有做用微軟作業系統創作影片,所以應該沒有被告的風險.

Centos 安裝MING

Centos 安裝MING和PHP-MING

yum install bison flex freetype-devel
mkdir /usr/local/src/ming
cd /usr/local/src/ming

 

wget http://downloads.sourceforge.net/ming/ming-0.4.0.beta5.tar.gz
tar xzf ming*.tar.gz
cd ming*
./configure --enable-php
make
make install

PHP 的JSON傳送通訊流程

Server side:

<?php

$json = file_get_contents(‘php://input’);
$obj = json_decode($json);

if($obj->name!=””)
$result[“ok”]=1;
else
$result[“ok”]=0;

echo json_encode($result);

?>

Client side:

<?php
$data[“name”]=”Blah blah”;
$data_string = json_encode($data);

$ch = curl_init(‘https://jacch.php5.idv.tw/json.php’);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, “POST”);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
‘Content-Type: application/json’,
‘Content-Length: ‘ . strlen($data_string))
);

$result = curl_exec($ch);
$result = json_decode($result);
var_dump($result);

?>

[PHP]PHPMailer 騰訊企業郵箱

PHPMailer 騰訊企業郵箱

用PHP連結企業郵箱寄送信件的程式Sample

$this->mail = new PHPMailer(true);

if(is_a($this->mail,”PHPMailer”)){

try {
$this->mail->isSMTP();
$this->mail->SMTPDebug = 0;
$this->mail->Host = “hwsmtp.exmail.qq.com”;
$this->mail->Port = 465;
$this->mail->SMTPSecure= “ssl”;
$this->mail->SMTPAuth = true;
$this->mail->SMTPKeepAlive=true;

//帳號
$this->mail->Username=”noreply@blahblah.com.xxx”;

//密碼
$this->mail->Password=”blahblah”;

//
$this->mail->setFrom($from_email, $from_name);

$this->mail->CharSet = mb_detect_encoding($contents);

$this->mail->addAddress($email, $to_name);

$subject = base64_encode($subject);
$subject = ‘=?utf8?B?’.$subject .’?=’;
$this->mail->Subject = $subject;
$this->mail->Body =$contents;
$this->mail->IsHTML(true);

//寄出
$this->mail->send();

} catch (phpmailerException $e) {
//echo $e->errorMessage(); //Pretty error messages from PHPMailer
} catch (Exception $e) {
//echo $e->getMessage(); //Boring error messages from anything else!
}