openSUSE

How To Install WordPress with LAMP on openSUSE

Install WordPress on openSUSE

WordPress, the world’s most popular content management system, powers over a third of all websites. Combining it with the robust LAMP stack (Linux, Apache, MariaDB, PHP) on openSUSE creates a powerful and flexible web hosting environment. This comprehensive guide will walk you through the process of installing WordPress with LAMP, specifically using Apache, MariaDB, and PHP 8.3 on openSUSE.

Prerequisites

Before diving into the installation process, ensure you have the following:

  • An openSUSE Leap or Tumbleweed system with root or sudo access
  • A registered domain name (if you plan to make your site publicly accessible)
  • Basic familiarity with the Linux command line

It’s also crucial to have your system up-to-date. Run the following command to update your openSUSE system:

sudo zypper update

Step 1: Install Apache Web Server

Apache is a reliable and widely-used web server that will host your WordPress site. To install Apache on openSUSE, follow these steps:

  1. Open a terminal and run the following command:
    sudo zypper install apache2
  2. Once installed, start the Apache service and enable it to run at boot:
    sudo systemctl start apache2
    sudo systemctl enable apache2
  3. Verify that Apache is running:
    sudo systemctl status apache2

To test your Apache installation, open a web browser and navigate to http://localhost or http://your_server_ip. You should see the default Apache welcome page.

Step 2: Install MariaDB

MariaDB is a powerful, open-source database management system that WordPress uses to store and manage site content. Here’s how to install and configure MariaDB:

  1. Install MariaDB using zypper:
    sudo zypper install mariadb mariadb-client
  2. Start the MariaDB service and enable it to run at boot:
    sudo systemctl start mysql
    sudo systemctl enable mysql
  3. Secure your MariaDB installation:
    sudo mysql_secure_installation

    Follow the prompts to set a root password and remove insecure default settings.

After securing MariaDB, create a database and user for WordPress:

sudo mysql -u root -p
CREATE DATABASE wordpress;
CREATE USER 'wpuser'@'localhost' IDENTIFIED BY 'your_password';
GRANT ALL PRIVILEGES ON wordpress.* TO 'wpuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;

Replace ‘your_password‘ with a strong, unique password.

Step 3: Install PHP 8.3

PHP is the scripting language that WordPress is built on. openSUSE Leap might not have PHP 8.3 in its default repositories, so we’ll need to add a repository:

  1. Add the PHP repository:
    sudo zypper addrepo https://download.opensuse.org/repositories/devel:/languages:/php/openSUSE_Leap_15.4/ php
  2. Refresh the repository:
    sudo zypper refresh
  3. Install PHP 8.3 and necessary extensions:
    sudo zypper install php8 php8-mysql apache2-mod_php8 php8-gd php8-mbstring php8-xml php8-curl php8-zip
  4. Enable the PHP module for Apache:
    sudo a2enmod php8
    sudo systemctl restart apache2

To verify your PHP installation, create a PHP info file:

echo '' | sudo tee /srv/www/htdocs/info.php

Navigate to http://your_server_ip/info.php in your web browser. If you see a page with PHP information, the installation was successful.

Step 4: Download and Configure WordPress

Now that we have our LAMP stack set up, let’s download and configure WordPress:

  1. Download the latest version of WordPress:
    cd /tmp
    wget https://wordpress.org/latest.tar.gz
  2. Extract the archive:
    tar xzvf latest.tar.gz
  3. Move WordPress files to the Apache document root:
    sudo mv wordpress/* /srv/www/htdocs/
  4. Set proper permissions:
    sudo chown -R wwwrun:www /srv/www/htdocs
    sudo chmod -R 755 /srv/www/htdocs

Next, configure WordPress to use the database we created earlier:

  1. Copy the sample configuration file:
    sudo cp /srv/www/htdocs/wp-config-sample.php /srv/www/htdocs/wp-config.php
  2. Edit the configuration file:
    sudo nano /srv/www/htdocs/wp-config.php
  3. Update the database details:
    define('DB_NAME', 'wordpress');
    define('DB_USER', 'wpuser');
    define('DB_PASSWORD', 'your_password');
    define('DB_HOST', 'localhost');

Step 5: Configure Apache for WordPress

To ensure Apache works correctly with WordPress, we need to make a few adjustments:

  1. Create a new virtual host configuration:
    sudo nano /etc/apache2/vhosts.d/wordpress.conf
  2. Add the following content (replace example.com with your domain):
    <VirtualHost *:80>
        ServerName example.com
        DocumentRoot /srv/www/htdocs
        <Directory /srv/www/htdocs>
            Options FollowSymLinks
            AllowOverride All
            Require all granted
        </Directory>
        ErrorLog /var/log/apache2/wordpress_error.log
        CustomLog /var/log/apache2/wordpress_access.log combined
    </VirtualHost>
  3. Enable the rewrite module:
    sudo a2enmod rewrite
  4. Restart Apache to apply changes:
    sudo systemctl restart apache2

Step 6: Complete WordPress Installation

With all the backend configuration complete, it’s time to finish the WordPress installation through the web interface:

  1. Open a web browser and navigate to your domain or server IP.
  2. Select your preferred language and click “Continue”.
  3. On the next page, fill in the site information:
    • Site Title
    • Username (avoid using ‘admin’ for security reasons)
    • Password (use a strong, unique password)
    • Your Email
  4. Click “Install WordPress” to complete the setup.

After installation, you can log in to your new WordPress site using the credentials you just created.

How To Install WordPress with LAMP on openSUSE

Security and Optimization Tips

To ensure your WordPress installation remains secure and performs optimally, consider implementing these additional measures:

Security Enhancements

  • Install and configure a WordPress security plugin like Wordfence or Sucuri.
  • Enable two-factor authentication for admin accounts.
  • Regularly update WordPress core, themes, and plugins.
  • Use strong, unique passwords for all user accounts.
  • Limit login attempts to prevent brute-force attacks.

Performance Optimization

  • Install a caching plugin like W3 Total Cache or WP Super Cache.
  • Enable Gzip compression in Apache to reduce file transfer sizes.
  • Optimize images before uploading them to your site.
  • Use a content delivery network (CDN) for static assets.
  • Regularly clean up your database to remove unnecessary data.

Troubleshooting Common Issues

If you encounter problems during or after installation, try these troubleshooting steps:

  • Check Apache error logs: sudo tail -f /var/log/apache2/error.log
  • Verify PHP is working: Create a phpinfo file as described earlier.
  • Test database connectivity: Use a tool like phpMyAdmin or the MySQL command line client.
  • Ensure proper file permissions: WordPress files should be owned by the web server user (www run on openSUSE).
  • Enable WordPress debug mode: Add define('WP_DEBUG', true); to wp-config.php for detailed error messages.

Congratulations! You have successfully installed WordPress. Thanks for using this tutorial to install the latest version of WordPress on openSUSE. For additional help or useful information, we recommend you check the official WordPress website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is a seasoned Linux system administrator with a wealth of experience in the field. Known for his contributions to idroot.us, r00t has authored numerous tutorials and guides, helping users navigate the complexities of Linux systems. His expertise spans across various Linux distributions, including Ubuntu, CentOS, and Debian. r00t's work is characterized by his ability to simplify complex concepts, making Linux more accessible to users of all skill levels. His dedication to the Linux community and his commitment to sharing knowledge makes him a respected figure in the field.
Back to top button