Table des matières

Wordpress

https://wiki.debian.org/WordPress

Pour wordpress, a renseigner dans keepass mysql/wpuser

export PMYDBNAME="nom_db_wordpress"
export PMYDBUSER="nom_wpuser"
export PMYDBPW="phrase_de_passe"

FQDN du site

export HOTNAMEWP="www"
export DOMAINWP="monsite.com"
export FQDNWP="$HOTNAMEWP.$DOMAINWP"
echo "FQDN du serveur : $FQDNWP"

Installation

apt-get update
apt-get install wordpress curl apache2 mysql-server

Nouveau mot de passe du superutilisateur de MySQL : renseigner le mot de passe root mysql (mysql/root) et le mettre dans le fichier keepass

Hôte apache2

cat << 'EOF' > /etc/apache2/sites-available/wordpress
 
Alias /wp/wp-content /var/lib/wordpress/wp-content
Alias /wp /usr/share/wordpress
<Directory /usr/share/wordpress>
  Options FollowSymLinks
  AllowOverride Limit Options FileInfo
  DirectoryIndex index.php
  Order allow,deny
  Allow from all
</Directory>
<Directory /var/lib/wordpress/wp-content>
  Options FollowSymLinks
  Order allow,deny
  Allow from all
</Directory>
 
EOF
 
chmod 644 /etc/apache2/sites-available/wordpress.conf
a2ensite wordpress
service apache2 stop
service apache2 start

Config wordpress

echo "<?php" > /etc/wordpress/config-default.php
echo "define('DB_NAME', '$PMYDBNAME');" >> /etc/wordpress/config-default.php
echo "define('DB_USER', '$PMYDBUSER');" >> /etc/wordpress/config-default.php
echo "define('DB_PASSWORD', '$PMYDBPW');" >> /etc/wordpress/config-default.php
echo "define('DB_HOST', 'localhost');" >> /etc/wordpress/config-default.php
echo "define('WP_CONTENT_DIR', '/var/lib/wordpress/wp-content');" >> /etc/wordpress/config-default.php
echo "define('FS_METHOD', 'direct');" >> /etc/wordpress/config-default.php
echo "?>" >> /etc/wordpress/config-default.php
chmod 644 /etc/wordpress/config-default.php

Initialisation tables mysql

echo "CREATE DATABASE $PMYDBNAME;" > /root/tmp_mysql_wordpress.sql
echo "GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,ALTER" >> /root/tmp_mysql_wordpress.sql
echo "ON $PMYDBNAME.*" >> /root/tmp_mysql_wordpress.sql
echo "TO $PMYDBUSER@localhost" >> /root/tmp_mysql_wordpress.sql
echo "IDENTIFIED BY '$PMYDBPW';" >> /root/tmp_mysql_wordpress.sql
echo "FLUSH PRIVILEGES;" >> /root/tmp_mysql_wordpress.sql
cat /root/tmp_mysql_wordpress.sql | mysql --defaults-extra-file=/etc/mysql/debian.cnf
rm /root/tmp_mysql_wordpress.sql

Installation interne worpress

echo "http://$FQDNWP/wp/wp-admin/install.php"
# ===> http://FQDN/wp/wp-admin/install.php
# entrer l'utilisateur admin : nom_adminwp, le renseigner dans keepass (wordpress/nom_adminwp)
# aller jusqu'au login mais NE PAS SE LOGGUER (si c'est fait, se délogguer)
 
mv /etc/wordpress/config-default.php /etc/wordpress/config-$DOMAINWP.php
chmod 644 /etc/wordpress/config-$DOMAINWP.php

Gestion des themes et plugins

chown -R www-data:www-data /var/lib/wordpress/wp-content
mkdir /root/tmpwp
cp -aRL /var/lib/wordpress/wp-content/themes/* /root/tmpwp
rm /var/lib/wordpress/wp-content/themes/*
mv /root/tmpwp/* /var/lib/wordpress/wp-content/themes
cp -aRL /var/lib/wordpress/wp-content/plugins/* /root/tmpwp
rm /var/lib/wordpress/wp-content/plugins/*
mv /root/tmpwp/* /var/lib/wordpress/wp-content/plugins
rmdir /root/tmpwp
chown -R www-data:www-data /var/lib/wordpress/wp-content
 
mv /usr/share/wordpress/wp-content{,-orig}
cp -ar /usr/share/wordpress/* /var/lib/wordpress
chown -R www-data:www-data /var/lib/wordpress/
mv /usr/share/wordpress/wp-content-orig /usr/share/wordpress/wp-content

Hôte apache2

cat << 'EOF' > /etc/apache2/sites-available/wordpress.conf
Alias /wp /usr/share/wordpress/
<Directory /usr/share/wordpress>
  Options FollowSymLinks
  AllowOverride Limit Options FileInfo
  DirectoryIndex index.php
  Order allow,deny
  Allow from all
</Directory>
  <Directory /var/lib/wordpress/wp-content>
  Options FollowSymLinks
  Order allow,deny
  Allow from all
</Directory>
EOF
chmod 644 /etc/apache2/sites-available/wordpress.conf
service apache2 stop
service apache2 start

Désactiver tous les plugins wordpress

cd /root
export DATE=`date +%Y%m%d-%H%M%S`
wget http://wordpress.org/latest.tar.gz
tar cvzf /root/wordpress_$DATE.tgz   /var/lib/wordpress
tar -zxvf latest.tar.gz -C /var/lib/ wordpress/wp-admin
tar -zxvf latest.tar.gz -C /var/lib/ wordpress/wp-includes
tar -zxvf latest.tar.gz -C /var/lib/ wordpress/wp-content
tar --wildcards -zxvf latest.tar.gz -C /var/lib/ 'wordpress/*.php'
rm latest.tar.gz
chown -R www-data:www-data /var/lib/wordpress/

# Ctrl+F5 sur Wordpress, autoriser le rechargement/mise à jour de la base de données # réactiver les plugins

Aller sur wordpress, mettre à jour (wordpress, plugins, thèmes)