raspberry_pi:projects:wordpress
Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| raspberry_pi:projects:wordpress [2025/02/07 08:50] – created jmbargallo | raspberry_pi:projects:wordpress [2025/02/07 09:05] (current) – jmbargallo | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | Questions | + | ====== Wordpresss ====== |
| - | Product Docs | + | |
| - | Cloud Chats | + | |
| - | CONTENTS | + | |
| - | Prerequisites | ||
| - | Step 1 — Creating a MariaDB Database and User for WordPress | ||
| - | Step 2 — Installing Additional PHP Extensions | ||
| - | Step 3 — Adjusting Apache’s Configuration to Allow for .htaccess Overrides and Rewrites | ||
| - | Step 4 — Downloading WordPress | ||
| - | Step 5 — Configuring the WordPress Directory | ||
| - | Step 6 — Completing the Installation Through the Web Interface | ||
| - | Conclusion | ||
| - | Tutorial | + | ===== Introduction ===== |
| - | How to Install WordPress with LAMP on Debian 10 | + | |
| - | Published on July 22, 2019 | + | |
| - | LAMP Stack | + | WordPress |
| - | Debian 10 | + | |
| - | | + | |
| - | authorauthorauthor | ||
| - | Mark Drake, Brian Boucheron, | + | ===== Step 1 — Creating a MariaDB Database |
| - | English | + | |
| - | How to Install | + | |
| - | Not using Debian 10? | + | |
| - | Choose a different version or distribution. | + | |
| - | Debian 10 | + | |
| - | Introduction | + | |
| - | WordPress is the most popular CMS (content management system) on the internet. It allows you to easily set up flexible blogs and websites on top of a MariaDB backend with PHP processing. WordPress has seen incredible adoption and is a great choice for getting a website up and running quickly. After setup, almost all administration can be done through the web frontend. | ||
| - | In this guide, we’ll | + | The first step that we will take is a preparatory one. WordPress requires a MySQL-based database to store and manage site and user information. We have MariaDB — a drop-in replacement for MySQL — installed already, but we need to make a database and a user for WordPress to use. |
| - | Prerequisites | + | |
| + | To get started, open up the MariaDB prompt as the root account: | ||
| + | |||
| + | sudo mariadb | ||
| + | |||
| + | Note: If you set up another account with administrative privileges when you installed and set up MariaDB, you can also log in as that user. You’ll need to do so with the following command: | ||
| + | |||
| + | mariadb -u username -p | ||
| + | |||
| + | After issuing this command, MariaDB will prompt you for the password you set for that account. | ||
| + | |||
| + | Begin by creating a new database that WordPress will control. You can call this whatever you would like but, to keep it simple for this guide, we will name it wordpress. | ||
| + | |||
| + | Create the database for WordPress by typing: | ||
| + | |||
| + | CREATE DATABASE wordpress DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci; | ||
| + | |||
| + | Note that every MySQL statement must end in a semi-colon (;). Check to make sure this is present if you are running into any issues. | ||
| + | |||
| + | Next, create a separate MySQL user account that we will use exclusively to operate | ||
| + | |||
| + | Create this account, set a password, and grant the user access to the database you just created with the following command. Remember to choose a strong password for your database user: | ||
| + | |||
| + | GRANT ALL ON wordpress.* TO ' | ||
| + | |||
| + | You now have a database and user account, each made specifically for WordPress. Run the following command to reload the grant tables so that the current | ||
| + | |||
| + | FLUSH PRIVILEGES; | ||
| + | |||
| + | Exit out of MariaDB by typing: | ||
| + | |||
| + | EXIT; | ||
| + | |||
| + | Now that you’ve configured the database and user that will be used by WordPress, you can move on to installing some PHP-related packages used by the CMS. | ||
| + | |||
| + | on to installing some PHP-related packages used by the CMS. | ||
| + | Step 2 — Installing Additional PHP Extensions | ||
| + | |||
| + | When setting up our LAMP stack, | ||
| + | |||
| + | Download and install some of the most popular PHP extensions for use with WordPress by typing: | ||
| + | |||
| + | sudo apt update | ||
| + | sudo apt install php-curl php-gd php-mbstring php-xml php-xmlrpc php-soap php-intl php-zip | ||
| + | |||
| + | Note: Each WordPress plugin has its own set of requirements. Some may require additional PHP packages to be installed. Check your plugin documentation to find its PHP requirements. If they are available, they can be installed with apt as demonstrated above. | ||
| + | |||
| + | We will restart | ||
| + | |||
| + | sudo systemctl restart apache2 | ||
| + | |||
| + | At this point, all that’s left to do before installing WordPress is to make some changes to your Apache configuration in order to allow the CMS to function smoothly. | ||
| + | |||
| + | ===== Step 3 — Adjusting Apache’s Configuration to Allow for .htaccess Overrides | ||
| + | |||
| + | With the additional | ||
| + | |||
| + | Additionally, | ||
| + | |||
| + | Note: It’s possible you are using the 000-default.conf default configuration (with / | ||
| + | |||
| + | Currently, the use of .htaccess files is disabled. WordPress and many WordPress plugins use these files extensively for in-directory tweaks to the web server’s behavior. | ||
| + | |||
| + | Open the Apache configuration file for your website. Note that if you have an existing Apache configuration file for your website, this file’s name will be different: | ||
| + | |||
| + | sudo nano / | ||
| + | |||
| + | To allow .htaccess files, you’ll need to add a Directory block pointing to your document root with an AllowOverride directive within it. Add the following block of text inside the VirtualHost block in your configuration file, being sure to use the correct web root directory: | ||
| + | / | ||
| + | |||
| + | < | ||
| + | AllowOverride All | ||
| + | </ | ||
| + | |||
| + | When you are finished, save and close the file. | ||
| + | |||
| + | Next, enable the rewrite module in order to utilize the WordPress permalink feature: | ||
| + | |||
| + | sudo a2enmod rewrite | ||
| + | |||
| + | Before implementing the changes you’ve made, check to make sure that you haven’t made any syntax errors: | ||
| + | |||
| + | sudo apache2ctl configtest | ||
| + | |||
| + | If your configuration file’s syntax is correct, you’ll see the following in your output: | ||
| + | |||
| + | Output | ||
| + | Syntax OK | ||
| + | |||
| + | If this command reports any errors, go back and check that you haven’t made any syntax errors in your configuration file. Otherwise, restart Apache to implement the changes: | ||
| + | |||
| + | sudo systemctl restart apache2 | ||
| + | |||
| + | Next, we will download and set up WordPress itself. | ||
| + | Step 4 — Downloading WordPress | ||
| + | |||
| + | Now that your server software is configured, you can download and set up WordPress. For security reasons in particular, it is always recommended to get the latest version of WordPress directly from their site. | ||
| + | |||
| + | Note: We will use curl to download WordPress, but this program may not be installed by default on your Debian server. | ||
| + | |||
| + | sudo apt install curl | ||
| + | |||
| + | Change into a writable directory and then download the compressed release by typing: | ||
| + | |||
| + | cd /tmp | ||
| + | curl -O https:// | ||
| + | |||
| + | Extract the compressed file to create the WordPress directory structure: | ||
| + | |||
| + | tar xzvf latest.tar.gz | ||
| + | |||
| + | We will move these files into our document root momentarily. Before we do, though, add a dummy .htaccess file so that this will be available for WordPress to use later. | ||
| + | |||
| + | Create the file by typing: | ||
| + | |||
| + | touch / | ||
| + | |||
| + | Then copy over the sample configuration file to the filename that WordPress actually reads: | ||
| + | |||
| + | cp / | ||
| + | |||
| + | Additionally, | ||
| + | |||
| + | mkdir / | ||
| + | |||
| + | Then, copy the entire contents of the directory into your document root. Notice that the following command includes a dot at the end of the source directory to indicate that everything within the directory should be copied, including hidden files (like the .htaccess file you created): | ||
| + | |||
| + | sudo cp -a / | ||
| + | |||
| + | With that, you’ve successfully installed WordPress onto your web server and performed some of the initial configuration steps. Next, we’ll discuss some further configuration changes that will give WordPress the privileges it needs to function as well as access to the MariaDB database and user account you created previously. | ||
| + | Step 5 — Configuring the WordPress Directory | ||
| + | |||
| + | Before we can go through the web-based setup process for WordPress, we need to adjust some items in our WordPress directory. | ||
| + | |||
| + | Start by giving ownership of all the files to the www-data user and group. This is the user that the Apache web server runs as, and Apache will need to be able to read and write WordPress files in order to serve the website and perform automatic updates. | ||
| + | |||
| + | Update the ownership with chown: | ||
| + | |||
| + | sudo chown -R www-data: | ||
| + | |||
| + | Next we will run two find commands to set the correct permissions on the WordPress directories and files: | ||
| + | |||
| + | sudo find / | ||
| + | sudo find / | ||
| + | |||
| + | These should be a reasonable permissions set to start with, although some plugins and procedures might require additional tweaks. | ||
| + | |||
| + | Following this, you will need to make some changes to the main WordPress configuration file. | ||
| + | |||
| + | When you open the file, your first objective will be to adjust some secret keys to provide some security for your installation. WordPress provides a secure generator for these values so that you do not have to try to come up with good values on your own. These are only used internally, so it won’t hurt usability to have complex, secure values here. | ||
| + | |||
| + | To grab secure values from the WordPress secret key generator, type: | ||
| + | |||
| + | curl -s https:// | ||
| + | |||
| + | You will get back unique values that look something like this: | ||
| + | |||
| + | Warning! It is important that you request unique values each time. Do NOT copy the values shown below! | ||
| + | |||
| + | define(' | ||
| + | define(' | ||
| + | define(' | ||
| + | define(' | ||
| + | define(' | ||
| + | define(' | ||
| + | define(' | ||
| + | define(' | ||
| + | |||
| + | These are configuration lines that you will paste directly into your configuration file to set secure keys. Copy the output you received to your clipboard, and then open the WordPress configuration file located in your document root: | ||
| + | |||
| + | sudo nano / | ||
| + | |||
| + | Find the section that contains the dummy values for those settings.. . . | ||
| + | |||
| + | Delete these lines and paste in the values you copied from the command line: | ||
| + | / | ||
| + | |||
| + | Next, modify the database connection settings at the top of the file. You need to adjust the database name, the database user, and the associated password that you’ve configured within MariaDB. | ||
| + | |||
| + | The other change you must make is to set the method that WordPress should use to write to the filesystem. Since we’ve given the web server permission to write where it needs to, we can explicitly set the filesystem method to “direct”. Failure to set this with our current settings would result in WordPress prompting for FTP credentials when you perform certain actions. | ||
| + | |||
| + | This setting can be added below the database connection settings, or anywhere else in the file: | ||
| + | / | ||
| + | |||
| + | Modify the values: | ||
| + | |||
| + | | ||
| + | |||
| + | /** MySQL database username */ | ||
| + | | ||
| - | In order to complete this tutorial, you will need access to a Debian 10 server. | + | /** MySQL database password */ |
| + | | ||
| - | You will need to perform the following tasks before you can start this guide: | + | |
| - | Create a sudo user on your server: We will be completing the steps in this guide using a non-root user with sudo privileges. You can create a user with sudo privileges by following our Debian 10 initial server setup guide. | + | Save and close the file when you are finished. Finally, you can finish installing |
| - | Install a LAMP stack: WordPress will need a web server, a database, | + | |
| - | Secure your site with SSL: WordPress serves dynamic content and handles user authentication and authorization. TLS/SSL is the technology that allows | + | |
| - | If you have a domain name… the easiest way to secure your site is with Let’s Encrypt, which provides free, trusted certificates. Follow our Let’s Encrypt guide for Apache to set this up. | + | |
| - | If you do not have a domain… | + | |
| + | ===== Step 6 — Completing the Installation Through the Web Interface ===== | ||
| + | Now that the server configuration is complete, we can complete the installation through the web interface. | ||
raspberry_pi/projects/wordpress.1738918232.txt.gz · Last modified: 2025/02/07 08:50 by jmbargallo
