Skip to main content

Installing WordPress on OpenSUSE

This is a continuation of our journey into the world of content management systems with WordPress, the most popular platform for creating websites and blogs. In this lesson, we'll walk through the process of installing WordPress on an OpenSUSE server. OpenSUSE, known for its robustness and flexibility, provides an excellent foundation for hosting a WordPress site. This tutorial will equip you with the knowledge to get your WordPress site up and running on OpenSUSE.

Introduction

WordPress is a free and open-source content management system (CMS) that powers a significant portion of the web. It's renowned for its ease of use, extensive customization options, and a vibrant community of users and developers. When paired with OpenSUSE, a stable and secure Linux distribution, you have a powerful combination for hosting websites of any scale.

Before we dive into the installation process, let's ensure we have a clear understanding of the prerequisites and the environment we'll be working in.

Prerequisites

  • A server running OpenSUSE (Leap or Tumbleweed).
  • Root access or a user with sudo privileges.
  • A basic understanding of the Linux command line.
  • A registered domain name (optional but recommended for a production environment).

Step 1: Updating the System

First things first, let's update our OpenSUSE system to ensure all our packages are up to date. This is crucial for security and compatibility.

sudo zypper update

Step 2: Installing the LAMP Stack

WordPress requires a LAMP stack (Linux, Apache, MySQL, PHP) to operate. OpenSUSE makes it easy to install these components.

Apache Web Server

sudo zypper install apache2

Start and enable the Apache service:.

sudo systemctl start apache2
sudo systemctl enable apache2

MySQL Database Server

sudo zypper install mysql

Secure your MySQL installation:.

sudo systemctl start mysql
sudo systemctl enable mysql
sudo mysql_secure_installation

Follow the prompts to set a root password, remove anonymous users, disallow root login remotely, remove the test database, and reload privilege tables.

PHP and Required Extensions

sudo zypper install php7 php7-mysql apache2-mod_php7

After installation, you may need to enable mod_rewrite for URL rewriting in Apache:.

sudo a2enmod rewrite

Step 3: Configuring Apache and PHP

Edit the Apache configuration to adjust the DirectoryIndex and AllowOverride settings:.

sudo nano /etc/apache2/httpd.conf

Make sure the following lines are present or add them:.

DirectoryIndex index.php index.html
<Directory "/srv/www/htdocs">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>

Restart Apache to apply the changes:.

sudo systemctl restart apache2

Step 4: Creating a MySQL Database for WordPress

Log in to MySQL:.

mysql -u root -p

Create a database and user for WordPress:.

CREATE DATABASE wordpressdb;
CREATE USER 'wordpressuser'@'localhost' IDENTIFIED BY 'your_strong_password';
GRANT ALL PRIVILEGES ON wordpressdb.* TO 'wordpressuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;

Replace your_strong_password with a secure password.

Step 5: Downloading and Installing WordPress

Download the latest WordPress package:.

cd /srv/www/htdocs
sudo wget https://wordpress.org/latest.tar.gz

Extract the files:.

sudo tar xzf latest.tar.gz

Move the WordPress files to the web root directory:.

sudo mv wordpress/* /srv/www/htdocs
sudo chown -R wwwrun:www /srv/www/htdocs

Step 6: Configuring WordPress

Rename the wp-config-sample.php file to wp-config.php:.

cd /srv/www/htdocs
sudo cp wp-config-sample.php wp-config.php

Edit the wp-config.php file to enter your database details:.

sudo nano wp-config.php

Replace the database name, user, and password with the ones you created earlier:.

// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'wordpressdb');

/** MySQL database username */
define('DB_USER', 'wordpressuser');

/** MySQL database password */
define('DB_PASSWORD', 'your_strong_password');

/** MySQL hostname */
define('DB_HOST', 'localhost');

Step 7: Completing the WordPress Installation

Open your web browser and navigate to your server's IP address or domain name. You should be greeted by the WordPress installation wizard. Follow the on-screen instructions to complete the installation.

Step 8: Securing Your WordPress Site

  • Set up .htaccess for additional security measures.
  • Install security plugins like Wordfence or Sucuri.
  • Regularly update WordPress, themes, and plugins.

After installation, log in to your WordPress dashboard and set your preferred permalink structure under Settings > Permalinks.

To secure your site with HTTPS, you can use Let's Encrypt to obtain a free SSL certificate:.

sudo zypper install certbot
sudo certbot --apache -d yourdomain.com -d www.yourdomain.com

Follow the prompts to complete the SSL setup.

Troubleshooting and Tips

  • If you encounter the "Error establishing a database connection" message, double-check your database credentials in wp-config.php.
  • Ensure your firewall settings allow traffic on ports 80 (HTTP) and 443 (HTTPS).
  • Regularly back up your WordPress files and database.

That's it, you now have a fully functional WordPress installation on your OpenSUSE server With WordPress's flexibility and OpenSUSE's stability, your website is poised for success.