This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionLast revisionBoth sides next revision | ||
computing:selfhostedwp [2023/06/29 05:22] – oemb1905 | computing:selfhostedwp [2023/07/09 20:20] – oemb1905 | ||
---|---|---|---|
Line 13: | Line 13: | ||
This tutorial is for setting up a self-hosted WordPress instance on Debian GNU/Linux. This tutorial assumes you have some familiarity setting up a LAMP stack. If you need help with that, check out [[https:// | This tutorial is for setting up a self-hosted WordPress instance on Debian GNU/Linux. This tutorial assumes you have some familiarity setting up a LAMP stack. If you need help with that, check out [[https:// | ||
- | sudo apt install apache2 mariadb-server php8.x php-common php-cgi php-cli php-zip php-mysql php-mbstring php-intl php-fpm php-curl php-gd php-imagick php-xml php-xmlrpc php-soap php-opcache php-apcu php-bcmath memcached wget unzip | + | sudo apt install apache2 mariadb-server php8.2 php-common php-cgi php-cli php-zip php-mysql php-mbstring php-intl php-fpm php-curl php-gd php-imagick php-xml php-xmlrpc php-soap php-opcache php-apcu php-bcmath memcached wget unzip |
| | ||
- | Sometimes dpkg can choose which version of php you want and it's not always the version you want. In those cases, you can explicitly specify the version you need as follows: | + | Sometimes dpkg can choose which version of php you want and it's not always the version you want. In those cases, you can explicitly specify the version you need. Some packages are only available |
| | ||
- | sudo apt-get install php8.2-{common, | + | sudo apt-get install php8.2-{common, |
| | ||
Apache2 will set up a 000-default.conf automatically and your host should now resolve. Be sure to set up TLS with certbot. Here's my preferred method: | Apache2 will set up a 000-default.conf automatically and your host should now resolve. Be sure to set up TLS with certbot. Here's my preferred method: | ||
Line 28: | Line 28: | ||
Once you have the LAMP stack setup and TLS properly configured, it's time to make some decisions on your php handler and your apache2 multi-processing module (mpm). There' | Once you have the LAMP stack setup and TLS properly configured, it's time to make some decisions on your php handler and your apache2 multi-processing module (mpm). There' | ||
| | ||
- | sudo apt remove libapache2-mod-php --purge | + | sudo apt remove libapache2-mod-php* --purge |
+ | sudo apt install php8.2-fpm php8.2-cgi | ||
sudo a2enmod ssl | sudo a2enmod ssl | ||
sudo a2enmod headers | sudo a2enmod headers | ||
Line 97: | Line 98: | ||
Let's now shell into our instance and set up WordPress. | Let's now shell into our instance and set up WordPress. | ||
- | ssh root@wordpress.com | + | ssh root@site1.com |
- | cd ~/ | + | |
- | mkdir wpdownload | + | |
- | cd wpdownload | + | |
curl -O https:// | curl -O https:// | ||
tar xzvf latest.tar.gz | tar xzvf latest.tar.gz | ||
- | | + | |
- | sudo chmod 640 ~/Downloads/ | + | |
- | cp ~/Downloads/ | + | |
- | | + | |
Okay, we will need the files and directories I created once we get it running. | Okay, we will need the files and directories I created once we get it running. | ||
sudo mv ~/ | sudo mv ~/ | ||
- | Now, let's set up permissions and ownership: | + | Now, create proper |
- | sudo chown -R www-data: | + | sudo chown -R www-data: |
sudo find / | sudo find / | ||
sudo chmod 755 / | sudo chmod 755 / | ||
Line 126: | Line 121: | ||
<Replace the example salts with those you just downloaded using copy/ | <Replace the example salts with those you just downloaded using copy/ | ||
| | ||
- | Let's also add the following line to the '' | + | Sometimes, for reasons I am not sure about, WordPress does not allow users direct uploading. If/when that happens, |
sudo nano / | sudo nano / | ||
< | < | ||
- | Let's now visit site1.com in a web browser. Enter the credentials that you created for the database above. Choose the settings you prefer and set up an admin account and record your credentials securely. You should now have a proper WordPress site! | + | Let's now visit site1.com in a web browser. Enter the credentials that you created for the database above. Choose the settings you prefer and set up an admin account and record your credentials securely. You should now have a proper WordPress site! Now that you have a WordPress, check the SiteHealth tab and follow its advice |
- | + | ||
- | Optimizing WP is a different matter, for caching | + | |
apt install memcached | apt install memcached | ||
nano / | nano / | ||
+ | < | ||
a2enmod cache | a2enmod cache | ||
- | + | | |
- | Put this snippet under ''# | + | |
- | | + | |
- | sudo systemctl restart proftpd.service | + | |
- | Optimizing | + | After isntalling memcached |
- | + | ||
- | apt install memcached | + | |
- | nano / | + | |
- | a2enmod cache | + | |
- | a2enmod expires | + | |
< | < | ||
Line 162: | Line 150: | ||
</ | </ | ||
- | Enable re-writes: | ||
- | |||
- | a2enmod rewrite | ||
< | < | ||
RewriteEngine On | RewriteEngine On | ||
Line 178: | Line 163: | ||
</ | </ | ||
- | Enable headers: | ||
- | |||
- | a2enmod headers | ||
< | < | ||
Header always set X-Content-Type-Options " | Header always set X-Content-Type-Options " | ||
Line 211: | Line 193: | ||
sudo apt install proftpd ftp ftp-ssl | sudo apt install proftpd ftp ftp-ssl | ||
+ | sudo a2enmod tls | ||
cd / | cd / | ||
sudo openssl req -new -x509 -days 7305 -nodes -out ftpd-rsa.pem -keyout ftpd-rsa-key.pem | sudo openssl req -new -x509 -days 7305 -nodes -out ftpd-rsa.pem -keyout ftpd-rsa-key.pem | ||
sudo nano / | sudo nano / | ||
- | | + | |
| | ||
+ | Next, enter the TLS module in tls.conf underneath ''# | ||
+ | |||
+ | sudo nano / | ||
< | < | ||
| | ||
Line 228: | Line 214: | ||
| | ||
</ | </ | ||
+ | sudo systemctl restart proftpd.service | ||
| | ||
- | If you need more than one WordPress site, for example, site1.wordpress.com, site2.wordpress.com, etc., then you might be interested in setting up a [[https:// | + | Refresh WordPress and it should see the sftp server and allow you to make changes that way. Note: The sftp server is public and anyone can access this with proper credentials even if it not for WordPress so use a proper password and make sure your TLS configuration is working. Your instance should now be pretty solid. The only other thing you might want is more than one WordPress site subdomain, for example, site1.cooldomain.com, site2.cooldomain.com, etc. If that's the case, then hop on over to my [[https:// |
- | --- // | + | --- // |