PHP新手30天實戰金流, Laravel6我們部署在最簡單的 Google Compute Engine 上。
gcloud config list project 列出專案 ID
官方有提供 Cloud Shell,不過瀏覽器上操作容易有延遲,建議改用本機的 terminal 建立 ssh 連線至虛擬機
gcloud beta compute ssh "機器名稱"sudo apt-get install git-allgit clone -b migrate https://github.com/Yu-hanCheng/shopping_cart.git
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install -y php7.3
curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /home/sarahcheng/taiwan/public
<Directory /home/sarahcheng/taiwan>
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
sudo a2enmod rewrite
sudo systemctl restart apache2 重啟apache (sudo systemctl status apache2)vim /var/log/apache2/error.log, vim /var/log/apache2/access.log
groupadd taiwan
gpasswd -a 使用者名稱 taiwangpasswd -a www-data taiwan
chown -R 使用者名稱.taiwan shopping_cart/
sudo find taiwan/ -type f -exec chmod 2660 {} \;
sudo find taiwan/ -type d -exec chmod 2770 {} \;sudo /etc/init.d/mysql start
sudo mysql -u rootSELECT User, Host, plugin FROM mysql.user; 看看有哪些使用者CREATE USER 'sarahcheng'@'localhost' IDENTIFIED WITH mysql_native_password BY 'www^0^Yoyo409'
GRANT ALL PRIVILEGES ON *.* TO 'sarahcheng'@'localhost';
quitsudo mysql -u sarahcheng -pwww^0^Yoyo409
composer install
sudo npm install
sudo npm run dev
php artisan migrate