
The TALL stack combines Tailwind CSS, Alpine.js, Laravel, and Livewire to create a modern full-stack framework for building responsive, reactive applications. Laravel handles the backend, Tailwind provides utility-first CSS, Alpine.js adds lightweight frontend reactivity, and Livewire allows developers to build dynamic and reactive user interfaces with PHP. Vultr's Laravel Marketplace Application provisions a ready-to-use Laravel environment on Ubuntu LTS in just minutes.
This article explains deploying a TALL stack application on Vultr using the Laravel Marketplace App. You will install Node.js, configure a MySQL database, deploy a sample TALL application, set proper file permissions, configure Apache with a virtual host, verify each TALL stack component works correctly, and set up a TLS certificate to enable HTTPS.
Before you begin:
app.example.com.The Laravel Marketplace App includes Apache, PHP, MySQL, Composer, and Git. Install Node.js to build Tailwind CSS assets.
Download and install Node Version Manager (NVM) to manage Node.js versions.
You can first run the command without | bash to review the script before execution.
Reload your shell configuration to make NVM available in your current session.
Install the latest LTS version of Node.js.
Verify the Node.js installation.
Output:
Verify the NPM installation.
Output:
Your TALL application requires a database. Follow these steps to secure MySQL, create a new user and database, and grant the user permission to manage it.
Run the MySQL secure installation script to disable insecure default settings and enable authentication on your database server.
Reply to the following MySQL database server options when prompted:
2 to enable multi-character passwords and dictionary usage on the server.root remote login access.Login to your MySQL shell as root user.
Create a database. Replace tallisman with your desired database name.
Create a new MySQL user. Replace vultr with your desired username and Strong@@password123 with your desired password.
Give the vultr user permission to manage the tallisman database.
Exit the MySQL shell.
Test the connection with the vultr user. Enter your password when prompted.
Verify the databases that the vultr user can access.
Output:
Exit the database.
The Laravel Marketplace Application provides a fresh Laravel installation. In this step, you'll replace the default application with a sample application already preinstalled in the TALL stack.
Navigate to the Apache document root and remove the default Laravel application.
Clone the sample TALL repository.
Change the ownership of the tallisman directory to your user and the www-data group.
This sets the owner to your user and the group to www-data, giving both you and Apache permission to manage the application.
Navigate to the tallisman directory.
Copy .env.example to .env.
Configure the database connection in the .env file.
Update DB_DATABASE, DB_USERNAME, and DB_PASSWORD with the values created earlier:
Save and close the file.
Install backend dependencies.
Install frontend dependencies.
Generate the application key. Laravel uses this key to encrypt data within your application.
Run database migrations.
Build the frontend assets for production.
This compiles your Tailwind CSS and JavaScript assets, creating the necessary files in the public/build directory.
Before going live, secure the application by configuring file permissions and Apache.
Laravel requires correct file and folder permissions to run securely. Files must be readable, directories accessible, and the storage and bootstrap/cache directories writable by the web server.
Change all file permissions to 644.
This ensures files are not executable unless specifically needed.
Change all directory permissions to 755.
This allows users to enter and traverse directories.
Change the group ownership of the storage and bootstrap/cache directories to www-data.
This gives the web server access to manage these directories.
Grant full permissions to the owner and group for storage and bootstrap/cache.
These directories must be writable so Laravel can store logs, cache, and compiled views.
Clear Laravel's cached files.
Running this after permission changes ensures Laravel can rebuild its cache without errors.
Apache uses virtual hosts to define how to serve websites. By creating a custom virtual host for your Laravel app, you can disable Apache directory listing and ensure the server points directly to Laravel's public directory.
Disable the default virtual host.
Output:
Navigate to Apache's site configuration directory.
Create a new virtual host file.
Add the following configuration:
Save and close the file.
Test the Apache configuration for errors.
Enable the virtual host.
Reload Apache to apply the virtual host changes.
Visit http://your-server-ip/ in your browser to view the application.
After deploying your application, verify that each component of the TALL stack is functioning correctly.
Tailwind CSS provides utility-first CSS classes that allow you to style elements directly in your HTML. Follow these steps to verify Tailwind is working:
Navigate to the tallisman directory.
Open the welcome view file.
Modify the heading by adding Tailwind classes.
Save and close the file.
Rebuild the assets to apply the changes.
Visit http://your-server-ip/ in your browser. You should see a large, bold, underlined heading with blue decoration.
Livewire enables you to build dynamic interfaces using PHP without writing JavaScript. Create a simple counter component to test Livewire:
Create a new Livewire component.
This generates two files:
app/Livewire/Counter.php - The component logicresources/views/livewire/counter.blade.php - The component viewOpen the Counter component class.
Replace the contents with:
Save and close the file.
Open the counter view file.
Replace the existing content with the following content:
Save and close the file.
Open the welcome view to include the Livewire component.
Add the Livewire component after the heading:
Save and close the file.
Rebuild the assets to compile the new CSS classes.
Visit http://your-server-ip/ and test the counter buttons. The count should update without a page refresh.
Alpine.js provides lightweight JavaScript functionality for interactive elements. Add a simple toggle component to verify Alpine.js:
Navigate to the tallisman directory.
Open the welcome view file.
Add an Alpine.js toggle component:
Save and close the file.
Rebuild the assets to compile the new CSS classes.
Visit http://your-server-ip/ and click the toggle button. The content should smoothly appear and disappear with transitions.
Once your TALL stack application is verified, secure it with TLS certificates to enable HTTPS connections and protect user data. Use Certbot to generate and manage these certificates.
Install the Certbot Let's Encrypt client plugin for Apache.
Request a new Let's Encrypt SSL certificate for your domain. Replace app.example.com with your domain and email@example.com with your email address.
The --redirect option automatically configures Apache to redirect HTTP traffic to HTTPS.
Let's Encrypt certificates are valid for 90 days and automatically renew via a systemd timer. You can check the renewal timer status with systemctl list-timers | grep certbot.
Restart Apache to apply the SSL configuration changes.
Visit https://app.example.com in your browser to verify HTTPS is working. A padlock icon in the address bar indicates a secure connection.
You have successfully deployed a TALL stack application on Vultr using the Laravel Marketplace App. You secured MySQL, configured environment variables, installed backend and frontend dependencies, set proper file permissions, and created a custom Apache virtual host. You also set TLS encryption to enable secure HTTPS access.
0 Comments
Be the first to comment and share your perspective with the community.