summaryrefslogtreecommitdiff
path: root/app-from-scratch.sh
blob: 418686d4072ad544d4948211b484dd94b0fc9ba7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# on a debian 9 fresh VM
ssh -A intarnet@intarnet.fr

# "fork" from CHD' git repos
git config --global -e
git clone root@chd.sx:/var/git/chd_gestion
cd ~/chd_gestion/
git checkout a6104f4
git checkout -b cake36
editor app-from-scratch.sh # Adding notes progressively

# env setup
sudo apt --yes install php-cli apache2 libapache2-mod-php php-mbstring php-intl php-xml php-sqlite3 phpmyadmin mariadb-server unzip
sudo a2disconf phpmyadmin
sudo apache2 restart
sudo mkdir /var/www/intarnet.fr
sudo chown intarnet: /var/www/intarnet.fr

# composer install
wget -q https://getcomposer.org/composer.phar -O ~/bin/composer.phar
chmod +x ~/bin/composer.phar
echo 'export PATH="$PATH:~/bin"' >> ~/.bashrc
source ~/.bashrc
composer.phar --version
# Composer version 1.7-dev (006c921abde5a9fa5ec682014265e3203a0987b1) 2018-07-12 20:08:52

# cake install
cd ~/chd_gestion/
mkdir fai_gestion
yes | php ~/composer.phar create-project --prefer-dist cakephp/app fai_gestion
ln -s ~intarnet/chd_gestion/fai_gestion/bin/cake ~/bin/
cd ~/chd_gestion/fai_gestion
cake version
# 3.6.7

# cake first start (embed webserver)
cake server -p 8080
# from desktop linux :
# ssh -L 8080:localhost:8080 intarnet@intarnet.fr
# firefox http://localhost:8080/
# -> everything green except database connection
^C

# prepare for apache2 
ln -s ~intarnet/chd_gestion/fai_gestion /var/www/intarnet.fr/gestion
sudo chgrp -R www-data tmp/ logs/
sudo chmod -R ug=rwX,o=rX tmp/ logs/
# (cake bake runs with intarnet user, web served pages with www-data)
# do NOT allow www-data write elsewhere
sudo mv logs /var/log/fai_gestion
ln -s /var/log/fai_gestion logs

# apache2 vhost excerpt

# Alias "/gestion" "/var/www/intarnet.fr/gestion/webroot"
# <Directory /var/www/intarnet.fr/gestion>
#         Options None
#         AllowOverride None
#         Require all denied
# </Directory>
# <Directory /var/www/intarnet.fr/gestion/webroot>
#         Options SymLinksIfOwnerMatch
#         AllowOverride None
#
#         AuthType Basic
#         AuthName "Partie privee"
#         AuthUserFile /etc/apache2/passwords/intarnet.fr/www_priv.passwd
#         Require valid-user
#
#         SetEnv APP_DEFAULT_LOCALE fr_FR
#         SetEnv DEBUG true
#
#         RequestHeader unset Proxy
#         RewriteEngine On
#         RewriteCond %{REQUEST_FILENAME} !-f
#         RewriteRule ^ index.php [L]
# </Directory>

sudo a2enmod env headers rewrite
sudo service apache2 restart

# from desktop linux :
# firefox https://intarnet.fr/gestion/
# -> everything green except database connection

cd ~/chd_gestion/
cat fai_gestion/.gitignore
git add app-from-scratch.sh fai_gestion
git commit -m "Cake 3.6.7 fresh install"