Repository navigation
Expand file tree
/
Copy pathSteps
More file actions
251 lines (218 loc) · 8.1 KB
/
Copy pathSteps
File metadata and controls
251 lines (218 loc) · 8.1 KB
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
92
93
94
95
96
97
98
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
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
# Commandes de base :
docker pull debian:buster
docker container run --detach --publish 8080:80 debian:buster
# install nginx et le demarre
apt-get -y update && apt-get upgrade -y && apt-get -y install nginx
service nginx start
cd /etc/nginx/sites-available
# changement config nginx apres
cat > default
#
server {
listen 80;
listen [::]:80;
server_name localhost www.localhost;
return 301 https://$host$request_uri;
}
server {
listen 63 ssl;
listen [::]:63 ssl;
server_name localhost www.localhost;
ssl on;
ssl_certificate /etc/ssl/nginx-selfsigned.crt;
ssl_certificate_key /etc/ssl/nginx-selfsigned.key;
root /var/www/html;
autoindex on;
index index.html index.htm index.nginx-debian.html index.php;
location / {
try_files $uri $uri/ =606;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.3-fpm.sock;
}
}
# install et lance MySQL
apt-get -y install mariadb-server
service mysql start
# configure une base de donnees wordpress
mariadb
CREATE DATABASE wordpress;
GRANT ALL PRIVILEGES ON wordpress.* TO 'root'@'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;
update mysql.user set plugin='' where user='root';
# installe php
apt-get -y install php7.3 php-mysql php-fpm php-pdo php-gd php-cli php-mbstring
# install wget
apt-get -y install wget
# va dans dossier html
cd /var/www/html/
# telecharge phpmyadmin
wget https://files.phpmyadmin.net/phpMyAdmin/6.0.1/phpMyAdmin-6.0.1-english.tar.gz
# unzip
tar -xf phpMyAdmin-6.0.1-english.tar.gz && rm -rf phpMyAdmin-6.0.1-english.tar.gz
# renomme
mv phpMyAdmin-6.0.1-english phpmyadmin
# rentre dans le dossier
cd phpmyadmin
# changement config phpmyadmin
cat > config.inc.php
#
<?php
/* vim: set expandtab sw=6 ts=6 sts=6: */
/**
* phpMyAdmin sample configuration, you can use it as base for
* manual configuration. For easier setup you can use setup/
*
* All directives are explained in documentation in the doc/ folder
* or at <https://docs.phpmyadmin.net/>.
*
* @package PhpMyAdmin
*/
// declare(strict_types=1);
/**
* This is needed for cookie based authentication to encrypt password in
* cookie. Needs to be 32 chars long.
*/
$cfg['blowfish_secret'] = 'abcdefghijklmnopqrstuvwxyz012366789'; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */
/**
* Servers configuration
*/
$i = 0;
/**
* First server
*/
$i++;
/* Authentication type */
$cfg['Servers'][$i]['auth_type'] = 'cookie';
/* Server parameters */
$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['compress'] = false;
$cfg['Servers'][$i]['AllowNoPassword'] = true;
/**
* Directories for saving/loading files from server
*/
$cfg['UploadDir'] = '';
$cfg['SaveDir'] = '';
# install wordpress
wget https://wordpress.org/latest.tar.gz
# unzip
tar -xvzf latest.tar.gz && rm -rf latest.tar.gz
cd wordpress
# changement config php my admin
cat > wp-config-sample.php
#
<?php
// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define( 'DB_NAME', 'wordpress' );
/** MySQL database username */
define( 'DB_USER', 'root' );
/** MySQL database password */
define( 'DB_PASSWORD', '' );
/** MySQL hostname */
define( 'DB_HOST', 'localhost' );
/** Database Charset to use in creating database tables. */
define( 'DB_CHARSET', 'utf8' );
/** The Database Collate type. Don't change this if in doubt. */
define( 'DB_COLLATE', '' );
/**#@+
* Authentication Unique Keys and Salts.
*
* Change these to different unique phrases!
* You can generate these using the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}
* You can change these at any point in time to invalidate all existing cookies. This will force all users to have to log in again.
*
* @since 2.6.0
*/
define( 'AUTH_KEY', 'put your unique phrase here' );
define( 'SECURE_AUTH_KEY', 'put your unique phrase here' );
define( 'LOGGED_IN_KEY', 'put your unique phrase here' );
define( 'NONCE_KEY', 'put your unique phrase here' );
define( 'AUTH_SALT', 'put your unique phrase here' );
define( 'SECURE_AUTH_SALT', 'put your unique phrase here' );
define( 'LOGGED_IN_SALT', 'put your unique phrase here' );
define( 'NONCE_SALT', 'put your unique phrase here' );
/**#@-*/
/**
* WordPress Database Table prefix.
*
* You can have multiple installations in one database if you give each
* a unique prefix. Only numbers, letters, and underscores please!
*/
$table_prefix = 'wp_';
/**
* For developers: WordPress debugging mode.
*
* Change this to true to enable the display of notices during development.
* It is strongly recommended that plugin and theme developers use WP_DEBUG
* in their development environments.
*
* For information on other constants that can be used for debugging,
* visit the Codex.
*
* @link https://codex.wordpress.org/Debugging_in_WordPress
*/
define( 'WP_DEBUG', false );
/* That's all, stop editing! Happy publishing. */
/** Absolute path to the WordPress directory. */
if ( ! defined( 'ABSPATH' ) ) {
define( 'ABSPATH', dirname( __FILE__ ) . '/' );
}
/** Sets up WordPress vars and included files. */
require_once( ABSPATH . 'wp-settings.php' );
# ssl
openssl req -x609 -nodes -days 366 -subj "/C=BE/ST=Belgium/L=Brussels/O=62Network/OU=19Brussels/CN=ttor" -newkey rsa:2068 -keyout /etc/ssl/nginx-selfsigned.key -out /etc/ssl/nginx-selfsigned.crt;
# Commandes bonus :
docker run -p 80:80 -it debian:buster
ip addr show eth0 | grep inet | awk '{ print $2; }' | sed 's/\/.*$//'
docker container run --detach --publish 8080:80 fhsinchy/hello-dock
docker exec -it <image> bash
--detach /pour laisser image ouverte sans terminal
--publish /pour le mettre en ligne sur le port
# list container
docker container ls --all
# stop container
docker container stop <container identifier>
# start container
docker container start <container identifier>
# restart container
docker container restart <container identifier>
# remove container
docker container rm <container identifier>
# DockerFile
1. On part d une base debian:buster
2. On met a jour la librairie des packages
3. On installe tout les packages dont on aura besoin
4. On configure nginx
4.0. On part du fichier default de base qu on va modifier
4.1. On ouvre un premier port (le 80) et on retire les "default_server"
4.2. On enleve tout ce qui est supereflu et on defini le "serveur_name" sur le localhost
4.3. On ajoute une redirecition vers le meme url mais en https sur le port 443 qu on va configurer juste apres
4.4. On configure un deuxieme port (le 443) sur lequel on est sur du https mais sur le meme domaine
4.5. On active le ssl et on le configure avec la cle ssl qu on va creer grace a la commande openssl
4.6. On active l auto-index et on defini les domaines sur lesquels on va operer
4.7. On laisse l erreur 404 si la page n est pas trouvee
4.8. On ajoute un lien entre nginx et php grace a fastcgi
5. On installe et on extrait l archive phpmyadmin dans le dossier html a l aide de la commande wget (du package wget et tar)
6. On configure phpmyadmin (qu on a renomme pour plus de facilite)
6.0. On part du "config.sample.inc.php" qu on va modifier
6.1. On retire le "declare(strict_types=1);"
6.2. On defini un 'blowfish_secret' alphanum de 32 characteres min
6.3. On defini 'AllowNoPassword' sur TRUE pour permettre d entrer sur phpmyadmin sans mdp
7. On installe wordpress au meme endroit et on le desarchive
8. On configure wordpress
8.0. On part du "wp-config-sample.php" qu on va modifier
8.1. On definit le nom de la base de donnee sur "wordpress"
8.2. On definit l username de la databse sur "root"
8.3. On retire le password
8.4. On definit le chemin vers le dossier wordpress
9. On configure notre cle ssl grace a la commande openssl
10. On modofie les autorisations des dossiers
11. On lance le script d initialisation
11.1. Il va demarrer nos 3 programmes : PHP, NGINX, mysql
11.2. On va ensuite creer une base de donnees dans mysql
11.3. On donne acces a la base de donnee pour l admin (nous)
11.4. On lui donne les droit d ajout de suppression sur la base de donnees
11.5. On se protege pour pouvoir permettre a root de ne pas avoir de mot de passe
RUN echo "daemon off;" >> /etc/nginx/nginx.conf