Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
install wordpress on openstack vm
# install lamp server with PHP 7.2
yum -y install centos-release-scl.noarch
yum -y install rh-php72 rh-php72-php rh-php72-php-gd rh-php72-php-mbstring rh-php72-php-intl rh-php72-php-pecl-apcu rh-php72-php-fpm
yum -y install httpd mariadb-server svn rh-php72-php-mysqlnd
# disable loading the old PHP Apache modules by changing their names
mv /etc/httpd/conf.d/php.conf /etc/httpd/conf.d/
mv /etc/httpd/conf.modules.d/10-php.conf /etc/httpd/conf.modules.d/
ln -s /opt/rh/rh-php72/root/usr/bin/php /usr/bin/php
# symlink the PHP 7.2 Apache modules into place:
ln -s /opt/rh/httpd24/root/etc/httpd/conf.d/rh-php72-php.conf /etc/httpd/conf.d/
ln -s /opt/rh/httpd24/root/etc/httpd/conf.modules.d/15-rh-php72-php.conf /etc/httpd/conf.modules.d/
ln -s /opt/rh/httpd24/root/etc/httpd/modules/ /etc/httpd/modules/
#start services
service httpd start
service mariadb start
chkconfig mariadb on
chkconfig httpd on
# update the upload file size
SRC="upload_max_filesize = 2M"; DST="upload_max_filesize = 64M"; sed -i "s/$SRC/$DST/g" /etc/php.ini
service httpd restart
# download and copy wordpress to web folder
mkdir /wpinstall
cd /wpinstall
tar xzvf latest.tar.gz
rsync -avP /wpinstall/wordpress/ /var/www/html/
touch /var/www/html/.htaccess
mkdir /var/www/html/wp-content/uploads
chown -R apache:apache /var/www/html/*
# configure wordpress
cd /var/www/html
yes | cp wp-config-sample.php $CONFIG_FILE
chown apache:apache $CONFIG_FILE
#generate password
PASSWORD=$(date +%s|sha256sum|base64|head -c 32)
SRC="'WP_DEBUG', false"; DST="'WP_DEBUG', true"; sed -i "s/$SRC/$DST/g" $CONFIG_FILE
SRC="'DB_NAME', 'database_name_here'"; DST="'DB_NAME', 'wordpress'"; sed -i "s/$SRC/$DST/g" $CONFIG_FILE
SRC="'DB_USER', 'username_here'"; DST="'DB_USER', 'wordpressuser'"; sed -i "s/$SRC/$DST/g" $CONFIG_FILE
SRC="'DB_PASSWORD', 'password_here'"; DST="'DB_PASSWORD', '$PASSWORD'"; sed -i "s/$SRC/$DST/g" $CONFIG_FILE
SRC="'WP_DEBUG'"; DST="define( 'SCRIPT_DEBUG', true );"; grep -q "$DST" $CONFIG_FILE || sed -i "/$SRC/a$DST" $CONFIG_FILE
#update authentication keys and salts.
SALT=$(curl -L
SRC="define('AUTH_KEY'"; DST=$(echo $SALT|cat|grep -o define\(\'AUTH_KEY\'.\\{70\\}); sed -i "/$SRC/c$DST" $CONFIG_FILE
SRC="define('SECURE_AUTH_KEY'"; DST=$(echo $SALT|cat|grep -o define\(\'SECURE_AUTH_KEY\'.\\{70\\}); sed -i "/$SRC/c$DST" $CONFIG_FILE
SRC="define('LOGGED_IN_KEY'"; DST=$(echo $SALT|cat|grep -o define\(\'LOGGED_IN_KEY\'.\\{70\\}); sed -i "/$SRC/c$DST" $CONFIG_FILE
SRC="define('NONCE_KEY'"; DST=$(echo $SALT|cat|grep -o define\(\'NONCE_KEY\'.\\{70\\}); sed -i "/$SRC/c$DST" $CONFIG_FILE
SRC="define('AUTH_SALT'"; DST=$(echo $SALT|cat|grep -o define\(\'AUTH_SALT\'.\\{70\\}); sed -i "/$SRC/c$DST" $CONFIG_FILE
SRC="define('SECURE_AUTH_SALT'"; DST=$(echo $SALT|cat|grep -o define\(\'SECURE_AUTH_SALT\'.\\{70\\}); sed -i "/$SRC/c$DST" $CONFIG_FILE
SRC="define('LOGGED_IN_SALT'"; DST=$(echo $SALT|cat|grep -o define\(\'LOGGED_IN_SALT\'.\\{70\\}); sed -i "/$SRC/c$DST" $CONFIG_FILE
SRC="define('NONCE_SALT'"; DST=$(echo $SALT|cat|grep -o define\(\'NONCE_SALT\'.\\{70\\}); sed -i "/$SRC/c$DST" $CONFIG_FILE
# create wordpress database
mysql -u root -e "CREATE DATABASE wordpress;"
mysql -u root -e "CREATE USER wordpressuser@localhost IDENTIFIED BY '$PASSWORD';"
mysql -u root -e "GRANT ALL PRIVILEGES ON wordpress.* TO wordpressuser@localhost IDENTIFIED BY '$PASSWORD';"
mysql -u root -e "FLUSH PRIVILEGES;"
#install cert
yum -y install certbot-apache
certbot --apache -d $SERVERNAME --email=$EMAIL --agree-tos --non-interactive
# install phpUnit
cd /wpinstall
chmod +x phpunit-old.phar
mv phpunit-old.phar /usr/local/bin/phpunit --force
# install wp-cli
chmod +x wp-cli.phar
mv wp-cli.phar /usr/local/bin/wp --force
# install PHP_CodeSniffer
chmod +x phpcs.phar
mv phpcs.phar /usr/local/bin/phpcs --force
chmod +x phpcbf.phar
mv phpcbf.phar /usr/local/bin/phpcbf --force
# configure WordPress Coding Standards
git clone -b master wpcs
phpcs --config-set installed_paths ~/wpinstall/wpcs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment