How to Install WooCommerce on CentOS 7

Updated on October 15, 2021
How to Install WooCommerce on CentOS 7 header image

Introduction

WooCommerce is an open-source e-commerce plugin for WordPress. It is designed for small to large-sized online merchants. This article explains how to set up WooCommerce on a CentOS 7 server using Vultr's one-click LEMP Application.

1. Install Prerequisites

2. Install WordPress

1. Create a Database for WordPress

  1. Connect to the MySQL Database.

     # mysql -u root
  2. Create a database for WordPress named wordpressdb.

     mysql> CREATE DATABASE wordpressdb;
  3. Create a new database user. Replace <PASSWORD> with a strong password.

     mysql> CREATE USER 'wp-user'@'localhost' IDENTIFIED BY '<PASSWORD>';
  4. Grant the user permission to access the database.

     mysql> GRANT ALL PRIVILEGES ON wordpressdb.* TO 'wp-user'@'localhost';
  5. Reload the grant tables to activate the permission settings.

     mysql> FLUSH PRIVILEGES;
  6. Exit MySQL.

     mysql> exit

2. Download and Install WordPress

  1. Change the directory to /usr/share/nginx/html, which is the default Nginx server root directory in CentOS.

     # cd /usr/share/nginx/html
  2. Download the tarball of the latest WordPress version. Please see WordPress download page for the latest WordPress version.

     # wget https://wordpress.org/latest.tar.gz
  3. Extract the downloaded file.

     # tar -xvf latest.tar.gz
  4. remove latest.tar.gz.

     # rm -fr latest.tar.gz
  5. Move all the extracted files to /usr/share/nginx/html.

     # mv wordpress/* /usr/share/nginx/html/ && rm -fr wordpress

    Enter yes when prompted to replace index.php.

  6. Give nginx ownership of the /usr/share/nginx/html directory.

     # chown -R nginx:nginx /usr/share/nginx/html
  7. On your browser, navigate to your server's IP address.

  8. Click Let's go! to proceed.

  9. Enter the database information you provided from section 2.1. In this guide, you used wordpressdb as the Database Name, wp-user as the username, and you entered a strong password. The Database Host will remain as localhost and the Table Prefix should remain as wp_ unless you want to run multiple WordPress installations in a single database.

  10. Click Submit to continue.

  11. If it showed that you are Unable to write to wp-config.php file, you need to create the wp-config.php file manually, then paste the code provided.

    # nano /usr/share/nginx/html/wp-config.php
  12. Save and exit the file, then click Run the installation to proceed.

  13. Enter all the information such as the Site title, username, password, and your Email, then click Install WordPress.

  14. Login using the credentials you provided in step 13.

3. Setup WooCommerce

Now that you have finished installing WordPress, you may now proceed in setting up WooCommerce.

1. Download WooCommerce Plugin

  1. On your SSH terminal, change the directory to /usr/share/nginx/html/wp-content/plugins. This is where you need to extract the WooCommerce Plugin.

     # cd /usr/share/nginx/html/wp-content/plugins
  2. Download WooCommerce. Please see the WooCommerce Plugin Page on the WordPress website to get the latest version.

     # wget https://downloads.wordpress.org/plugin/woocommerce.5.7.1.zip
  3. Extract the downloaded zip file.

     # unzip woocommerce.5.7.1.zip

2. Optimize NGINX for WooCommerce and WordPress

  1. Edit nginx.conf using nano.

     # nano /etc/nginx/nginx.conf
  2. Look for:

     worker_processes auto;

    Change its value depending on how many CPUs your server instance has. For example, for a 2 CPU server instance, it should look like this:

     worker_processes 2;
  3. Look for:

     worker_connections 1024;

    Change its value depending on how many GB of memory your server instance has multiplied by 256. A 4GB RAM server instance should have 4 * 256 = 1024 connections.

  4. Once you are finished, save and exit the file.

3. Setting up WooCommerce

  1. On your WordPress Admin Dashboard, Select Plugins from the sidebar menu.
  2. Look for WooCommerce plugin, and click Activate to proceed with the WooCommerce setup.
  3. Fill up some details about your store such as the store address, the industry your store operates, the type of products your store will have, some business details and features that you want to add, and lastly, the theme for your online store.
  4. Once you are finished, you will be redirected to create a Jetpack account if you added the Jetpack Business Feature. You can either create an account or skip it, and just continue without a user account.

You now have successfully created a WooCommerce shop on WordPress. You may visit your shop on your server's IP address.

You can manage your store, such as your products, analytics, and marketing, through the WordPress Admin Dashboard.

Conclusion

In this article, you created an online shop with WooCommerce, using Vultr's one-click LEMP Application.