raspberry_pi:projects:wordpress
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| raspberry_pi:projects:wordpress [2025/02/07 08:55] – jmbargallo | raspberry_pi:projects:wordpress [2025/02/07 09:05] (current) – jmbargallo | ||
|---|---|---|---|
| Line 45: | Line 45: | ||
| 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. | 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, we only required a very minimal set of extensions in order to get PHP to communicate with MariaDB. WordPress and many of its plugins leverage additional PHP extensions. | ||
| + | |||
| + | 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 Apache to load these new extensions in the next section. If you are returning here to install additional plugins, you can restart Apache now by typing: | ||
| + | |||
| + | 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 and Rewrites ===== | ||
| + | |||
| + | With the additional PHP extensions installed and ready for use, the next thing to do is to make a few changes to your Apache configuration. Based on the prerequisite tutorials, you should have a configuration file for your site in the / | ||
| + | |||
| + | 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. To install it, run: | ||
| + | |||
| + | 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 */ | ||
| + | | ||
| + | |||
| + | /** MySQL database password */ | ||
| + | | ||
| + | |||
| + | | ||
| + | |||
| + | Save and close the file when you are finished. Finally, you can finish installing and configuring WordPress by accessing it through your web browser. | ||
| + | |||
| + | ===== 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.1738918513.txt.gz · Last modified: 2025/02/07 08:55 by jmbargallo
