83 lines
2.6 KiB
Markdown
83 lines
2.6 KiB
Markdown
# 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 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;
|
|
```
|
|
|
|
### 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/shop/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.
|
|
```
|
|
<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>
|
|
```
|