note
AWS
video
ubuntu
sudo apt-get update
sudo apt-get upgrade
sudo add-apt-repository ppa:nginx/stable
sudo apt-get update
sudo apt-get install nginx
sudo service nginx start
cd /var/www/html
sudo adduser lj
123456zxc123
(add sudo permission to lj)
sudo usermod -aG sudo lj
(prevent that root be hacked and delete all files)
#swich user
su - lj
正確來說只要給它需要用的權限就好
sudo su
#check ssh key for root user
cat .ssh/authorized_keys
#copy to user lj
cp -r .ssh/authorized_keys /home/lj
su - lj
mkdir .ssh
mv authorized_keys .ssh/
cd .ssh/
ll
#make auth of authorized_keys from root to lj
sudo chown lj:lj authorized_keys
ll
sudo vi /etc/ssh/sshd_config
change the root login from true to no
https://launchpad.net/~ondrej/+archive/ubuntu/php
sudo add-apt-repository ppa:ondrej/php
sudo apt-get install
#to connect nginx
sudo apt-get install php-fpm
sudo apt-get install php
sudo apt-get install php-mbstring
sudo apt-get install php-json
//sudo apt-get install php-ctype -y
//sudo apt-get install php-openssl -y
//sudo apt-get install php-pdo -y
sudo apt-get install php-xml -y
sudo apt-get install php-zip -y
sudo apt-get install php-mysql
cd /etc/nginx/sites-available/
change to
uninstall apache(不宜定要刪掉,可以停掉就好80port)
sudo service nginx restart
cd /var/www
git clone file
#install composer
cd /projectfile
sudo apt-get install composer
sudo composer install
sudo cp .env.example .env
(其實只要給特定的夾子就好)
(其實只要group 改成)
sudo chown -R www-data:www-data .
->No application encryption key has been specified.
sudo php artisan key:generate
sudo vi .env
20210510(可以直接用這個,現在 mysql 都內建)
CREATE USER 'laravel_api'@'localhost' IDENTIFIED WITH authentication_plugin BY '123456zxc123';
setting:
#create new user:
mysql -u root -p
CREATE USER 'lj'@'%' IDENTIFIED BY '123456zxc123';
#give privalige
GRANT ALL PRIVILEGES ON . TO 'lj'@'%';
FLUSH PRIVILEGES;
#enable outside access
#make 3306 listen to ouside(這步驟也是很危險,可能會被駭(無差別駭客),要開也是要換一個port)
cd /etc/mysql/mysql.conf.d/
#listen to all the host,allow remote connsction
sudo vi mysqld.cnf
sudo service mysql restart
sudo ufw allow 3306
mysql -u lj -h 3.89.137.188 -p
mysql -u lj -h 3.112.246.91 -p
https://laracasts.com/discuss/channels/code-review/unable-to-do-php-artisan-migrate
change .env
error(因為權限給nginx所以)
給login user laravel.log寫入的權限