In this article, we'll dive into the process of deploying a typical Laravel application on shared hosting using Wexron Hosting. Whether you're a seasoned developer or just getting started, this guide will help you get your Laravel project up and running smoothly.
Prerequisites
Before we begin, there are a few things you'll need in order to follow along:
-
Active Shared Hosting Plan: Ensure you have an active shared hosting plan with Wexron Hosting. If you're interested in trying this tutorial, you can take advantage of our free trial offer.
-
Git Knowledge (Optional): If you're familiar with Git, you can use it to clone your repository onto our servers. If not, don't worry—FTP clients or the File Manager provided by DirectAdmin will do the job just fine.
-
SSH Access (Optional): Please note that SSH access is currently disabled for all plans. However, you can request SSH access free of charge by opening a support ticket from your client area.
Once you have SSH access, you can log in to your account using the provided information.
Installation of Git
Good news! Git is readily available for all accounts with SSH access, so you typically won't need to install it separately.
Installation of Composer
By default, Wexron Hosting provides a globally installed Composer for your convenience. However, if you require a custom installation, follow these steps:
- Connect to your server via SSH.
- Navigate to the root directory (
/home/{username}
). - Create a 'bin' folder if it doesn't already exist. This folder is where you can place scripts that can be executed as terminal commands.
- Install the Composer setup script by running the following commands (you can also refer to the official Composer page for updated instructions):
# Get the official Composer installer. php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" # Verify the integrity of the installer. php -r "if (hash_file('sha384', 'composer-setup.php') === 'e21205b207c3ff031906575712edab6f13eb0b361f2085f1f1237b7126d785e826a450292b6cfd1d64d92e6563bbde02') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
- This will create a
composer-setup.php
(installer). Use it to install your specified version of Composer:
# Composer installation php composer-setup.php --filename=composer --install-dir=bin # You can also install a specific version using the version flag, e.g., --version=1.0.0-alpha8 # Remove the installer after successfully installing Composer on the server. php -r "unlink('composer-setup.php');"
-
Grant necessary permissions to the executable with this command:
chmod +x bin/composer
. -
Verify your Composer installation with:
composer --version
.
Installation of npm/yarn
To install npm/yarn, we recommend using NVM (Node Version Manager):
# Using curl
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash
# Using wget
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash
Once NVM is installed, you can easily set up your preferred Node.js version for your project. NVM will handle the rest for you, making the npm
command available in your terminal.
If you need to install pnpm
or yarn
, you can do so using npm.
How to Install and Deploy Your Laravel Project
Before you start, it's crucial to understand your domain's root. If you have a primary domain like "example.com," ensure it points to domains/example.com/public_html
. Your Laravel files should be uploaded to this location.
For a typical Laravel application, you'll need to configure your domain root to point to your project's public
folder. One way to achieve this is by creating an .htaccess
file in your domain root and using it to route all requests to public/index.php
.
If you're using a subdomain, you can edit the path to your Laravel project's public
folder directly from the DirectAdmin panel.
Setting up Your MySQL Database (Optional)
If your project requires a database, follow these steps to create a MySQL database.
- Login to your DirectAdmin panel
- Navigate to "MySql Management"
- Create a new Database with the necessary details.
- After creating your database, note down the configuration values.
- open
.env
and configure your connection with your laravel application - run all the migrations using
php artisan migrate
Setting up Your Laravel Configuration
Please note that Wexron Hosting supports a limited number of databases. Refer to this article for information on our supported databases.
Laravel applications use a .env
file to store configurations. To create the main .env
file, use the example .env
file provided:
cp env.example .env
After creating your .env
file, you can edit the configurations for the database and other services. For configuring emails and databases, refer to the relevant articles.
Once your environment variables are set, generate your Laravel application key:
php artisan key:generate
Your website is now ready to accept users. If you encounter any issues, don't hesitate to contact our support team for assistance with account setup.
We're here to help you with your hosting needs, although we may not be able to assist with your project's code.