How to Install XeroInput
Below is an updated step-by-step guide to installing a Laravel application on an Ubuntu system that includes both Apache and Nginx setup options. This guide assumes PHP and MySQL are already installed.
Before you start
To run this Laravel project, ensure your environment meets the following requirements:
PHP version 8.2 or higher
Composer for dependency management
A supported web server like Apache or Nginx
MySQL or PostgreSQL for the database
Required PHP Extensions
Make sure these extensions are installed and enabled:
mbstring
openssl
pdo
tokenizer
xml
For optional features, you may need:
Node.js (for frontend assets if using
laravel/ui
)Docker (if using
laravel/sail
for local development)
Additional Packages
This project uses various Laravel packages, including:
Laravel Sanctum for API authentication
Laravel UI for UI scaffolding
GuzzleHTTP for HTTP requests
Maatwebsite Excel for handling spreadsheets
Here's a condensed and structured guide for installing a Laravel application, complete with both Apache and Nginx server options and the cPanel setup, along with steps for importing databases.
Installation Steps for Laravel on Ubuntu
Prerequisites
Ensure PHP and MySQL are installed on your Ubuntu system.
Step 1: Update System Packages
Step 2: Install Composer
Step 3: Install Laravel
Step 4: Set Directory Permissions
Step 5: Configure Environment
Navigate to the Laravel project directory:
cd /var/www/html/xeroInput cp .env.example .env php artisan key:generateUpdate database configuration in
.env
:DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=xero_input DB_USERNAME=your_database_user DB_PASSWORD=your_database_password
Step 6: Create Database
Access MySQL and create the database:
sudo mysql -u root -pRun the following in the MySQL shell:
CREATE DATABASE xero_input; GRANT ALL PRIVILEGES ON xero_input.* TO 'your_database_user'@'localhost' IDENTIFIED BY 'your_database_password'; FLUSH PRIVILEGES; EXIT;
Step 7: Configure Web Server (Choose Apache or Nginx)
Option 1: Apache
Install and configure Apache:
sudo apt install apache2 -y sudo a2enmod rewrite sudo nano /etc/apache2/sites-available/xeroInput.confAdd this configuration in
xeroInput.conf
:<VirtualHost *:80> ServerAdmin admin@example.com DocumentRoot /var/www/html/xeroInput/public ServerName example.com ServerAlias www.example.com <Directory /var/www/html/xeroInput> Options Indexes FollowSymLinks AllowOverride All Require all granted </Directory> </VirtualHost>Enable the new site and reload Apache:
sudo a2ensite xeroInput.conf sudo systemctl reload apache2
Option 2: Nginx
Install Nginx and create a configuration file:
sudo apt install nginx -y sudo nano /etc/nginx/sites-available/xeroInputAdd the following configuration in
xeroInput
:server { listen 80; server_name example.com www.example.com; root /var/www/html/xeroInput/public; index index.php index.html index.htm; location / { try_files $uri $uri/ /index.php?$query_string; } location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/var/run/php/php7.4-fpm.sock; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } }Enable the site and restart Nginx:
sudo ln -s /etc/nginx/sites-available/xeroInput /etc/nginx/sites-enabled/ sudo nginx -t sudo systemctl restart nginx
Setting Up Laravel on cPanel
Log in to cPanel: Access via
http://yourdomain.com/cpanel
.Create Database and User in MySQL® Databases section.
Install Composer: Use cPanel Terminal to verify or install Composer:
composer --versionUpload Laravel Files:
Use File Manager to upload and extract files to your subdomain directory.
Alternatively, use FTP to upload the Laravel files.
Configure Environment Variables:
Rename
.env.example
to.env
.Edit database configuration in
.env
.
Set Permissions for Directories:
Set 755 permissions on
storage
andbootstrap/cache
directories.
Update .htaccess:
Ensure
.htaccess
contains:<IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ index.php [L] </IfModule>
Set Up Cron Jobs:
* * * * * php /home/username/path_to_laravel_project/artisan schedule:run >> /dev/null 2>&1
Final Step: Database Configuration
Option 1: Import SQL
Transfer
xeroInput.sql
to the server and import in MySQL:sudo mysql -u root -p USE xero_input; SOURCE /path/to/xeroInput.sql;
Option 2: Run Migrations and Seeders
Ensure
.env
is configured and run:php artisan migrate:fresh --seed
Access the application by navigating to your server's IP or domain.
Congratulations! You’ve successfully set up your Laravel application.