├── .gitattributes ├── Dockerfile ├── README.md └── src ├── config.inc.php ├── nginx-host-conf ├── start.sh ├── wordpress.sql └── wordpress.tar.gz /.gitattributes: -------------------------------------------------------------------------------- 1 | * linguist-language=Dockerfile 2 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM debian:buster 2 | MAINTAINER Matteo Le Floch 3 | COPY src/wordpress.sql ./root/ 4 | COPY src/nginx-host-conf ./root/ 5 | COPY src/wordpress.tar.gz ./root/ 6 | COPY src/config.inc.php ./root/ 7 | COPY src/start.sh ./ 8 | CMD bash start.sh && tail -f /dev/null 9 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ft_server DOCUMENTATION EN COURS DE REDACTION 2 | FT_SERVER project at 42 school Paris 3 | 4 | # Comment faire ft_server 5 | 6 | Pour faire le projet ft_server, je me suis servie des ressource suivante : 7 | 8 | Comment installer un serveur LEMP [https://www.linuxbabe.com/debian/install-lemp-stack-debian-10-buster] 9 | Installer PHPMYADMIN [https://www.itzgeek.com/how-tos/linux/debian/how-to-install-phpmyadmin-with-nginx-on-debian-10.html] 10 | 11 | # ATTENTION 12 | Certaine commande ne sont pas disponible/installer sur notre version de debian buster tel que : 13 | 14 | La commande pour redemarer un service est : 15 | ``` 16 | systemctl restart nginx 17 | ``` 18 | Remplacer par 19 | ``` 20 | service nginx restart 21 | ``` 22 | Dans une bonne partie des tuto trouver sur internet vous allez retrouver la commande 23 | ``` 24 | ufw 25 | ``` 26 | UFW est un pare-feux, il n'est pas installer d'origine avec debian donc pas besoin de s'en preocuper 27 | 28 | # Liste de Tips 29 | 1. Authoriser l'utilisateur root a acceder a la base de donnee via phpmyadmin 30 | Dermarer le terminal sql avec la commande ```mysql``` 31 | Effectuer ces requettes SQL 32 | ``` 33 | update mysql.user set plugin = 'mysql_native_password' where user='root'; 34 | ``` 35 | 36 | 2. Authoriser la connexion phpmyadmin sans mot de passe 37 | Creer un fichier de configuration nommer ``` config.inc.php``` a l'aide du template ```config.template.inc.php``` situer a la racine de phpmyadmin 38 | Remplacer 39 | ``` 40 | L33$cfg['Servers'][$i]['AllowNoPassword'] = false; 41 | ``` 42 | Par 43 | ``` 44 | L33$cfg['Servers'][$i]['AllowNoPassword'] = true; 45 | ``` 46 | -------------------------------------------------------------------------------- /src/config.inc.php: -------------------------------------------------------------------------------- 1 | . 9 | * 10 | * @package PhpMyAdmin 11 | */ 12 | 13 | /** 14 | * This is needed for cookie based authentication to encrypt password in 15 | * cookie. Needs to be 32 chars long. 16 | */ 17 | $cfg['blowfish_secret'] = ''; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */ 18 | 19 | /** 20 | * Servers configuration 21 | */ 22 | $i = 0; 23 | 24 | /** 25 | * First server 26 | */ 27 | $i++; 28 | /* Authentication type */ 29 | $cfg['Servers'][$i]['auth_type'] = 'cookie'; 30 | /* Server parameters */ 31 | $cfg['Servers'][$i]['host'] = 'localhost'; 32 | $cfg['Servers'][$i]['compress'] = false; 33 | $cfg['Servers'][$i]['AllowNoPassword'] = true; 34 | 35 | /** 36 | * phpMyAdmin configuration storage settings. 37 | */ 38 | 39 | /* User used to manipulate with storage */ 40 | // $cfg['Servers'][$i]['controlhost'] = ''; 41 | // $cfg['Servers'][$i]['controlport'] = ''; 42 | // $cfg['Servers'][$i]['controluser'] = 'pma'; 43 | // $cfg['Servers'][$i]['controlpass'] = 'pmapass'; 44 | 45 | /* Storage database and tables */ 46 | // $cfg['Servers'][$i]['pmadb'] = 'phpmyadmin'; 47 | // $cfg['Servers'][$i]['bookmarktable'] = 'pma__bookmark'; 48 | // $cfg['Servers'][$i]['relation'] = 'pma__relation'; 49 | // $cfg['Servers'][$i]['table_info'] = 'pma__table_info'; 50 | // $cfg['Servers'][$i]['table_coords'] = 'pma__table_coords'; 51 | // $cfg['Servers'][$i]['pdf_pages'] = 'pma__pdf_pages'; 52 | // $cfg['Servers'][$i]['column_info'] = 'pma__column_info'; 53 | // $cfg['Servers'][$i]['history'] = 'pma__history'; 54 | // $cfg['Servers'][$i]['table_uiprefs'] = 'pma__table_uiprefs'; 55 | // $cfg['Servers'][$i]['tracking'] = 'pma__tracking'; 56 | // $cfg['Servers'][$i]['userconfig'] = 'pma__userconfig'; 57 | // $cfg['Servers'][$i]['recent'] = 'pma__recent'; 58 | // $cfg['Servers'][$i]['favorite'] = 'pma__favorite'; 59 | // $cfg['Servers'][$i]['users'] = 'pma__users'; 60 | // $cfg['Servers'][$i]['usergroups'] = 'pma__usergroups'; 61 | // $cfg['Servers'][$i]['navigationhiding'] = 'pma__navigationhiding'; 62 | // $cfg['Servers'][$i]['savedsearches'] = 'pma__savedsearches'; 63 | // $cfg['Servers'][$i]['central_columns'] = 'pma__central_columns'; 64 | // $cfg['Servers'][$i]['designer_settings'] = 'pma__designer_settings'; 65 | // $cfg['Servers'][$i]['export_templates'] = 'pma__export_templates'; 66 | 67 | /** 68 | * End of servers configuration 69 | */ 70 | 71 | /** 72 | * Directories for saving/loading files from server 73 | */ 74 | $cfg['UploadDir'] = ''; 75 | $cfg['SaveDir'] = ''; 76 | 77 | /** 78 | * Whether to display icons or text or both icons and text in table row 79 | * action segment. Value can be either of 'icons', 'text' or 'both'. 80 | * default = 'both' 81 | */ 82 | //$cfg['RowActionType'] = 'icons'; 83 | 84 | /** 85 | * Defines whether a user should be displayed a "show all (records)" 86 | * button in browse mode or not. 87 | * default = false 88 | */ 89 | //$cfg['ShowAll'] = true; 90 | 91 | /** 92 | * Number of rows displayed when browsing a result set. If the result 93 | * set contains more rows, "Previous" and "Next". 94 | * Possible values: 25, 50, 100, 250, 500 95 | * default = 25 96 | */ 97 | //$cfg['MaxRows'] = 50; 98 | 99 | /** 100 | * Disallow editing of binary fields 101 | * valid values are: 102 | * false allow editing 103 | * 'blob' allow editing except for BLOB fields 104 | * 'noblob' disallow editing except for BLOB fields 105 | * 'all' disallow editing 106 | * default = 'blob' 107 | */ 108 | //$cfg['ProtectBinary'] = false; 109 | 110 | /** 111 | * Default language to use, if not browser-defined or user-defined 112 | * (you find all languages in the locale folder) 113 | * uncomment the desired line: 114 | * default = 'en' 115 | */ 116 | //$cfg['DefaultLang'] = 'en'; 117 | //$cfg['DefaultLang'] = 'de'; 118 | 119 | /** 120 | * How many columns should be used for table display of a database? 121 | * (a value larger than 1 results in some information being hidden) 122 | * default = 1 123 | */ 124 | //$cfg['PropertiesNumColumns'] = 2; 125 | 126 | /** 127 | * Set to true if you want DB-based query history.If false, this utilizes 128 | * JS-routines to display query history (lost by window close) 129 | * 130 | * This requires configuration storage enabled, see above. 131 | * default = false 132 | */ 133 | //$cfg['QueryHistoryDB'] = true; 134 | 135 | /** 136 | * When using DB-based query history, how many entries should be kept? 137 | * default = 25 138 | */ 139 | //$cfg['QueryHistoryMax'] = 100; 140 | 141 | /** 142 | * Whether or not to query the user before sending the error report to 143 | * the phpMyAdmin team when a JavaScript error occurs 144 | * 145 | * Available options 146 | * ('ask' | 'always' | 'never') 147 | * default = 'ask' 148 | */ 149 | //$cfg['SendErrorReports'] = 'always'; 150 | 151 | /** 152 | * You can find more configuration options in the documentation 153 | * in the doc/ folder or at . 154 | */ 155 | -------------------------------------------------------------------------------- /src/nginx-host-conf: -------------------------------------------------------------------------------- 1 | server { 2 | listen 80; 3 | listen [::]:80; 4 | server_name localhost www.localhost; 5 | return 301 https://$server_name$request_uri; 6 | } 7 | 8 | server{ 9 | 10 | listen 443 ssl ; 11 | listen [::]:443 ssl ; 12 | # 13 | ssl_certificate /root/mkcert/localhost.pem; 14 | ssl_certificate_key /root/mkcert/localhost-key.pem; 15 | 16 | root /var/www/localhost; 17 | 18 | index index.html index.htm index.nginx-debian.html index.php; 19 | 20 | server_name localhost www.localhost; 21 | 22 | location / { 23 | try_files $uri $uri/ =404; 24 | } 25 | 26 | location ~ \.php$ { 27 | include snippets/fastcgi-php.conf; 28 | fastcgi_pass unix:/run/php/php7.3-fpm.sock; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/start.sh: -------------------------------------------------------------------------------- 1 | #UPDATE & INSTALL PACKAGES 2 | apt-get update 3 | apt-get upgrade -y 4 | apt-get -y install mariadb-server 5 | apt-get -y install wget 6 | apt -y install php-{mbstring,zip,gd,xml,pear,gettext,cli,fpm,cgi} 7 | apt-get -y install php-mysql 8 | apt-get install -y libnss3-tools 9 | apt-get -y install nginx 10 | 11 | #NGINX SETUP 12 | cd 13 | mkdir -p /var/www/localhost 14 | cp /root/nginx-host-conf /etc/nginx/sites-available/localhost 15 | ln -s /etc/nginx/sites-available/localhost /etc/nginx/sites-enabled/ 16 | 17 | #SLL SETUP 18 | mkdir ~/mkcert && \ 19 | cd ~/mkcert && \ 20 | wget https://github.com/FiloSottile/mkcert/releases/download/v1.1.2/mkcert-v1.1.2-linux-amd64 && \ 21 | mv mkcert-v1.1.2-linux-amd64 mkcert && \ 22 | chmod +x mkcert 23 | ./mkcert -install 24 | ./mkcert localhost 25 | 26 | #DATABASE SETUP 27 | service mysql start 28 | echo "CREATE DATABASE wordpress;" | mysql -u root 29 | echo "GRANT ALL PRIVILEGES ON wordpress.* TO 'root'@'localhost';" | mysql -u root 30 | echo "FLUSH PRIVILEGES;" | mysql -u root 31 | echo "update mysql.user set plugin = 'mysql_native_password' where user='root';" | mysql -u root 32 | cd 33 | mysql wordpress -u root --password= < wordpress.sql 34 | 35 | #WORDPRESS INSTALL 36 | cd 37 | cp wordpress.tar.gz /var/www/localhost/ 38 | cd /var/www/localhost/ 39 | tar -xf wordpress.tar.gz 40 | rm wordpress.tar.gz 41 | 42 | #PHPMYADMIN INSTALL 43 | cd 44 | wget https://files.phpmyadmin.net/phpMyAdmin/4.9.0.1/phpMyAdmin-4.9.0.1-english.tar.gz 45 | mkdir /var/www/localhost/phpmyadmin 46 | tar xzf phpMyAdmin-4.9.0.1-english.tar.gz --strip-components=1 -C /var/www/localhost/phpmyadmin 47 | cp /root/config.inc.php /var/www/localhost/phpmyadmin/ 48 | 49 | #ALLOW NGINX USER 50 | chown -R www-data:www-data /var/www/* 51 | chmod -R 755 /var/www/* 52 | 53 | #SERVICE STARTER 54 | service mysql restart 55 | /etc/init.d/php7.3-fpm start 56 | service nginx restart 57 | -------------------------------------------------------------------------------- /src/wordpress.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matteoolefloch/ft_server/3f25d5331917956385d4ca3f25c0cf8da4e45587/src/wordpress.tar.gz --------------------------------------------------------------------------------