Introduction: In this tutorial, we will guide you through the process of installing WordPress on a CentOS 7 server. Before starting, ensure that you meet the following prerequisites:

Prerequisites:

  1. A server with Linux CentOS 7.
  2. LAMP Stack (Linux, Apache, MySQL, PHP) installed. If not, follow our LAMP Stack installation tutorial.
  3. Root access to your server.
  4. SSH tools:
    • For Windows: PuTTY
    • For Linux/macOS: OpenSSH (available by default)

We will use the following information from the LAMP Stack tutorial in this WordPress installation:

  • Main Domain: example.com
  • Sub Domain: holu.example.com
  • MySQL root password: holuP455##

Let's get started!

Step 1: Create a MySQL Database with a User and Password Step 1.1: Login to MySQL (as root):

mysql -u root -p

Step 1.2: Create users (and passwords): For example.com:

CREATE USER 'example'@'localhost' IDENTIFIED BY '#TH15exmp#';

For holu.example.com:

CREATE USER 'holu'@'localhost' IDENTIFIED BY '#TH15holu#';

Step 1.3: Create the database: For example.com:

CREATE DATABASE exampledb;

For holu.example.com:

CREATE DATABASE holudb;

Step 1.4: Grant the user access rights: This command will give both users full access to their respective databases:

GRANT ALL PRIVILEGES ON exampledb.* TO 'example'@'localhost' WITH GRANT OPTION; GRANT ALL PRIVILEGES ON holudb.* TO 'holu'@'localhost' WITH GRANT OPTION;

To save the changes, run:

FLUSH PRIVILEGES;

Now exit MySQL with:

quit

Step 2: Install and Configure WordPress Step 2.1: Download and Extract WordPress:

cd /tmp wget https://wordpress.org/latest.tar.gz tar -xvf latest.tar.gz cd wordpress

Step 2.2: Copy the WordPress Files to the Public_HTML Directory and Grant Apache Access:

For example.com:

mkdir -p /var/www/html/example.com/public_html cp -r * /var/www/html/example.com/public_html chown -R apache:apache /var/www/html/example.com/public_html find /var/www/html/example.com/public_html -type d -exec chmod 755 {} \; find /var/www/html/example.com/public_html -type f -exec chmod 644 {} \;

For holu.example.com:

mkdir -p /var/www/html/holu.example.com/public_html cp -r * /var/www/html/holu.example.com/public_html chown -R apache:apache /var/www/html/holu.example.com/public_html find /var/www/html/holu.example.com/public_html -type d -exec chmod 755 {} \; find /var/www/html/holu.example.com/public_html -type f -exec chmod 644 {} \;

Step 2.3: Configure WordPress to Access your website from the browser (example.com and holu.example.com). If you see the standard WordPress page, the installation was successful.

  1. Click "Let's go" to configure the database settings.
  2. Set the website details, username, and password.
  3. If successful, you'll be redirected to the login page.

Repeat Step 2.3 for holu.example.com and any other websites you want to add.

Optional: Fixes for Potential Errors

  • Database Error: If you encounter a database error, you can fix it by editing the MySQL configuration, as explained in the tutorial.
  • Cannot Write wp-config.php Error: If you face a "Cannot write wp-config.php" error, check and grant Apache user access to your public_html directory.

Conclusion: Your CentOS 7 server is now ready to host WordPress websites. You can add more websites following the same steps. Enjoy your WordPress hosting!

 

¿Fue útil la respuesta? 44 Los Usuarios han Encontrado Esto Útil (88 Votos)