module
0.0.0-20240811095508-75be84efb04d
Repository: https://github.com/4adex/mvc-golang.git
Documentation: pkg.go.dev
# README
mvc-golang
Either run the setup script ./script.sh
or follow the steps below to get started.
- Clone the repo. From the root directory of the cloned repo:
- go mod vendor
- go mod tidy
- cp sample.env .env
- MYSQL Setup:
mysql -u root -p
: and enter password- Create a new database 'books':
CREATE DATABASE library_management;
- Connect to the database:
USE library_management;
- Do all the migrations:
- Ensure that you have golang migrate installed.
- Change the username and password and run
migrate -path database/migration/ -database "mysql://username:password@tcp(localhost:3306)/library_management" -verbose up
- Running the server:
go build -o mvc ./cmd/main.go
- Run the binary file:
./mvc
Hosting
- Install or Update apache on your system -
sudo apt update
sudo apt install apache2
- Enable required modules in apache -
sudo a2enmod proxy
sudo a2enmod proxy_http
sudo systemctl restart apache2
- Create Virtual host configuration file -
sudo nano /etc/apache2/sites-available/shelfmaster.conf
<VirtualHost *:80>
ServerName shelfmaster.local
ProxyPreserveHost On
ProxyPass / http://localhost:8000/
ProxyPassReverse / http://localhost:8000/
ErrorLog /var/log/shelfmaster-error.log
CustomLog /var/log/shelfmaster-access.log combined
</VirtualHost>
- Enable the virtual host -
sudo a2ensite shelfmaster.conf
sudo systemctl restart apache2
- Run the go binary using
./mvc
and access the hosted site onshelfmaster.local
.