PHP7.md 7.83 KB
Newer Older
thomas craipeau's avatar
thomas craipeau committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# installer php7 et mongo 3.6 pour dev sur ubuntu

prérequis avoir d'installer git, docker et docker-compose

### install docker
choose community edition CE
https://docs.docker.com/engine/installation/

**example install docker ubuntu**
https://docs.docker.com/engine/installation/linux/docker-ce/ubuntu/

**Post-installation steps for Linux**
https://docs.docker.com/engine/installation/linux/linux-postinstall/

### install docker-compose
thomas craipeau's avatar
thomas craipeau committed
16

thomas craipeau's avatar
thomas craipeau committed
17
18
19
https://docs.docker.com/compose/install/


thomas craipeau's avatar
thomas craipeau committed
20
21
22
23
24
25
### install start complete docker apache php7 auto script (ubuntu,docker,docker-compose,git,unzip)

installer sur la machine : ubuntu,docker,docker-compose,git,unzip


## install start complete docker apache php7
thomas craipeau's avatar
thomas craipeau committed
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
### clone du repo docker

créer un repertoire à la racine de votre user et cloner le repo docker

```bash
git clone https://gitlab.adullact.net/pixelhumain/docker.git ~/pixelhumain-php7/

cd ~/pixelhumain-php7/
```
changer de branch pour php7

```bash
git checkout php7
```

thomas craipeau's avatar
thomas craipeau committed
41
### build les services front (apache php7) et mongo (3.6)
thomas craipeau's avatar
thomas craipeau committed
42
43

créer le repertoire code/ dans le repertoire ~/pixelhumain-php7/
thomas craipeau's avatar
thomas craipeau committed
44
```sh
thomas craipeau's avatar
thomas craipeau committed
45
46
mkdir ~/pixelhumain-php7/code/
```
thomas craipeau's avatar
thomas craipeau committed
47

thomas craipeau's avatar
thomas craipeau committed
48
cette commande build le container pour le front à partir du dossier docker-front-apache
thomas craipeau's avatar
thomas craipeau committed
49
50

```sh
thomas craipeau's avatar
thomas craipeau committed
51
52
53
54
55
56
57
docker-compose -f docker-compose-apache.yml build
```


### clone des différents repo

Depuis le repertoire mkdir ~/pixelhumain-php7/code/ vous pouver cloner les différents repo
thomas craipeau's avatar
thomas craipeau committed
58
59

```sh
thomas craipeau's avatar
thomas craipeau committed
60
61
62
63
64
cd ~/pixelhumain-php7/code/

git clone https://gitlab.adullact.net/pixelhumain/pixelhumain.git pixelhumain
```

thomas craipeau's avatar
thomas craipeau committed
65
66
67
modules

```sh
thomas craipeau's avatar
thomas craipeau committed
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
mkdir modules
cd modules

git clone https://gitlab.adullact.net/pixelhumain/communecter.git communecter
git clone https://gitlab.adullact.net/pixelhumain/citizenToolkit.git citizenToolKit
git clone https://gitlab.adullact.net/pixelhumain/co2.git co2
git clone https://gitlab.adullact.net/pixelhumain/api.git api
git clone https://gitlab.adullact.net/pixelhumain/dda.git dda
git clone https://gitlab.adullact.net/pixelhumain/news.git news
git clone https://gitlab.adullact.net/pixelhumain/interop.git interop
git clone https://gitlab.adullact.net/pixelhumain/graph.git graph
git clone https://gitlab.adullact.net/pixelhumain/eco.git eco
git clone https://gitlab.adullact.net/pixelhumain/chat.git chat
git clone https://gitlab.adullact.net/pixelhumain/survey.git survey
git clone https://gitlab.adullact.net/pixelhumain/map.git map
git clone https://gitlab.adullact.net/pixelhumain/places.git places
git clone https://gitlab.adullact.net/pixelhumain/cotools.git cotools
git clone https://gitlab.adullact.net/pixelhumain/costum.git costum
```


### lancer composer depuis docker-compose
thomas craipeau's avatar
thomas craipeau committed
90
```sh
thomas craipeau's avatar
thomas craipeau committed
91
92
93
cd ~/pixelhumain-php7/
```
lancer les services
thomas craipeau's avatar
thomas craipeau committed
94
```sh
thomas craipeau's avatar
thomas craipeau committed
95
96
97
docker-compose -f docker-compose-apache.yml up -d
```
lancer sur le service front la commande pour installer les packages depuis composer
thomas craipeau's avatar
thomas craipeau committed
98
```sh
thomas craipeau's avatar
thomas craipeau committed
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
docker-compose -f docker-compose-apache.yml exec front composer config -g "secure-http" false -d /code/pixelhumain/ph

docker-compose -f docker-compose-apache.yml exec front composer install -d /code/pixelhumain/ph
```
### config mongo dans ~/pixelhumain-php7/code/pixelhumain/dbconfig.php

```sh
  cat > ~/pixelhumain-php7/code/pixelhumain/ph/protected/config/dbconfig.php <<EOF
  <?php

  \$dbconfig = array(
      'class' => 'mongoYii.EMongoClient',
      'server' => 'mongodb://mongo:27017/',
      'db' => 'pixelhumain',
  );
  \$dbconfigtest = array(
      'class' => 'mongoYii.EMongoClient',
      'server' => 'mongodb://mongo:27017/',
      'db' => 'pixelhumaintest',
  );
EOF
```
création repertoire et droit en ecriture
```
docker-compose -f docker-compose-apache.yml exec front mkdir -vp /code/pixelhumain/ph/{assets,upload,protected/runtime}

docker-compose -f docker-compose-apache.yml exec front chmod -R 777 /code/pixelhumain/ph/assets
docker-compose -f docker-compose-apache.yml exec front chmod -R 777 /code/pixelhumain/ph/upload
docker-compose -f docker-compose-apache.yml exec front chmod -R 777 /code/pixelhumain/ph/protected/runtime
```

### mongo data
```sh
docker-compose -f docker-compose-apache.yml exec -T mongo mongo mongo/pixelhumain <<EOF
db.createUser({ user: 'pixelhumain', pwd: 'pixelhumain', roles: [ { role: "readWrite", db: "pixelhumain" } ] });
EOF

docker-compose -f docker-compose-apache.yml exec -T mongo mongo mongo/pixelhumaintest <<EOF
db.createUser({ user: 'pixelhumain', pwd: 'pixelhumain', roles: [ { role: "readWrite", db: "pixelhumain" } ] });
EOF

docker-compose -f docker-compose-apache.yml exec -T mongo mongo mongo/pixelhumain <<EOF
db.lists.dropIndexes();
db.lists.remove({});
EOF

docker-compose -f docker-compose-apache.yml exec -T mongo mongoimport --host mongo --db pixelhumain --collection lists "/code/modules/co2/data/lists.json" --jsonArray

unzip "${PWD}/code/modules/co2/data/cities.json.zip" -d "${PWD}/code/modules/co2/data/"

docker-compose -f docker-compose-apache.yml exec -T mongo mongo mongo/pixelhumain <<EOF
db.cities.dropIndexes();
db.cities.remove({});
EOF


docker-compose -f docker-compose-apache.yml exec -T mongo mongoimport --host mongo --db pixelhumain --collection cities "/code/modules/co2/data/cities.json"


unzip "${PWD}/code/modules/co2/data/zones.json.zip" -d "${PWD}/code/modules/co2/data/"


docker-compose -f docker-compose-apache.yml exec -T mongo mongo mongo/pixelhumain <<EOF
db.zones.dropIndexes();
db.zones.remove({});
EOF


docker-compose -f docker-compose-apache.yml exec -T mongo mongoimport --host mongo --db pixelhumain --collection zones "/code/modules/co2/data/zones.json"


unzip ~/pixelhumain-php7/code/modules/co2/data/translate.json.zip -d ~/pixelhumain-php7/code/modules/co2/data/

docker-compose -f docker-compose-apache.yml exec -T mongo mongo mongo/pixelhumain <<EOF
db.translate.dropIndexes();
db.translate.remove({});
EOF


docker-compose -f docker-compose-apache.yml exec -T mongo mongoimport --host mongo --db pixelhumain --collection translate "/code/modules/co2/data/translate.json"

docker-compose -f docker-compose-apache.yml exec -T mongo mongo mongo/pixelhumain <<EOF
db.createCollection("applications")
db.applications.insert({     "_id" : ObjectId("59f1920bc30f30536124355d"),     "name" : "DEV Config",     "key" : "devParams",     "mangoPay" : {         "ClientId" : "communecter",         "ClientPassword" : "xxxx",         "TemporaryFolder" : "../../tmp"     } } )
db.applications.insert({     "_id" : ObjectId("59f1920bc30f30536124355e"),     "name" : "PROD Config",     "key" : "prodParams",     "mangoPay" : {         "ClientId" : "communecter",         "ClientPassword" : "xxxx",         "TemporaryFolder" : "../../tmp"     } } )
EOF


docker-compose -f docker-compose-apache.yml exec -T mongo mongo mongo/pixelhumain <<EOF
db.citoyens.dropIndexes();
db.cities.dropIndexes();
db.events.dropIndexes();
db.organizations.dropIndexes();
db.projects.dropIndexes();
EOF


docker-compose -f docker-compose-apache.yml exec -T mongo mongo mongo/pixelhumain <<EOF
db.citoyens.createIndex({"email": 1} , { unique: true });
db.cities.createIndex({"geoPosition": "2dsphere"});
db.cities.createIndex({"postalCodes.geoPosition": "2dsphere"});
db.cities.createIndex({"geoShape" : "2dsphere" });
db.cities.createIndex({"insee" : 1});
db.cities.createIndex({"region" : 1});
db.cities.createIndex({"dep" : 1});
db.cities.createIndex({"cp" : 1});
db.cities.createIndex({"country" : 1});
db.cities.createIndex({"postalCodes.name" : 1});
db.cities.createIndex({"postalCodes.postalCode" : 1});
db.events.createIndex({"geoPosition" : "2dsphere" });
db.events.createIndex({"parentId" : 1});
db.events.createIndex({"name" : 1});
db.organizations.createIndex({"geoPosition" : "2dsphere" });
db.projects.createIndex({"geoPosition" : "2dsphere" });
db.citoyens.createIndex({"geoPosition" : "2dsphere" });
EOF
thomas craipeau's avatar
update    
thomas craipeau committed
215
216
217
218
219
```

### Mongo dump 3.6 vers retsore 4.2
```bash
docker-compose -f docker-compose-apache.yml exec -T mongo mongodump --archive --gzip > all-db.archive.gz
thomas craipeau's avatar
update    
thomas craipeau committed
220
docker-compose -f docker-compose-apache.yml exec -T mongo42 mongorestore --gzip --archive < all-db.archive.gz
thomas craipeau's avatar
thomas craipeau committed
221
```