If you have purchased a PHP script and want to know how to host a PHP Script Online in less than 10 minutes as a web application on the internet?

Then follow up with me.

Moreover, this article will give you easy and simple step-by-step guides on How to host any PHP script online in less than 10 minutes.

I will define and review the most important concepts like:

  • Creating a VPS Server
  • Configuring the Server Using Putty SSH Client
  • Uploading File to the Server using FileZilla or WinSCP
  • Installing PHP Modules
  • Managing MySQL Databases
  • Setting up cronjobs, and
  • Mapping Domain Name

I will not host any PHP Script here but don’t worry, I will use the “Example” name as my PHP Script. Furthermore, I will add the SSH commands and how to install any PHP Modules, the Database, and Cronjobs.

Therefore, it will be an excellent example to follow up and grasp almost all of the terms you could confront while hosting and setting up any PHP Application.

Getting Started – How To Host a PHP Script Online

You will first need a VPS (Virtual Private Server) to host your PHP web application. So, I will use the DigitalOcean to obtain a VPS Server, and why DigitalOcean? 

How to host a PHP script online-VPS (LAMP) Servers

It is because of two reasons:

  1. DigitalOcean is already configured with (LAMP) Servers to host websites, which makes the process simple. Therefore, there is no need for the installation of PHP, MySQL Database, Apache server, or anything else.
  2. They’ll give you a $100 credit coupon for free so that you can try everything at zero cost for 60 days.

So sign up, make a VPS Droplet Machine, and ensure that you choose Lamp Server for the Server System, as shown in the picture.

Reset Droplet Password

Now you need to download Putty, an SSH Client, and reset your password to connect to your Server.

When you create the Droplet, You will get an email sent from DigitalOcean, containing your server credentials like server IP, Username and Password, or the default password for the root.

How to host a PHP script online-Reset Droplet Password Putty SSH client

Why do you need to reset your password? 

Because sometimes, when you create your Droplet in DigitalOcean, It generates a default username and password for your Server.

When you connect to your Server using the Putty SSH client, It asks you to enter your password and then reset your default generated password with a new one to connect to the server.

Upload PHP Files to Your Server

Connect to your VPS Server by using WinSCP or FileZilla, and Upload the PHP script Files on the Server in this location as shown down below:


By default, you will see a file such as “index.html” in that directory.

Just delete it, Drag, and Drop your Script.

In this case, If you are dealing with a Zipped File.

Therefore, You should extract it by giving the following commands to unzip the file using the Putty SSH Client.

 sudo apt-get install unzip

Clean the putty screen to make it clear with the following command:


Change the directory to /var/www/html by using this command:

cd /var/www/html

Type this command to list the files that exist in the directory:


Then unzip the “.zip” file by the following command:

unzip example.zip

Note: Your PHP Script file’s name might differ, and to make it clear, I used “example” as my file name; you should change the “example” and type your file name. 

After you have successfully unzipped the file using WinSCP.

Then you have to Drag and Drop your Script to the most recent content folder into the upper directory “/var/www/” below the “Html” folder.

Upload PHP Files to Your Server Drag and Drop

Delete the previous “Html” folder and instead rename your PHP Script “example” as the “Html” folder.

Upload PHP Files to Your Server Drag and Drop

Follow the steps shown in the picture.

In this manner, Your PHP files are in the Html folder, which means that they can be directly accessed using Your Domain’s name.

Start Installation

You can now open your browser and type your droplet Server IP, and You will be able to see the startup page of the PHP application you installed.

Install PHP modules

Every PHP Scripts module will be different, so the main command is “Sudo apt install” but to make it clear, I will add some module commands as an example to show you how to run the command to install the PHP Scripts modules.

Open the Putty application again, and execute these instructions for installing PHP modules:

sudo apt install PHP-curl                                                              or 
sudo apt install PHP-mbstring

Here “PHP-curl and “PHP-mbstring” are an example and instead of that suffixes you should put your module names, But many Scripts also have these modules to be installed, and if your scripts have these modules too, you can copy and paste them to install them one by one.

Then, Restart your Apache Server with this command:

sudo service apache2 restart

Create the Database

1. Open the Putty SSH Client and execute the following command:

mysql -u root -p

Log in to “MySQL” by using your password.

2. Build a database by using this command:


Note: You have to change the “example” and instead can give any name you want. 

3. Create a brand new user if the root isn’t accessed by local:

CREATE USER ‘example’@’localhost’ IDENTIFIED BY ‘example_db_pass123’;

Note: Remember to give the name of your choice in all “example” sections and run the commands one by one after each other.

Grant all Privileges:

GRANT ALL PRIVILEGES ON * . * TO ‘example’@’localhost’;

Flush Privileges:


Setup Cronjobs

Open the WinSCP application, go to the “/etc” directory folder, and Open the “crontab” or (it may differ due to various types of scripts file) using the editor. 

Copy all the cronjobs from the Script you use, and paste them on the “crontab” as shown in the picture.

Setup cronjobs

How To Host a PHP Script Online Final Step

Mapping Domain Name

The last step is to connect your Domain to your IP address within the DNS management zone.


In case if you are using Namecheap as your domain name provider, follow these steps:

1. Log in to your account.

2. Go to your “Domain list” on your Dashboard.

3. Find your Domain name and click on “Manage”.

4. Go to the “Advanced DNS” and click on “Add New Record”.

5. Select ” A Record” 

  • Host: @
  • IP Address: Your Server IP
  • TTL: Automatic

It is Done; wait a few minutes for configuration.


In case if you are using GoDaddy as your domain name provider, follow these steps:

1. Log in to your account.

2. Go to your “Manage Domain”.

3. Find and Select your Domain.

4. Click on “” in front of your Domain and select “Manage DNS”.

5. Select “A Record“.

  • Host: @
  • Points to: Your Server IP
  • TTL: 1 Hour

It is Done; wait a few minutes for configuration.

So, I hope you enjoyed it and found this article helpful. 

However, comment down If you have any questions about How to host a PHP script online or how to create a WordPress website, I will be here to help you.