How to Install WooCommerce on CentOS 7
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
Deploy a one-click LEMP Application on CentOS 7 from Vultr Marketplace Apps
Your server's number of CPUs and Memory size should depend on how large your online store will be.
Login as root
2. Install WordPress
1. Create a Database for WordPress
Connect to the MySQL Database.
# mysql -u root
Create a database for WordPress named
wordpressdb
.mysql> CREATE DATABASE wordpressdb;
Create a new database user. Replace
<PASSWORD>
with a strong password.mysql> CREATE USER 'wp-user'@'localhost' IDENTIFIED BY '<PASSWORD>';
Grant the user permission to access the database.
mysql> GRANT ALL PRIVILEGES ON wordpressdb.* TO 'wp-user'@'localhost';
Reload the grant tables to activate the permission settings.
mysql> FLUSH PRIVILEGES;
Exit MySQL.
mysql> exit
2. Download and Install WordPress
Change the directory to
/usr/share/nginx/html
, which is the default Nginx server root directory in CentOS.# cd /usr/share/nginx/html
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
Extract the downloaded file.
# tar -xvf latest.tar.gz
remove
latest.tar.gz
.# rm -fr latest.tar.gz
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.Give nginx ownership of the
/usr/share/nginx/html
directory.# chown -R nginx:nginx /usr/share/nginx/html
On your browser, navigate to your server's IP address.
Click Let's go! to proceed.
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 aslocalhost
and the Table Prefix should remain aswp_
unless you want to run multiple WordPress installations in a single database.Click Submit to continue.
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
Save and exit the file, then click Run the installation to proceed.
Enter all the information such as the Site title, username, password, and your Email, then click Install WordPress.
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
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
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
Extract the downloaded zip file.
# unzip woocommerce.5.7.1.zip
2. Optimize NGINX for WooCommerce and WordPress
Edit
nginx.conf
using nano.# nano /etc/nginx/nginx.conf
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;
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.
Once you are finished, save and exit the file.
3. Setting up WooCommerce
- On your WordPress Admin Dashboard, Select Plugins from the sidebar menu.
- Look for WooCommerce plugin, and click Activate to proceed with the WooCommerce setup.
- 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.
- 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.