V1
This commit is contained in:
		
						commit
						3e0338ca5f
					
				
							
								
								
									
										37
									
								
								README.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								README.md
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,37 @@
 | 
			
		||||
# WP-Deploy
 | 
			
		||||
 | 
			
		||||
[](https://svgshare.com/i/Zhy.svg) [](https://github.com/ellerbrock/open-source-badges/) [](http://perso.crans.org/besson/LICENSE.html) [](https://github.com/Naereen/badges/) [](https://shields.io/)
 | 
			
		||||
 | 
			
		||||
Installation automatique de Wordpress. 
 | 
			
		||||
 | 
			
		||||
## Pour commencer
 | 
			
		||||
 | 
			
		||||
Entrez ici les instructions pour bien débuter avec votre projet...
 | 
			
		||||
 | 
			
		||||
### Pré-requis
 | 
			
		||||
 | 
			
		||||
Ce qu'il est requis pour faire fonctionner le script
 | 
			
		||||
 | 
			
		||||
- Rocky Linux 9
 | 
			
		||||
- Apache
 | 
			
		||||
- MariaDB
 | 
			
		||||
- WP-cli
 | 
			
		||||
 | 
			
		||||
### Installation
 | 
			
		||||
 | 
			
		||||
Pré-requis Wordpress : 
 | 
			
		||||
- sudo dnf install httpd tar wget mariadb-server php php-zip php-intl php-mysqlnd php-dom php-simplexml php-xml php-xmlreader php-curl php-exif php-ftp php-gd php-iconv php-json php-mbstring php-posix php-sockets php-tokenizer
 | 
			
		||||
- systemctl enable --now httpd mariadb php-fpm
 | 
			
		||||
- mysql_secure_installation  
 | 
			
		||||
Faire une configuration simple
 | 
			
		||||
 | 
			
		||||
Installation de wp-cli :
 | 
			
		||||
- wget https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
 | 
			
		||||
- chmod +x wp-cli.phar
 | 
			
		||||
- mv wp-cli.phar /usr/local/bin/wp
 | 
			
		||||
 | 
			
		||||
ENJOY il suffit de lancer le script avec ./deploy.sh
 | 
			
		||||
 | 
			
		||||
## Auteurs
 | 
			
		||||
* **Quentin Leduc ** _alias_ [@kiu](https://git.netwaze.fr/kiu)
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										125
									
								
								deploy.sh
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										125
									
								
								deploy.sh
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,125 @@
 | 
			
		||||
#!/bin/bash
 | 
			
		||||
 | 
			
		||||
# Vérifier si le script est lancé avec les droits sudo
 | 
			
		||||
if [[ "$EUID" -ne 0 ]]; then
 | 
			
		||||
  # Afficher un message d'avertissement
 | 
			
		||||
  echo "Veuillez lancer ce script avec les droits sudo"
 | 
			
		||||
  # Quitter le script avec un code d'erreur
 | 
			
		||||
  exit 1
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
# Génération du mot de passe
 | 
			
		||||
charset='0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!"#$%&'\''()*+,-./:;<=>?@[\]^_`{|}~'
 | 
			
		||||
password=$(openssl rand -base64 30 | tr -dc "$charset" | fold -w 30)
 | 
			
		||||
 | 
			
		||||
# Question pour la création du site internet
 | 
			
		||||
read -rp "Nom du site internet : " -e NAME_WEBSITE
 | 
			
		||||
read -rp "Utilisateur de la BDD : " -e USER_BDD
 | 
			
		||||
read -rp "Mot de passe de la BDD : " -e -i "${password}" PWD_BDD
 | 
			
		||||
read -rp "Prefix que vous voulez utilisez : " -e PREFIX
 | 
			
		||||
read -rp "Compte a utiliser pour wordpress : " -e LOGIN
 | 
			
		||||
read -sp "Mot de passe  : " -e PWD_USER
 | 
			
		||||
read -rp "Mail pour le compte administrateur : " -e MAIL
 | 
			
		||||
read -rp "URL du site internet sans le http/s: " -e URL
 | 
			
		||||
 | 
			
		||||
# Création de la base de donnée
 | 
			
		||||
mysql -e "CREATE DATABASE $NAME_WEBSITE;"
 | 
			
		||||
mysql -e "CREATE USER '$USER_BDD'@'localhost' IDENTIFIED BY '$PWD_BDD';"
 | 
			
		||||
mysql -e "GRANT ALL ON $NAME_WEBSITE.* TO '$USER_BDD'@'localhost';"
 | 
			
		||||
mysql -e "FLUSH PRIVILEGES;"
 | 
			
		||||
 | 
			
		||||
# Téléchargement et installation du Wordpress
 | 
			
		||||
cd /var/www/html && wget https://fr.wordpress.org/latest-fr_FR.tar.gz > /dev/null 2>&1
 | 
			
		||||
tar -xvzf latest-fr_FR.tar.gz -C /var/www/html/ > /dev/null 2>&1
 | 
			
		||||
mkdir $NAME_WEBSITE
 | 
			
		||||
cp -r wordpress/* /var/www/html/$NAME_WEBSITE
 | 
			
		||||
chown -R apache:apache /var/www/html/$NAME_WEBSITE
 | 
			
		||||
rm -rf wordpress latest-fr_FR.tar.gz
 | 
			
		||||
 | 
			
		||||
# Création des clées de chiffrement du Wordpress
 | 
			
		||||
AUTH_KEY=$(openssl rand -hex 64)
 | 
			
		||||
SECURE_AUTH_KEY=$(openssl rand -hex 64)
 | 
			
		||||
LOGGED_IN_KEY=$(openssl rand -hex 64)
 | 
			
		||||
NONCE_KEY=$(openssl rand -hex 64)
 | 
			
		||||
AUTH_SALT=$(openssl rand -hex 64)
 | 
			
		||||
SECURE_AUTH_SALT=$(openssl rand -hex 64)
 | 
			
		||||
LOGGED_IN_SALT=$(openssl rand -hex 64)
 | 
			
		||||
NONCE_SALT=$(openssl rand -hex 64)
 | 
			
		||||
 | 
			
		||||
# Création du fichier wp-config.php
 | 
			
		||||
echo "<?php
 | 
			
		||||
 | 
			
		||||
/** Nom de la base de données de WordPress. */
 | 
			
		||||
define( 'DB_NAME', '$NAME_WEBSITE' );
 | 
			
		||||
 | 
			
		||||
/** Utilisateur de la base de données MySQL. */
 | 
			
		||||
define( 'DB_USER', '$USER_BDD' );
 | 
			
		||||
 | 
			
		||||
/** Mot de passe de la base de données MySQL. */
 | 
			
		||||
define( 'DB_PASSWORD', '$PWD_BDD' );
 | 
			
		||||
 | 
			
		||||
/** Adresse de l’hébergement MySQL. */
 | 
			
		||||
define( 'DB_HOST', 'localhost' );
 | 
			
		||||
 | 
			
		||||
/** Jeu de caractères à utiliser par la base de données lors de la 
 | 
			
		||||
création des tables. */
 | 
			
		||||
define( 'DB_CHARSET', 'utf8' );
 | 
			
		||||
 | 
			
		||||
define( 'DB_COLLATE', '' );
 | 
			
		||||
 | 
			
		||||
define( 'AUTH_KEY',         '$AUTH_KEY' );
 | 
			
		||||
define( 'SECURE_AUTH_KEY',  '$SECURE_AUTH_KEY' );
 | 
			
		||||
define( 'LOGGED_IN_KEY',    '$LOGGED_IN_KEY' );
 | 
			
		||||
define( 'NONCE_KEY',        '$NONCE_KEY' );
 | 
			
		||||
define( 'AUTH_SALT',        '$AUTH_SALT' );
 | 
			
		||||
define( 'SECURE_AUTH_SALT', '$SECURE_AUTH_SALT' );
 | 
			
		||||
define( 'LOGGED_IN_SALT',   '$LOGGED_IN_SALT' );
 | 
			
		||||
define( 'NONCE_SALT',       '$NONCE_SALT' );
 | 
			
		||||
 | 
			
		||||
"'$table_prefix'" = '$PREFIX';
 | 
			
		||||
 | 
			
		||||
define( 'WP_DEBUG', false );
 | 
			
		||||
 | 
			
		||||
if ( ! defined( 'ABSPATH' ) )
 | 
			
		||||
  define( 'ABSPATH', dirname( __FILE__ ) . '/' );
 | 
			
		||||
 | 
			
		||||
require_once( ABSPATH . 'wp-settings.php' );" > /var/www/html/$NAME_WEBSITE/wp-config.php
 | 
			
		||||
 | 
			
		||||
# Création du fichier HTTPD
 | 
			
		||||
echo "
 | 
			
		||||
<VirtualHost *:80>
 | 
			
		||||
    ServerName $URL
 | 
			
		||||
    ServerAlias www.$URL
 | 
			
		||||
    ServerAdmin $MAIL
 | 
			
		||||
    DocumentRoot /var/www/html/$NAME_WEBSITE
 | 
			
		||||
 | 
			
		||||
    <Directory /var/www/html/$NAME_WEBSITE>
 | 
			
		||||
        Options -Indexes +FollowSymLinks
 | 
			
		||||
        AllowOverride All
 | 
			
		||||
    </Directory>
 | 
			
		||||
 | 
			
		||||
    ErrorLog /var/log/httpd/$NAME_WEBSITE-error.log
 | 
			
		||||
    CustomLog /var/log/httpd/$NAME_WEBSITE-access.log combined
 | 
			
		||||
</VirtualHost> " > /etc/httpd/conf.d/$NAME_WEBSITE.conf
 | 
			
		||||
 | 
			
		||||
# Création des fichiers LOG
 | 
			
		||||
touch /var/log/httpd/$NAME_WEBSITE-access.log
 | 
			
		||||
touch /var/log/httpd/$NAME_WEBSITE-error.log
 | 
			
		||||
 | 
			
		||||
# Automatisation de l'install wordpress
 | 
			
		||||
cd /var/www/html/$NAME_WEBSITE
 | 
			
		||||
/usr/local/bin/wp core install --url=https://$URL/ --title=$NAME_WEBSITE --admin_user=$LOGIN --admin_password=$PWD_USER --admin_email=$MAIL --allow-root > /dev/null 2>&1
 | 
			
		||||
 | 
			
		||||
# Mettre le HTTPS dans le fichier de conf de WordPress
 | 
			
		||||
read -p "Voulez-vous mettre le HTTPS ? (o/n) : " -e -i o answer
 | 
			
		||||
if [[ $answer == "o" ]]; then
 | 
			
		||||
    echo "<?php
 | 
			
		||||
    if (isset(\$_SERVER['HTTP_X_FORWARDED_PROTO']) && \$_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') {
 | 
			
		||||
        \$_SERVER['HTTPS'] = 'on';
 | 
			
		||||
    }" >> /var/www/html/\$NAME_WEBSITE/wp-config.php
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
# RESTART HTTPD SERVICE
 | 
			
		||||
systemctl restart httpd
 | 
			
		||||
 | 
			
		||||
echo "le site internet $NAME_WEBSITE est créer" 
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user