original source : https://youtu.be/Xjdv31k-Kf4

이 동영상은 1시간 분량인데 굉장히 설명이 잘되있으며 단계별 정리가 되어있다.

digitalocean 에 프로젝트 올릴때 사용했다. 위 동영상은 새로 시작하는setting 작업이고 이미 있는 프로젝트의 deploy는 https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-16-04#create-and-configure-a-new-django-project 를 따라 할수 있다. 이를 기반으로 한 동영상은 https://youtu.be/BrVHwQ-SJUA 이며 이는 apache가 아닌 Gunicorn wsgi를 이용했다. 

image
image
image

위는 ubuntu 처음 시작전 update와 upgrade를 하는 과정이다. 

image

동영상 게시자가 추천하는 구조이다.꼭 따라야 하는 것은 아니다. 

image
pip install -r /path/to/requirements.txt

requirements.txt에 있는 libraries들을 설치하는 방법

git clone, fetch, pull의 차이점 설명

https://stackoverflow.com/questions/3620633/what-is-the-difference-between-pull-and-clone-in-git

image
image

위에서 호스트 주소가 바뀐것을 유심히 볼것

image

mysql_secure_installation는 보안성을 높이는 과정이다. 

https://stackoverflow.com/q/20760908/3151712 참조

image

데이터베이스 연결정보 화일을 외부에 두는 방법이다. (옵셥사항)

image

최초 migrate을 통해 admin tables생성및 django superuser만드는법

image

아이피주소뒤에 붙는 port 주소를 없애기위해서는 apache server가 필요하다.그리고 설정수정을 한다.

image

python-path =  이값은 manage.py가 있는 경로

python-hom =  이값은 virtual env가 있는 경로

image
image

static화일 경로 설정이 필요하다. 

original source : https://youtu.be/vHYh-m4iXw4

기본적으로 macOS에는 apache, php가 준비되어있다. mysql, phpmyadmin은 따로 설치해주어야 한다. 

— Steps: 

  •  sudo apachectl start 
  •  sudo nano /etc/apache2/httpd.conf 
  •  remove # before #LoadModule php5… 
  •  sudo apachectl restart 
  •  sudo nano /etc/apache2/httpd.conf 
  •  Add index.php in DirectoryIndex line 
  •  sudo apachectl restart 
  •  sudo nano /Library/WebServer/Documents/index.php 
  •  add the code seen on the screen 
  •  download Mysql: https://dev.mysql.com/downloads/ 
  •  SAVE YOUR PASSWORD! 
  •  sudo mkdir /var/mysql 
  •  sudo ln -s /tmp/mysql.sock /var/mysql/mysql.sock 
  •  Start mysql Server
    – cd /usr/local/mysql/bin 
  •  sudo ./mysql -u root -p 
  •  Alter user ’root’@‘localhost’ identified by ‘newpassword’; 
  •  Download phpmyadmin: https://www.phpmyadmin.net 
  •  Copy paste it into Documents folder and rename to phpMyAdmin 
  •  cd /Library/Webserver/Documents/ 
  •  cd phpMyAdmin 
  •  sudo mkdir config 
  •  sudo chmod o+x config 
  •  open localhost/phpmyadmin 
  •  Under Authentication, enter mysql password 
  •  Download Config 
  •  Copy/Paste config into config folder 

mysql 은 community version이 free이다.

https://www.oracle.com/mysql/community.html

위에서 Alter user ’root’@‘localhost’ identified by ‘newpassword’; 여기에서 newpassword가 아니고 password로 진행해야 영상대로 된다.

또 영상에서는 Config 화일을 phpmyadmin 폴더에 넣는데 이는 만든 phpmyadmin/config폴더에 넣어야 한다.

아래 과정은 phpmyadmin에 접속할때 credential을 매번 넣지 않게 하기위한 옵션과정이다.

  • sudo ./mysql -u root -p
  • Alter user ’root’@‘localhost’ identified by ‘newpassword’;
  • Copy paste it into Documents folder and rename to phpMyAdmin
  • cd /Library/Webserver/Documents/
  • cd phpMyAdmin
  • sudo mkdir config
  • sudo chmod o+x config
  • open localhost/phpmyadmin
  • Under Authentication, enter mysql password
  • Download Config
  • Copy/Paste config into config folde

django에 mysql을 사용하려고 했으나 연결이 어려웠다. 아래 방법들을 다 시도해보고 결국 export PATH=$PATH:/usr/local/mysql/bin/ 를 통해 mysql config위치를 다시 정해 주고 pymysql을 설치하고 django downgrade로 문제 해결 했다.

pymysql 설치 https://stackoverflow.com/a/56312295

django downgrade https://stackoverflow.com/a/58448370

최종적으로 사용된 modules

image
image

.

.

.

image

.

.

.

image

.

.

.

image

위와 같은 error 발생

.

.

ModuleNotFoundError: No module named ‘MySQLdb’

https://stackoverflow.com/questions/53024891/modulenotfounderror-no-module-named-mysqldb

unable to install mysqlclient in python 3.7.3
https://stackoverflow.com/questions/57808191/unable-to-install-mysqlclient-in-python-3-7-3

What’s the difference between MySQLdb, mysqlclient and MySQL connector/Python?

https://stackoverflow.com/questions/43102442/whats-the-difference-between-mysqldb-mysqlclient-and-mysql-connector-python/46396881#46396881

pip install mysql-python fails with EnvironmentError: mysql_config not found
https://stackoverflow.com/questions/5178292/pip-install-mysql-python-fails-with-environmenterror-mysql-config-not-found

Import error :No module named MYSQLdb

https://askubuntu.com/questions/583415/import-error-no-module-named-mysqldb/1048285#1048285

Django – installing mysqlclient error: mysqlclient 1.3.13 or newer is required; you have 0.9.3

https://stackoverflow.com/questions/55657752/django-installing-mysqlclient-error-mysqlclient-1-3-13-or-newer-is-required

Best way to store hashtags and the uses / combinations in a database

How do I connect to a MySQL Database in Python?

How To Install Linux, Apache, MySQL, PHP (LAMP) stack on Ubuntu 14.04 | DigitalOcean