Giter Club home page Giter Club logo

spring-boot-blog's Introduction

Blog

A blogging website built with React, SpringBoot, and MySQL. Live link: https://blog.aaronhong.net

Database

Upon starting the application, the schema.sql file located in src/main/resources will be executed. Please ensure that you have a database named "blog" prior to starting the application. If you need to change the database configuration, you can do so by modifying the application.properties file located in src/main/resources.

Setting up JAVA_HOME

To set up the JAVA_HOME environment variable, follow these steps:

Install the OpenJDK 17 package:

sudo apt install openjdk-17-jdk

Add JAVA_HOME to the /etc/environment file:

echo 'JAVA_HOME="/usr/lib/jvm/java-17-openjdk-amd64"' | sudo tee -a /etc/environment

Reload the environment variables:

source /etc/environment

Building the Application

To build the Spring Boot Blog application, run the following command in the project directory:

./mvnw clean package -P prod

This command will build the frontend artifacts and create a JAR file for the application.

Deploying to a Server

To deploy the Spring Boot Blog application to a server, follow these steps:

Create a new Systemd service file:

sudo vi /etc/systemd/system/blog.service

Add the following content to the service file:

[Unit]
Description=Spring Boot serve for blog app
After=network.target

[Service]
User=<username>
Group=www-data
WorkingDirectory=/home/<username>/blog
Environment="PATH=/usr/bin"
ExecStart=/usr/bin/java -jar /home/<username>/blog/target/blog.jar

[Install]
WantedBy=multi-user.target

Start and enable the blog service:

sudo systemctl daemon-reload
sudo systemctl start blog
sudo systemctl enable blog

Install nginx:

sudo apt install nginx

Create nginx config file

sudo vi /etc/nginx/sites-available/blog

Add the following content to the config file:

server {
    listen 80;
    server_name <IP address or domain name>;

    return 301 https://$server_name$request_uri;
}

server {
    listen 443 ssl;
    server_name <IP address or domain name>;

    error_log /home/ubuntu/blog/error.log;
    access_log /home/ubuntu/blog/access.log;

    ssl_certificate <Path to cert>;
    ssl_certificate_key <Path to key>;

    location / {
        include proxy_params;
        proxy_pass <Port or Stock>;
    }
}

Soft link conf file and restart nginx

sudo ln -s /etc/nginx/sites-available/blog /etc/nginx/sites-enabled/
sudo nginx -s reload

spring-boot-blog's People

Contributors

aaron-dev247 avatar

Stargazers

Kevin Sangani avatar sunhang avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.