Install WordPress WooCommerce Plugin on Ubuntu 17.04 | 17.10 with Apache2 Support

WooCommerce is a WordPress plugin that turns a standard WordPress website into self-hosted online store. The plugin requires that you have a working WordPress website. The installation process is fairly simple. and should take only a few minutes to complete.

This brief tutorial is going to show students and new users how to install WooCommerce WordPress plugins and set up their own online stores. For this tutorial, we’ll going to begin from the very beginning.

We will install and configure WordPress, then install the WooCommerce plugin on WordPress website.

To get started with install WooCommerce, continue with the steps below:

STEP 1: PREPARE AND UPDATE UBUNTU

It’s good to always update Ubuntu servers before installing packages… to update Ubuntu, run the commands below.

sudo apt update && sudo apt dist-upgrade && sudo apt autoremove

After updating Ubuntu, continue below with installing required packages for WordPress to work.

STEP 2: INSTALL APACHE2 WEB SERVER

Apache2 web server is the most popular server in use today and WordPress requires a web server… so go and install Apache2 by running the commands below.

sudo apt install apache2

After installing Apache2, run the commands below to disable directory listing.

sudo sed -i "s/Options Indexes FollowSymLinks/Options FollowSymLinks/" /etc/apache2/apache2.conf

The commands below can be used to stop, start and enable Apache2 service to always start up with the server boots.

sudo systemctl stop apache2.service
sudo systemctl start apache2.service
sudo systemctl enable apache2.service

STEP 3: INSTALL MARIADB DATABASE SERVER

MariaDB database server is rapidly overtaking MySQL in the open source and Linux communities… MariaDB is the default database server on majority of Linux distributions… and WordPress requires a database server. run the commands below to install MariaDB.

sudo apt-get install mariadb-server mariadb-client

After installing, the commands below can be used to stop, start and enable MariaDB service to always start up when the server boots.

sudo systemctl stop mariadb.service
sudo systemctl start mariadb.service
sudo systemctl enable mariadb.service

After that, run the commands below to secure MariaDB server and create a new root password.

sudo mysql_secure_installation

When prompted, answer the questions below by following the guide.

  • Enter current password for root (enter for none): Just press Enter
  • Set root password? [Y/n]: Y
  • New password: Enter password
  • Re-enter new password: Repeat password
  • Remove anonymous users? [Y/n]: Y
  • Disallow root login remotely? [Y/n]: Y
  • Remove test database and access to it? [Y/n]:  Y
  • Reload privilege tables now? [Y/n]:  Y

STEP 4: INSTALL PHP AND RELATED MODULES

Now that Apache2 and MariaDB are installed, run the commands below to install PHP and related PHP modules on the new server. This is a good list of PHP modules to install.

sudo apt install php libapache2-mod-php php-common php-mbstring php-xmlrpc php-soap php-gd php-xml php-intl php-mysql php-cli php-mcrypt php-ldap php-zip php-curl

After install PHP, run the commands below to open Apache2 PHP default file.

sudo nano /etc/php/7.X/apache2/php.ini

Depending on your system, the X in the command above could be 0 or 1 .

Then scroll down the lines in the file and change the following lines below and save.

post_max_size = 100M
memory_limit = 256M
max_execution_time = 360
upload_max_filesize = 100M

STEP 5: CREATE A BLANK WORDPRESS DATABASE

At this point, all the required WordPress packages and and servers are installed. The new server  is now ready to host WordPress… On the new server, create a blank WordPress database. WordPress will use this empty database to store its content.

Run the commands below to logon to the database server. When prompted for a password, type the root password you created above.

sudo mysql -u root -p

Then create a blank database called WP_database  you can use the same database name from the old server.

CREATE DATABASE WP_database;

Create a database user called wp_user with new password.  You can use the same username and password from the old server.

CREATE USER 'wp_user'@'localhost' IDENTIFIED BY 'type_password_here';

Then grant the user full access to the database.

GRANT ALL ON WP_database.* TO 'wp_user'@'localhost' IDENTIFIED BY 'type_user_password_here' WITH GRANT OPTION;

Finally, save your changes and exit.

FLUSH PRIVILEGES;
EXIT;

STEP 6: CONFIGURE THE NEW WORDPRESS SITE

Next, configure the WordPress site configuration file on the server. Run the commands below to create a new configuration file called wordpress.conf

sudo nano /etc/apache2/sites-available/wordpress.conf

Then copy and paste the content below into the file and save it. Replace example.com with your own domain name.

<VirtualHost *:80>
     ServerAdmin [email protected]
     DocumentRoot /var/www/html/wordpress/
     ServerName example.com
     ServerAlias www.example.com

     <Directory /var/www/html/wordpress/>
        Options +FollowSymlinks
        AllowOverride All
        Require all granted
     </Directory>

     ErrorLog ${APACHE_LOG_DIR}/error.log
     CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

Save the file and exit.

STEP 7: ENABLE THE WORDPRESS SITE AND REWRITE MODULE

After configuring the VirtualHost above, enable it by running the commands below

sudo a2ensite wordpress.conf
sudo a2enmod rewrite

STEP 8: DOWNLOAD WORDPRESS LATEST RELEASE

Next, visit WordPress site and download the latest…. or run the commands below to do that for you.

cd /tmp && wget 
tar -zxvf latest.tar.gz
sudo mv wordpress /var/www/html/wordpress

Then run the commands below to set the correct permissions for WordPress root directory.

sudo chown -R www-data:www-data /var/www/html/wordpress/
sudo chmod -R 755 /var/www/html/wordpress/

STEP 9: CONFIGURE WORDPRESS

Next, run the commands below to create WordPress wp-config.php file. This is the default configuration file for WordPress.

sudo mv /var/www/html/wordpress/wp-config-sample.php /var/www/html/wordpress/wp-config.php

Then run the commands below to open WordPress configuration file.

sudo nano /var/www/html/wordpress/wp-config.php

Enter the highlighted text below that you created for your database and save.

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

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

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

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

/** Database Charset to use in creating database tables. */
define('DB_CHARSET', 'utf8');

/** The Database Collate type. Don't change this if in doubt. */
define('DB_COLLATE', '');

Save the file and you’re done.

Now all is configured… run the commands below to reload Apache2 web server settings.

sudo systemctl reload apache2.service

After that, open your browser and browse to the server IP address or domain name to continue with WordPress setup.

ex. 

If everything is setup correctly, you’ll see WordPress setup wizard and continue with the setup.

ubuntu wordpress lets encrypt

Follow the on-screen instruction to complete the wizard. you’ll have to create the site administrator account with password. then use it to logon to WordPress dashboard to manage WordPress.

After installing, go to WordPress dashboard and click Plugins –> Add New

Then search for WooCommerce and click Install Now

woocommerce_wordpress

After installing, Activate. After activating, the plugin should automatically start the setup wizard. follow the on-screen instruction

woocommerce wordpress

Continue until the setup is complete. After that, you can begin setting up your products to sell online

woocommerce

Enjoy!

woocommerce plugin

You may also like the post below: