How to Install Crater on Debian
Crater is an open-source invoicing app built with Laravel. It allows freelancers and small businesses to manage their invoices, expenses, and clients with ease. In this tutorial, we'll show you how to install Crater on Debian.
Prerequisites
Before we begin, make sure your Debian system meets the following requirements:
- Sudo privileges
- PHP 7.3 or higher
- MySQL 5.7 or higher
- Composer
- Node.js
Step 1: Install Apache Web Server
Crater requires a web server to run. We'll use Apache in this tutorial. To install Apache on Debian, run the following commands:
sudo apt update
sudo apt install apache2
After the installation is complete, start the Apache service and enable it to start automatically on boot:
sudo systemctl start apache2
sudo systemctl enable apache2
Verify that Apache is running by visiting http://localhost in your web browser. You should see the Apache2 Debian Default Page.
Step 2: Install MySQL
Crater uses a MySQL database to store its data. To install MySQL on Debian, run the following command:
sudo apt install mysql-server
During the installation process, you will be prompted to set a root password for MySQL. Choose a strong password and remember it.
After the installation is complete, start the MySQL service and enable it to start automatically on boot:
sudo systemctl start mysql
sudo systemctl enable mysql
Verify that MySQL is running by logging in to the MySQL shell:
mysql -u root -p
Enter the root password when prompted. If you can successfully log in, you're ready to proceed.
Step 3: Install PHP
Crater requires PHP 7.3 or higher. To install PHP on Debian, run the following commands:
sudo apt install php php-common php-cli php-mysql php-curl php-mbstring php-xml
After the installation is complete, verify that PHP is installed by running the following command:
php --version
You should see the PHP version number displayed.
Step 4: Install Composer
Composer is a dependency manager for PHP. It is used to install and manage Crater's dependencies. To install Composer on Debian, run the following commands:
sudo apt install curl
curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer
After the installation is complete, verify that Composer is installed by running the following command:
composer --version
You should see the Composer version number displayed.
Step 5: Install Node.js and NPM
Crater uses Node.js and NPM to manage its front-end dependencies. To install Node.js and NPM on Debian, run the following commands:
sudo apt install nodejs npm
After the installation is complete, verify that Node.js and NPM are installed by running the following commands:
node --version
npm --version
You should see the Node.js and NPM version numbers displayed.
Step 6: Clone Crater from GitHub
Now that we've installed all the required dependencies, we're ready to clone Crater from GitHub. To do this, run the following commands:
cd /var/www/html
sudo git clone https://github.com/crater-invoice/crater.git
cd crater
sudo composer install
sudo npm install
sudo npm run dev
The first command changes the current directory to /var/www/html. This is where Apache serves its web files from by default. The second command clones the Crater repository from GitHub. The third command changes the current directory to the Crater directory. The fourth command installs Crater's PHP dependencies using Composer. The fifth command installs Crater's front-end dependencies using NPM. The sixth command compiles Crater's assets using NPM.
Step 7: Create a MySQL Database and User
Crater requires a MySQL database and user to function. To create a database and user, log in to the MySQL shell:
mysql -u root -p
Enter the root password when prompted. Then, create a new database and user:
CREATE DATABASE crater_db;
CREATE USER 'crater_user'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON crater_db.* TO 'crater_user'@'localhost';
FLUSH PRIVILEGES;
Replace 'password' with a strong password for the crater_user.
Step 8: Configure Crater
Now that we've set up the database and user, we're ready to configure Crater. Copy the .env.example file to .env:
sudo cp .env.example .env
Then, edit the .env file with your favorite text editor:
sudo nano .env
Find the following lines in the .env file:
DB_DATABASE=
DB_USERNAME=
DB_PASSWORD=
And replace them with:
DB_DATABASE=crater_db
DB_USERNAME=crater_user
DB_PASSWORD=password
Replace 'password' with the password you set for the crater_user.
Save and close the .env file.
Step 9: Run the Crater Installer
Finally, run the Crater installer to set up the database schema and create a user:
php artisan crater:install
Follow the prompts to create a user and set up your company information.
Step 10: Access Crater
You should now be able to access Crater by visiting http://localhost/crater/public in your web browser. Log in with the username and password you created during the installation process.
That's it! You have successfully installed Crater on Debian.