server.apache
- Installer Apache sur le serveur
- Configurer apache
- Redémarrer apache
- Tester la config
- Pour engager la bonne marche des htaccess (et donc des url_rewrite) :
- Mysql
- PHPMyAdmin
- Send email with Apache
- Virtual hosts
- Editer le fichier hosts
- Redémarrer apache
- Editer un fichier avec nano
- Lire un fichier avec cat
- Add MySQL to terminal shell in Mac OS X
- J’ai un problème au démarrage d’Apache
- Pas à pas : installation d’un nouveau sous-domaine sécurisé avec Let’s Encrypt + certbot##
- rewrite non-www to www
- Connaitre les modules installés
- Changer version de PHP
Installer Apache sur le serveur
https://www.codeflow.site/fr/article/how-to-install-the-apache-web-server-on-debian-10
Configurer apache
/etc/apache2/sites-available Copier, puis adapter le contenu (exemple) lien symbolique vers sites-enabled (exemple)
cd /etc/apache2/sites-enabled && sudo ln -s ../sites-available/madon-ssl-voir.conf madon-ssl-voir.conf
Redémarrer apache
sudo apache2ctl restart
# ou
sudo systemctl restart apache2
https://github.com/area17/subfolio/archive/master.zip
Consulter les logs lors d’un problème de mod_rewrite, e.g. (erreur 500) https://stackoverflow.com/questions/5641618/how-to-enable-loglevel-debug-on-apache2-server
get apache service status
$ sudo systemctl status apache2
Tester la config
apache configtest
Pour engager la bonne marche des htaccess (et donc des url_rewrite) :
Si ça ne fonctionne pas, tout se passe dans le httpd.conf
Aller voir si le module mod_rewrite.so
est activé (ligne décommentée)
Puis, aller voir les autorisations au niveau du dossier de départ. Dans mon
cas, j’ai dû passer AllowOverride
de None
à All
. Résultat final :
<Directory "/Library/WebServer/www">
Options FollowSymLinks Multiviews
MultiviewsMatch Any
AllowOverride All
Require all granted
</Directory>
Redémarrer Apache
sudo apachectl restart
Mysql
Version téléchargée > mysql-5.7.13-osx10.11-x86_64
2016-06-03T09:01:27.438915Z 1 [Note] A temporary password is generated for root@localhost: j6V;!ntr(Sgp
Nouveau password -> xxdEeddde
Start MySQL server
sudo /usr/local/mysql/support-files/mysql.server start
Stop MySQL server
sudo /usr/local/mysql/support-files/mysql.server stop
Restart MySQL server
sudo /usr/local/mysql/support-files/mysql.server restart
Ou alors…
PHPMyAdmin
In /Library/WebServer/www/phpmyadmin
Problème de droits d’accès (impossible en faisant http://localhost/phpmyadmin) ?
sudo chmod 755 /Library/WebServer/www/phpmyadmin/config.inc.php
Send email with Apache
http://stackoverflow.com/questions/21149535/send-mail-from-local-apache-server
Virtual hosts
http://jason.pureconcepts.net/2015/10/install-apache-php-mysql-mac-os-x-el-capitan/
Editer le hhtpd.conf de /etc/apache2
dans le terminal
sudo /Applications/TextEdit.app/Contents/MacOS/TextEdit /etc/apache2/httpd.conf
Editer le fichier hosts
dans le terminal
sudo /Applications/TextEdit.app/Contents/MacOS/TextEdit/etc/hosts
Redémarrer apache
sudo /usr/sbin/apachectl restart
Editer un fichier avec nano
nano {file}
Lire un fichier avec cat
cat {file}
Add MySQL to terminal shell in Mac OS X
- http://www.gigoblog.com/2011/03/13/add-mysql-to-terminal-shell-in-mac-os-x/
- http://www.commentcamarche.net/faq/12341-phpmyadmin-1045-access-denied-for-user-root-localhost
J’ai un problème au démarrage d’Apache
Error: (98)Address already in use: make_sock: could not bind to address 0.0.0.0:80
Vérifier ce qui utilise le port 80
ss -plnt sport eq :80
Dans mon cas, c’était nginx
qui tournait en même temps : sudo service nginx stop
Pas à pas : installation d’un nouveau sous-domaine sécurisé avec Let’s Encrypt + certbot##
créer le répertoire
sudo mkdir /var/www/subdomain.domain.fr
sudo echo "<h1>Salut</h1>" > index.html # pour tester que tout fonctionne, ensuite
Puis
cd etc/apache2/sites-available
touch subdomain.conf && {nano-emacs-vi-whatever} subdomain.conf
<VirtualHost *:80>
ServerAdmin bonjour@thomasguesnon.fr
DocumentRoot /var/www/subdomain.domain.fr
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
RewriteEngine on
RewriteCond %{SERVER_NAME} =thomasguesnon.net
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
le script de certification a besoin de savoir que c’est nous qui contrôlons l’emplacement, donc il va d’abord essayer d’y accéder en non-sécurisé (port 80)
cd ../sites-enabled
lien symbolique dans sites-enabled
ln -s /etc/apache2/sites-available/subdomain.conf subdomain.conf
On redémarre Apache
sudo service apache2 restart
chez provider pointer vers ip
subdomain 3600 IN A 86.229.179.47
attendre un peu que ça se propage
aller voir sur subdomain.domain.conf
Si tout se passe bien, on lance la certif du site
sudo certbot -d subdomain.fr
Ça mouline. À la fin, certbot
doit nous afficher les clés générées
SSLCertificateFile /etc/letsencrypt/live/subdomain.domain.fr/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/subdomain.domain.fr/privkey.pem
On retourne dans /etc/apache2/sites-available/subdomain.conf
{nano-emacs-vi-whatever} subdomain.conf
<VirtualHost *:80>
ServerAdmin bonjour@thomasguesnon.fr
ServerName subdomain.domain.fr
DocumentRoot /var/www/subdomain.domain.fr
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
RewriteEngine on
RewriteCond %{SERVER_NAME} =thomasguesnon.net
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerAdmin bonjour@thomasguesnon.fr
ServerName subdomain.domain.fr
DocumentRoot /var/www/subdomain.domain.fr
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
RewriteEngine on
# Là, on vient coller nos clés obtenues à l'étape précédente
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/subdomain.domain.fr/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/subdomain.domain.fr/privkey.pem
</VirtualHost>
</IfModule>
Et normalement, https://subdomain.domain.fr doit fonctionner normalement.
rewrite non-www to www
<VirtualHost *:80>
ServerName example.com
Redirect permanent / http://www.example.com/
</VirtualHost>
<VirtualHost *:80>
ServerName www.example.com
# real server configuration
</VirtualHost>
Avec https, il faut joindre le certificat pour les deux entrées
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerName example.com
Redirect permanent / https://www.example.com/
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificatFile /path/to/fullchain.pem
SSLCertificatKeyFile /path/to/privkey.pem
</VirtualHost>
<VirtualHost *:443>
ServerName www.example.com
# real server configuration
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificatFile /path/to/fullchain.pem
SSLCertificatKeyFile /path/to/privkey.pem
</VirtualHost>
</IfModule>
Très bonne ressource qui récapitule tout :
Connaitre les modules installés
apache2ctl -M
Installer un module
Activer/désactiver un module
sudo a2dismod {module}
sudo service apache2 restart
sudo a2enmod {module}
sudo service apache2 restart