2021-07-05 04:38:25 +00:00
# WordPress
2021-07-21 02:28:48 +00:00
Wordpress on Ubuntu
***
### Setup & Install LAMP
```sh
sudo apt update -qq & & sudo apt upgrade -y
sudo apt install -y lamp-server^
2021-07-21 06:36:39 +00:00
sudo apt install -y php-curl php-gd php-mbstring php-xml php-xmlrpc php-soap php-intl php-zip php-imagick wget
2021-07-21 02:28:48 +00:00
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;
```
2021-07-21 02:34:43 +00:00
then run `sudo mysql_secure_installation`
2021-07-21 02:28:48 +00:00
### 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/
2021-07-25 17:17:43 +00:00
sudo nano /var/www/wp/html/wp-config.php
2021-07-21 02:28:48 +00:00
define('FS_METHOD', 'direct');
2021-07-21 02:32:12 +00:00
```
### 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.
```
< IfModule mod_ssl . c >
< VirtualHost _default_ :443 >
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
< Directory / var / www / wp / html / >
AllowOverride All
< / Directory >
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
< FilesMatch " \.( cgi | shtml | phtml | php )$" >
SSLOptions +StdEnvVars
< / FilesMatch >
< Directory / usr / lib / cgi-bin >
SSLOptions +StdEnvVars
< / Directory >
< / VirtualHost >
< / IfModule >
```
2021-07-21 02:34:43 +00:00
Then run
```sh
sudo a2ensite wp
sudo service apache2 reload
```