How to host any PHP script online | Step By Step

How to host any PHP script online | Step By Step

Host a PHP Script

If you are working as a developer and desired to host and install the web application i.e., PHP script online, then follow the above guidelines to complete the installation process successfully. 

In this article, I will show you a brief guideline on how to host any PHP Script online in a couple of minutes. So first, go through the main concept:

  • 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

Let’s start the process, here I’ll take the “XEROCHAT FACEBOOK MARKETING APPLICATION” as an example script. This script requires some PHP modules, a Database, and some cronjobs.   

You can better understand the concept through this example. So, the hosting and installing process will be easy for you to understand.

Getting Started

Getting started, Public VPS Server is the first thing you need to host your PHP web application on. So, in this scenario I will use Digital Ocean to get a VPS Server because of the following two reasons:

  • The first reason is already configured servers (LAMP) that makes a lot easier to host the PHP script. There is no need to install Apache, MYSQL, PHP, or anything else.
  • The other one is a free coupon, where you can test everything for free and just go, click and sign up to get the coupon.

Reset Droplet Password

You will get the email containing the root default password when you created the Droplet. So, use the Putty SSH Client to connect to your Droplet and reset the password.

Upload PHP Files to Your Server

Then, use the WinSCP to connect to your VPS server and update the PHP files to the server through the given path:

Getting Started

In this scenario, I have zipped files that need to be extracted. So, again to Putty SSH Client and install the unzip utility by running the following command:

sudo apt-get install unzip

Run the following command to clear the putty screen to make in clean:

clear

Then, change the directory to /var/www/html by running the following command:

cd /var/www/html

Unzip the files by running the following command:

unzip xerochat.zip

*Note:

In your case, the file name can be different so, rename the files with your file name.

Now move the content folder to the upper directory to be accessed directly -> use WinSCP.

Then drag and drop by using WinSCP

Delete the html folder and replace the “xerochat” with html.

Now your PHP files are in the html folder, so you can use your domain name to access the script directly.

Start Installation

Now you can open the application startup page by entering the Droplet IP into the browser.

Install PHP modules

Open putty, and install the PHP modules by running the following command:

sudo apt install php-curl
sudo apt install php-mbstring

Now, run the following command to restart the Apache service:

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- If the root has not local accessible, then create a new user:

CREATE USER ‘xero’@’localhost’ IDENTIFIED BY ‘Xero_db_pass123’;
GRANT ALL PRIVILEGES ON * . * TO ‘xero’@’localhost’;
FLUSH PRIVILEGES;

Setup cronjobs

Now, setup the cronjobs by following the above steps:

  • Open the WinSCP and go to /etc
  • Use the editor to open crontab and paste all the jobs from Xerochat

Now, point your domain name to your IP address in the DNS management zone. That’s it.

GoodLuck!

Thanks for Reading.

If you liked this article and want to read more of these, please subscribe to our newsletter and follow us on FacebookYouTube, and Twitter.