DEV Community

Emmanuel
Emmanuel

Posted on • Updated on

Using WooCommerce as a headless Online Store

  • Install WordPress

    • Watch this video and stop at step #3. Make sure you select uscentral1, useast1, or uswest1 to take advantage of google's free tier.
    • Enable let's encrypt by running:
         sudo /opt/bitnami/bncert-tool
    
    • Disable the Bitnami banner by running:
        sudo /opt/bitnami/apps/wordpress/bnconfig --disable_banner 1
        sudo /opt/bitnami/ctlscript.sh restart apache
    
    • Configure the server to parse Authorization headers correctly when you make a request from the front end:
        // Open the htttpd config file by running:        
        sudo nano /opt/bitnami/apps/wordpress/conf/httpd-app.conf
    
        // Add this to the bottom of the file:
        RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
        SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
    
        // Restart the server
        sudo  /opt/bitnami/ctlscript.sh restart apache
    
  • Install Woo-commerce plugin

  • Go to settings -> Permalinks and change from plain to custom: /%postname%/and product base to custom: /product/

  • Generate your API keys. set them to read/write

  • Add products (set up a test CSV file for this)

  • Install Axios on your front end we will use this for some basic auth stuff

Bonus Section: Connect to MySQL DB Remotely

SSH into your VM and run the following command:

sudo nano /opt/bitnami/mysql/my.cnf
Enter fullscreen mode Exit fullscreen mode

comment out bind-address=127.0.0.1 and save the file.

Next create a new db user with the following command:



mysql -u root -p
# enter password
CREATE USER 'user'@'%' IDENTIFIED BY 'YOUR_PASSWORD';
GRANT ALL PRIVILEGES ON * . * TO 'user'@'%';
FLUSH PRIVILEGES;

Enter fullscreen mode Exit fullscreen mode

Top comments (0)

Some comments may only be visible to logged-in visitors. Sign in to view all comments.