- sudo apt-get update
- sudo apt-get install apache2 libapache2-mod-wsgi-py3 python-virtualenv python3-pip -y
- sudo apt-get update
- sudo apt-get install apache2 libapache2-mod-wsgi-py3 python-virtualenv python3-pip -y
- mkdir flaskapp
- sudo ln -sT ~/flaskapp /var/www/html/flaskapp
- touch flaskapp/index.html
- echo "Hello World" > flaskapp/index.html
- sudo apachectl restart
- http://35.221.146.213/flaskapp/index.html
- pip3 install virtualenv
- git pull
- cd flaskapp
- virtualenv -p python3 env
- source env/bin/activate
- pip3 install flask
- touch flaskapp.wsgi
import sys
sys.path.insert(0, '/var/www/html/flaskapp')
sys.path.insert(1, '/home/service/flaskapp/new_env/lib/python3.6/site-packages')
from main import app as application
- Set apache config /etc/apache2/sites-enabled/000-default.conf
WSGIDaemonProcess flaskapp python-path=/var/www/html/flaskapp:/var/www/html/flaskapp/env/lib/python3.6/site-packages
WSGIScriptAlias / /var/www/html/flaskapp/flaskapp.wsgi
DocumentRoot /var/www/html
<Directory flashapp>
WSGIProcessGroup flaskapp
WSGIApplicationGroup %{GLOBAL}
Order deny,allow
Allow from all
</Directory>
- sudo apachectl restart http://35.221.146.213/
- source env/bin/activate
- Pip3 install line-bot-sdk
- sudo apt-get update
- sudo apt-get install software-properties-common -y
- sudo add-apt-repository ppa:certbot/certbot
- sudo apt-get update
- sudo apt-get install python-certbot-apache -y
- sudo vim /etc/apache2/sites-enabled/000-default.conf
- Comment WSGIDaemonProcess
- sudo certbot --apache
- Uncomment WSGIDaemonProcess
- sudo apachectl restart
- sudo apt-get install mysql-server mysql-client libmysqlclient-dev -y
- sudo netstat -tap | grep mysql
- sudo vim /etc/mysql/debian.cnf
- mysql -u debian-sys-maint -p
CREATE USER 'user'@'localhost' IDENTIFIED BY 'password';
CREATE USER 'user'@'%' IDENTIFIED BY 'password';
GRANT ALL ON *.* TO 'user'@'localhost' IDENTIFIED BY 'password' WITH GRANT OPTION;
GRANT ALL ON *.* TO 'user'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;
FLUSH PRIVILEGES;
EXIT;
CREATE DATABASE `new_media` /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci */;
CREATE TABLE `new_media`.`articles ` ( `id` int(11) NOT NULL AUTO_INCREMENT, `title` TEXT DEFAULT NULL, `date` varchar(45) DEFAULT NULL, `tags` TEXT DEFAULT NULL, `share` varchar(45) DEFAULT NULL, `brand` varchar(45) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=397 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
CREATE DATABASE `fb_social_data` /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci */;
CREATE TABLE `fb_social_data`.`posts` ( `id` int(11) NOT NULL AUTO_INCREMENT, `date` varchar(45) DEFAULT NULL, `content` text, `attach` int(11) DEFAULT NULL, `interactive` int(11) DEFAULT NULL, `promotion_date` varchar(45) DEFAULT NULL, `promotion_attach` int(11) DEFAULT NULL, `promotion_interactive` int(11) DEFAULT NULL, `replied_count` int(11) DEFAULT NULL, `shared_count` int(11) DEFAULT NULL, `good` int(11) DEFAULT NULL, `group` varchar(45) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=62 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
CREATE TABLE `fb_social_data`.`replies` ( `id` int(11) NOT NULL AUTO_INCREMENT, `comment` text, `post_id` int(11) DEFAULT NULL, PRIMARY KEY (`id`)) ENGINE=InnoDB AUTO_INCREMENT=854 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
- sudo apt-get install libxss1 libappindicator1 libindicator7 xvfb unzip -y
- wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
- sudo apt-get install -f -y( run when install error )
- sudo dpkg -i google-chrome-stable_current_amd64.deb google-chrome --version https://chromedriver.storage.googleapis.com/index.html
- wget -N https://chromedriver.storage.googleapis.com/{version}/chromedriver_linux64.zip
- unzip chromedriver_linux64.zip
- chmod +x chromedriver
-
設定 port 號開啟
-
連進 /etc/mysql/mysql.conf.d/mysqld.cnf 更改 bind-address 成 0.0.0.0
-
/usr/local/mysql/bin/mysqldump -u root --password="password" -e "fb_social_data" > db.sql
Windows 路徑: C:\Program Files\MySQL\MySQL Server 8.0\bin 輸出的位置: C:\Users\user\Desktop\db.sql
-
/usr/local/mysql/bin/mysql -h 35.201.183.55 -u user --password="password" --execute="DROP DATABASE fb_social_data;"
-
/usr/local/mysql/bin/mysql -h 35.201.183.55 -u user --password="password" --execute="CREATE SCHEMA fb_social_data DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;"
-
/usr/local/mysql/bin/mysql -h 35.201.183.55 -u user --password="password" --database="fb_social_data" < "/Users/johnliu/db.sql"
-
建立 bash script 檔案 #!/bin/bash