WordPress

OPTIONAL: Create LXD container

lxc launch ubuntu-minimal:lts wordpress
lxc shell wordpress

Ubuntu package
https://ubuntu.com/tutorials/install-and-configure-wordpress#1-overview

sudo apt update
sudo apt install -y apache2 ghostscript libapache2-mod-php mysql-server php php-bcmath php-curl php-imagick php-intl php-json php-mbstring php-mysql php-xml php-zip apg vim
 
rm /var/www/html/index.html
 
sudo chown www-data: /var/www/html
curl https://wordpress.org/latest.tar.gz | sudo -u www-data tar zx -C /var/www/html
 
 
cat<<EOF>/etc/apache2/sites-available/wordpress.conf
    <VirtualHost *:80>
        DocumentRoot /var/www/html/wordpress
        <Directory /var/www/html/wordpress>
            Options FollowSymLinks
            AllowOverride Limit Options FileInfo
            DirectoryIndex index.php
            Require all granted
        </Directory>
        <Directory /var/www/html/wordpress/wp-content>
            Options FollowSymLinks
            Require all granted
        </Directory>
    </VirtualHost>
EOF
 
sudo a2ensite wordpress
sudo a2enmod rewrite
sudo a2dissite 000-default
sudo service apache2 reload
 
 
DB_PASS=$(apg -m 16 -n1)
WP_PHASE=$(apg -m 32 -n1)
 
 
cat <<EOF> /tmp/wordpress.sql
CREATE DATABASE wordpress;
CREATE USER wordpress@localhost IDENTIFIED BY '${DB_PASS}';
GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,ALTER ON wordpress.* TO wordpress@localhost;
FLUSH PRIVILEGES;
EOF
 
cat /tmp/wordpress.sql | sudo mysql --defaults-extra-file=/etc/mysql/debian.cnf
 
 
cd /var/www/html/wordpress
sudo -u www-data cp wp-config-sample.php wp-config.php
 
sudo -u www-data sed -i 's/database_name_here/wordpress/' wp-config.php
sudo -u www-data sed -i 's/username_here/wordpress/' wp-config.php
sudo -u www-data sed -i "s/password_here/${DB_PASS}/" wp-config.php
sudo -u www-data sed -i "s/put your unique phrase here/${WP_PHASE}/" wp-config.php
 
# OPTIONAL: enforce https
sed -i '2i\$_SERVER['HTTPS'] = 'on';\' wp-config.php
 
# Access the server under:
http://your_server/wordpress

OLD

cat <<EOF> /etc/wordpress/config-localhost.php
<?php
define('DB_NAME', 'wordpress');
define('DB_USER', 'wordpress');
define('DB_PASSWORD', 'yourpasswordhere');
define('DB_HOST', 'localhost');
define('WP_CONTENT_DIR', '/usr/share/wordpress/wp-content');
?>
EOF
 
ln -s /etc/wordpress/config-localhost.php /etc/wordpress/config-10.0.129.230.php

# Links
https://help.ubuntu.com/lts/serverguide/wordpress.html

Manual installation

apt-get install -y apache2 mysql-server php5-mysql wget vi php5
# libapache2-mod-auth-mysql

cd /var/www/html
wget http://wordpress.org/latest.tar.gz
tar -xzvf latest.tar.gz

# create database
echo "CREATE DATABASE wordpress;" | mysql -u root -proot
echo "CREATE USER wordpressuser@localhost;" | mysql -u root -proot
echo "SET PASSWORD FOR wordpressuser@localhost= PASSWORD('password');" | mysql -u root -proot
echo "GRANT ALL PRIVILEGES ON wordpress.* TO wordpressuser@localhost IDENTIFIED BY 'password';" | mysql -u root -proot
echo "FLUSH PRIVILEGES;" | mysql -u root -proot

cp wordpress/wp-config-sample.php wordpress/wp-config.php

sed -i 's|database_name_here|wordpress|' wordpress/wp-config.php
sed -i 's|username_here|wordpressuser|' wordpress/wp-config.php
sed -i 's|password_here|password|' wordpress/wp-config.php

vi wordpress/wp-config.php

#define('WP_ALLOW_REPAIR', true);
#define('DB_CHARSET', 'utf8');

define('DB_CHARSET', 'latin1');
define('FS_METHOD', 'direct');
define( 'WP_MEMORY_LIMIT', '96M' );
define( 'WP_MAX_MEMORY_LIMIT', '256M' );

chown www-data:www-data /var/www/html/wordpress/ -R

http://10.0.3.173/wordpress/wp-admin/install.php

http://10.0.3.173/wordpress/wp-admin/plugin-install.php
Jigoshop

# show errors
# wp-config.php
define('WP_DEBUG', true);

# configuration
UPDATE wp_options
SET option_value = REPLACE(option_value, 'new.example.com', 'www.example.com')
WHERE option_value LIKE '%new.example.com%'

#UPDATE wp_options SET `option_value` = 'you@example.com' WHERE `wp_options`.`option_id` = 5;
#UPDATE wp_users SET user_email = 'you@example.com' WHERE ID = 1;

# reset password
UPDATE wp_users SET user_pass = MD5('new_pass') WHERE ID = 1;

# wordpress extract script
# wi.php
<?php
system("tar -xzf wordpress-4.4.2.tar.gz");
?>

# fix URL
UPDATE wp_posts
SET post_content = REPLACE(post_content, 'new.example.com', 'www.example.com')
WHERE post_content LIKE '%new.example.com%'

UPDATE wp_posts
SET guid = REPLACE(guid, 'new.example.com', 'www.example.com')
WHERE guid LIKE '%new.example.com%'

# set file permissions
system("find . -type d -exec chmod 755 {} \;");
system("find . -type f -exec chmod 644 {} \;");

Force https

cat wp-config.php 
$_SERVER['HTTPS'] = 'on';

Links
https://wiki.debian.org/WordPress
https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-on-ubuntu-12-04
https://www.digitalocean.com/community/tutorials/initial-server-setup-with-ubuntu-12-04
https://wiki.debian.org/WordPress
http://wpde.org/e-commerce/
http://steellounge.de/
https://www.jigoshop.com/getting-started-guide/
https://blog.programster.org/using-wordpress-with-a-reverse-proxy-or-load-balancer