Deploying JavaScript and PHP Applications
Hashtags: #javascript #php #application #laravel #angular #vuejs
All our web hosting plans support PHP (backend) and JavaScript (frontend) applications, built with any framework, libraries or package manager, using SQLite or MySQL. This guide describes the process of uploading these applications created on a local server (e.g. XAMPP) to a hosting account:
Uploading an application to a hosting account
- Before uploading the application, all dependencies should already be installed, for example with
composer installandnpm run buildor the package manager commands we are using. - Make sure the application works correctly on the local server.
- Once the above is checked, begin uploading the files. On our machine, we compress the project folder and upload it via FTP:
- Now on the server, connected via SSH or using the panel’s file browser, we unzip the folder outside the public directory (public_html, httpdocs, etc.).
- Copy the files from the project’s public folder (where index.html or index.php is) to the account’s public folder mentioned above.
General steps
- If the application uses local MySQL databases, it will be necessary to create them inside the control panel:
- When we created the application, we likely configured the database connection (in a PHP file, .env, .conf, etc.). You will probably need to change the following parameters:
- Port: 3306.
- Name: the name you recreated the database with in the panel.
- User: the database user you created in the panel.
- Password: the password you set when recreating the database in the panel.
- SQLite databases should work without changes.
- Usually JavaScript frameworks will work by default.
Laravel
- In Laravel, the index.php file contains the paths to Laravel files, which remained in the folder we unzipped earlier. One option is to move the contents of that folder into the public folder. The other is to modify index.php.
- If you want to modify index.php, you must find the file and folder paths and change them. If the folder we unzipped is named laravel, we would change the paths that started with …/ to …/laravel/, or to …/[folder]/ with the name you unzipped. For example:
'/../storage/framework/maintenance.php' -> '/../laravel/storage/framework/maintenance.php'
'/../vendor/autoload.php' -> '/../laravel/vendor/autoload.php'
'/../bootstrap/app.php' -> '/../laravel/bootstrap/app.php'
- If we have not moved the contents of the original folder to the public folder, we must at least move the build folder for the site to work.