Website mijn.makerspaceleiden.nl setup: verschil tussen versies

Uit MakerSpace Leiden
Ga naar: navigatie, zoeken
(In production - setup from zero =)
(In production - setup from zero =)
Regel 29: Regel 29:
 
     git clone https://github.com/dirkx/makerspaceleiden-crm.git
 
     git clone https://github.com/dirkx/makerspaceleiden-crm.git
  
# Create random seed
+
    # Create random seed
openssl rand 128 > /etc/crm_secret_key.txt
+
    openssl rand 128 > /etc/crm_secret_key.txt
chmod 640 /etc/crm_secret_key.txt
+
    chmod 640 /etc/crm_secret_key.txt
chgrp www-data /etc/crm_secret_key.txt
+
    chgrp www-data /etc/crm_secret_key.txt
 
+
   
# Allow storing of uploads in media by the suid
+
    # Allow storing of uploads in media by the suid
# all this runs as.
+
    # all this runs as.
mkdir -p var/media
+
    mkdir -p var/media
chown www-data var/media
+
    chown www-data var/media
 
+
   
# Prepare env for python and pull in the various dependencies.
+
    # Prepare env for python and pull in the various dependencies.
python3 -mvenv venv
+
    python3 -mvenv venv
source ./venv/bin/activate
+
    source ./venv/bin/activate
pip3 install -r requirements
+
    pip3 install -r requirements
 
+
   
# Set up the framework
+
    # Set up the framework
cd makerspaceleiden
+
    cd makerspaceleiden
ln -s prod.py local.py
+
    ln -s prod.py local.py
cat > makerspaceledien/my.cnf <<EOM
+
    cat > makerspaceledien/my.cnf <<EOM
[client]
+
    [client]
database = mslcrm
+
    database = mslcrm
user = mslcrmuser
+
    user = mslcrmuser
password = XXXX-passowrd-XXX
+
    password = XXXX-passowrd-XXX
default-character-set = utf8
+
    default-character-set = utf8
EOM
+
    EOM
 
+
   
# Create database & user
+
    # Create database & user
mysql (suply database admin arguments as and when needed)
+
    mysql (suply database admin arguments as and when needed)
create database mslcrm;
+
    create database mslcrm;
create user 'mslcrmuser'@'localhost' identified by 'XXXX-passowrd-XXX';
+
    create user 'mslcrmuser'@'localhost' identified by 'XXXX-passowrd-XXX';
grant all priveleges on mslcrm.* to 'mslcrmuser'@'localhost';
+
    grant all priveleges on mslcrm.* to 'mslcrmuser'@'localhost';
flush priveleges;
+
    flush priveleges;
 
+
   
# Check for issues and build database & site
+
    # Check for issues and build database & site
python manage.py check --deploy
+
    python manage.py check --deploy
python3 manage.py makemigrations
+
    python3 manage.py makemigrations
python3 manage.py migrate
+
    python3 manage.py migrate
python manage.py collectstatic
+
    python manage.py collectstatic
 
+
   
# Create temp super user
+
    # Create temp super user
python3 manage.py createsuperuser
+
    python3 manage.py createsuperuser
 
+
   
# Create apache config
+
    # Create apache config
cat > /etc/apache2/sites-available/crm.conf <<EOM
+
    cat > /etc/apache2/sites-available/crm.conf <<EOM
WSGIScriptAlias /crm /usr/local/makerspaceleiden-crm/makerspaceleiden/wsgi.py  process-group=crm
+
    WSGIScriptAlias /crm /usr/local/makerspaceleiden-crm/makerspaceleiden/wsgi.py  process-group=crm
 
+
   
WSGIDaemonProcess crm python-home=/usr/local/makerspaceleiden-crm/venv python-path=/usr/local/makerspaceleiden-crm/
+
    WSGIDaemonProcess crm python-home=/usr/local/makerspaceleiden-crm/venv python-path=/usr/local/makerspaceleiden-crm/
WSGIProcessGroup  crm  
+
    WSGIProcessGroup  crm  
 
+
   
Alias /crm-static/ /usr/local/makerspaceleiden-crm/static/
+
    Alias /crm-static/ /usr/local/makerspaceleiden-crm/static/
Alias /media/      /usr/local/makerspaceleiden-crm/var/media/
+
    Alias /media/      /usr/local/makerspaceleiden-crm/var/media/
 
+
   
<Directory /usr/local/makerspaceleiden-crm/>
+
    <Directory /usr/local/makerspaceleiden-crm/>
  <Files wsgi.py>
+
      <Files wsgi.py>
    Require all granted
+
        Require all granted
  </Files>
+
      </Files>
</Directory>
+
    </Directory>
 
+
   
<Directory /usr/local/makerspaceleiden-crm/static>
+
    <Directory /usr/local/makerspaceleiden-crm/static>
        Options None
+
            Options None
        order deny,allow
+
            order deny,allow
        allow from all
+
            allow from all
        Require all granted
+
            Require all granted
</Directory>
+
    </Directory>
 
+
   
<Directory /usr/local/makerspaceleiden-crm/var/media>
+
    <Directory /usr/local/makerspaceleiden-crm/var/media>
        Options None
+
            Options None
        order deny,allow
+
            order deny,allow
        allow from all
+
            allow from all
        Require all granted
+
            Require all granted
</Directory>
+
    </Directory>
EOM
+
    EOM
ln -s /etc/apache2/sites-available/crm.conf  /etc/apache2/sites-active/crm.conf  
+
    ln -s /etc/apache2/sites-available/crm.conf  /etc/apache2/sites-active/crm.conf  
 
+
   
# Start server
+
    # Start server
#
+
    #
apacheclt configtest
+
    apacheclt configtest
apachectl restart
+
    apachectl restart
tail -F /var/log/apache2/error.log
+
    tail -F /var/log/apache2/error.log
 
+
   
# Create the initial members/structure. Assign the trusteeds
+
    # Create the initial members/structure. Assign the trusteeds
# the super user permission; then delete the temporary admin you made.
+
    # the super user permission; then delete the temporary admin you made.

Versie van 19 jan 2019 om 22:04

On a demo/local laptop

   git clone https://github.com/dirkx/makerspaceleiden-crm.git
   cd makerspaceleiden-crm
   sh loaddemo.sh

then visit http://localhost:8000/

Prepare for restarts with

 source venv/bin/activate

and then do :

 python3 manage.py runsever

as needed

Om production -- update

 cd /usr/local/makerspaceleiden-crm
 git pull <right version>
 
 source venv/bin/activate
 python3 manage.py makemigrations
 python3 manage.py migrate

In production - setup from zero =

   cd /usr/local
   git clone https://github.com/dirkx/makerspaceleiden-crm.git
   # Create random seed
   openssl rand 128 > /etc/crm_secret_key.txt
   chmod 640 /etc/crm_secret_key.txt
   chgrp www-data /etc/crm_secret_key.txt
   
   # Allow storing of uploads in media by the suid
   # all this runs as.
   mkdir -p var/media
   chown www-data var/media
   
   # Prepare env for python and pull in the various dependencies.
   python3 -mvenv venv
   source ./venv/bin/activate
   pip3 install -r requirements
   
   # Set up the framework
   cd makerspaceleiden
   ln -s prod.py local.py
   cat > makerspaceledien/my.cnf <<EOM
   [client]
   database = mslcrm
   user = mslcrmuser
   password = XXXX-passowrd-XXX
   default-character-set = utf8
   EOM
   
   # Create database & user
   mysql (suply database admin arguments as and when needed)
   create database mslcrm;
   create user 'mslcrmuser'@'localhost' identified by 'XXXX-passowrd-XXX';
   grant all priveleges on mslcrm.* to 'mslcrmuser'@'localhost';
   flush priveleges;
   
   # Check for issues and build database & site
   python manage.py check --deploy
   python3 manage.py makemigrations
   python3 manage.py migrate
   python manage.py collectstatic
   
   # Create temp super user
   python3 manage.py createsuperuser
   
   # Create apache config
   cat > /etc/apache2/sites-available/crm.conf <<EOM
   WSGIScriptAlias /crm /usr/local/makerspaceleiden-crm/makerspaceleiden/wsgi.py  process-group=crm
   
   WSGIDaemonProcess crm python-home=/usr/local/makerspaceleiden-crm/venv python-path=/usr/local/makerspaceleiden-crm/
   WSGIProcessGroup  crm 
   
   Alias /crm-static/ /usr/local/makerspaceleiden-crm/static/
   Alias /media/      /usr/local/makerspaceleiden-crm/var/media/
   
   <Directory /usr/local/makerspaceleiden-crm/>
     <Files wsgi.py>
        Require all granted
     </Files>
   </Directory>
   
   <Directory /usr/local/makerspaceleiden-crm/static>
           Options None
           order deny,allow
           allow from all
           Require all granted
   </Directory>
   
   <Directory /usr/local/makerspaceleiden-crm/var/media>
           Options None
           order deny,allow
           allow from all
           Require all granted
   </Directory>
   EOM
   ln -s /etc/apache2/sites-available/crm.conf  /etc/apache2/sites-active/crm.conf 
   
   # Start server
   #
   apacheclt configtest
   apachectl restart
   tail -F /var/log/apache2/error.log
   
   # Create the initial members/structure. Assign the trusteeds
   # the super user permission; then delete the temporary admin you made.