Host a PHP Script
If you are a PHP Developer, or anyone who bought a PHP Script and wants to host and install this PHP script (web application) Online, Then You are in the right place.
In this tutorial, I will show you a step by step guide on how to Install any PHP Script Online in 10 minutes and I will pass by the main concepts like:
- Creating a VPS Server
- Configuring the Server USing Putty SSH Client
- Uploading File to the Server using WinSCP
- Installing PHP Modules
- Managing MySQL Databases
- Setup cronjobs
- Mapping our Domain Name
I will Host an Example Script called “XEROCHAT Facebook Marketing application” which requires some PHP modules, a Database, and some cronjobs.
So it will be a good example to use in order to understand almost all the concepts that may face you while hosting and installing a PHP Application.
This article depends on my Full Video “How to Host and Install Any PHP Script Online in 10 Minutes? | Example: Xerochat from Codecanyon”, so please watch the video to understand what we are doing here.
Here is the Video:
The first thing we will need is a Public VPS Server to host our PHP web application on.
I will be using Digital Ocean to Get a VPS Server in this scenario for two reasons:
- Digital Ocean has already Configured Servers (LAMP) For hosting which makes it a lot easier as you will see later, so we don’t need to install Apache, MySQL, PHP, or anything else.
- I will give you a Free coupon, so you can test everything for free, to get the coupon, click and sign up using the link below:
So Just Signup and Create a VPS Droplet Machine and be sure to Select Lamp Server as your Server System as Explained in the Video.
Reset Droplet Password
After you create the Droplet, you will receive an email containing the root default password.
Simply connect to your Droplet using Putty SSH Client and Reset the password.
Upload PHP Files to Your Server
Connect to Your VPS Server using WinSCP, and Update the PHP Files to the server to this path: “/var/www/html”
In my case, I have a Zipped file, so I need to extract it. So again to Putty SSH CLient and Let’s install the unzip utility using the following command:
sudo apt-get install unzip
Clear putty screen to make in clean using the following command:
Change directory to /var/www/html using the following command:
Unzip the “.zip” file using the following command:
*Note: the file name may be different in your case, so replace xerochat with your file name.
Now, Move the latest folder content to the upper directory so it can be accessed directly -> use WinSCP
Just Drag and Drop using WinSCP
Then delete the html folder, and rename “xerochat” to html.
In this way, the Your PHP files are in the html folder directly, so it can be accessed directly using your domain name.
Now you can open your browser, and enter the Droplet IP and You will see the application startup page.
Install PHP modules
Open Putty, and run the following commands to install PHP Modules:
sudo apt install php-curl
sudo apt install php-mbstring
*Restart apache service using the following command:
sudo service apache2 restart
Create the Database
1- Open Putty SSH Client and run the following command:
mysql -u root -p
Login to MySQL with your root password
2- Create the database using the following command:
CREATE DATABASE xero;
3- Create a new user if root has not local accessible
CREATE USER ‘xero’@’localhost’ IDENTIFIED BY ‘Xero_db_pass123’;
GRANT ALL PRIVILEGES ON * . * TO ‘xero’@’localhost’;
Open WinSCP and got to /etc
Open crontab file using the editor
And paste all the jobs from Xerochat ( or your application) as explained in the video.
Now, the last step is to point your domain name to your IP address in the DNS management zone.