# WordPress Wordpress on Ubuntu *** ### Setup & Install LAMP ```sh sudo apt update -qq && sudo apt upgrade -y sudo apt install -y lamp-server^ sudo apt install -y php-curl php-gd php-mbstring php-xml php-xmlrpc php-soap php-intl php-zip php-imagick wget sudo systemctl restart apache2 sudo a2enmod rewrite sudo a2enmod ssl sudo a2dissite 000-default ``` ### Config MySQL Default from the install above root has no password and is unsecure for the moment to just type `sudo mysql` then do each below and alter the usernames, password, and database names to your desire. So the example below the mysql datadase is `wpdb`, the mysql user is `wpdbuser`, and the password for that mysql user would be `changethispassword` ```sh CREATE DATABASE wpdb DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci; CREATE USER 'wpdbuser'@'%' IDENTIFIED WITH mysql_native_password BY 'changethispassword'; GRANT ALL ON shop.* TO 'wpdbuser'@'%'; FLUSH PRIVILEGES; EXIT; ``` then run `sudo mysql_secure_installation` ### Install Wordpress ```sh cd /tmp curl -O https://wordpress.org/latest.tar.gz tar xzvf latest.tar.gz touch /tmp/wordpress/.htaccess cp /tmp/wordpress/wp-config-sample.php /tmp/wordpress/wp-config.php mkdir /tmp/wordpress/wp-content/upgrade sudo mkdir /var/www/wp sudo mkdir /var/www/wp/ssl sudo mkdir /var/www/wp/html sudo cp -a /tmp/wordpress/. /var/www/wp/html sudo chown -R www-data:www-data /var/www/wp/html sudo find /var/www/wp/html/ -type d -exec chmod 750 {} \; sudo find /var/www/wp/html/ -type f -exec chmod 640 {} \; ``` ### WP Config Fix details laters ```sh curl -s https://api.wordpress.org/secret-key/1.1/salt/ sudo nano /var/www/wp/html/wp-config.php define('FS_METHOD', 'direct'); ``` ### Apache HTTPS Setup Create PEM files ```sh cd /var/www/wp/ssl openssl req -newkey rsa:2048 -new -nodes -x509 -days 3650 -keyout key.pem -out cert.pem ``` Create apache2 file enter `sudo nano /etc/apache2/sites-available/wp.conf` then Copy+Paste the following then CTRL+X then Y then Enter to save. ``` ServerName shop.sarimoko.com ServerAdmin travis@sarimoko.com DocumentRoot /var/www/wp/html/ SSLEngine on SSLCertificateFile /var/www/wp/ssl/cert.pem SSLCertificateKeyFile /var/www/wp/ssl/key.pem AllowOverride All ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined SSLOptions +StdEnvVars SSLOptions +StdEnvVars ``` Then run ```sh sudo a2ensite wp sudo service apache2 reload ```