Note ไว้สำหรับตัวเองเพราะต้องเอา Django ไปใช้
วัตถุดิบ
OS ที่ใช้
Web Server
Database
วิธีการลง
ลง Ubuntu ก่อน ฮาา
ลง MySQL Server
sudo apt-get install mysql-server # ขั้นตอนนี้ MySQL จะให้เซต password ให้ใส่ตามต้องการ
ลง apache httpd และ mod_wsgi โดยใช้คำสั่ง
sudo apt-get install apache2 libapache2-mod-wsgi
ลง Django webframework และ Python MySQL
sudo apt-get install python-django python-mysqldb
นำ django web ที่เราทำใส่ใน /var/www
เปิดไฟล์ /etc/apache2/sites-available/default ขึ้นมาเพื่อ config wsgi
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WSGIScriptAlias /myweb /var/www/sipacounter/myweb/wsgi.py
WSGIPythonPath /var/www/myweb
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www
<Directory /var/www/myweb>
<Files /myweb/wsgi.py>
Order deny,allow
Allow from all
</Files>
</Directory>
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
restart apache config sudo service apache2 restart
deploy Model ลง database โดยไปที่ web ของเรา สั่ง python manage.py syncdb # ให้ตรวจสอบ config ของ database ก่อนที่จะสั่งด้วย
เปิด browser เข้าเวบของเราก็จะเข้าได้ทันที
No comments :
Post a Comment