You are a PHP developer or you may have purchased a PHP script but don’t know how to host a PHP Script online, Right?

Meanwhile, finding a good web server for your PHP script files can be also tough and even more difficult to get set up correctly.

But, not to worry, I am here to help.

In this step by step guide, I will show you how to install any PHP scripts online in less than 10 minutes easily and simply by giving the right command line.

As well as, this guide can help those who have purchased PHP script files from Codecanyon and want to know how to host PHP script files from Codecanyon.

I will define and review the most important concepts like:

  1. Creating a VPS Server
  2. Configuring the Server Using Putty SSH Client
  3. Uploading File to the Web Server using FileZilla or WinSCP
  4. Installing PHP Modules
  5. Managing MySQL Databases Setup
  6. Setting up Cronjobs, and
  7. Mapping Domain Name

I will not host any PHP Script files here but don’t worry, I will use the “Example” as a “Name” for my PHP file Script.

Furthermore, I will also add the SSH command line, install PHP Modules, run databases setup on the web server, and Cronjobs in this tutorial.

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

Read Also: 10 Best Email Warm up Tools – Increase Your Inbox Reputation

Getting Started – How To Host a PHP Script Online

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

How to host a PHP script online-VPS (LAMP) Servers
P.C. DIGITALOCEAN.COM

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.

Now, let’s start the installation.

Read Also: What Is Email Warm Up – Increase Email Delivery By 90%

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

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:

/var/www/html

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 writing 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:

clear

Use the following command below to change the directory to /var/www/html

cd /var/www/html

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

Ls

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

unzip example.zip

Note: Your Script file’s name might differ, and to make it clear, I used “example” as my PHP file name.

So you should change the “example” and type your PHP file name. 

If you have successfully unzipped the PHP file using WinSCP.

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

Upload PHP Files to Your Server using WinSCP

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

Upload PHP Files to Your Server using WinSCP

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

Now you can open your browser and type your droplet Server IP. After that, you will be able to see the PHP application startup page you installed.

Install PHP modules

PHP modules will be different for every PHP file but the main command is “Sudo apt install” 

However, to make it clear, I will add some PHP module commands as an example to show you how to run the commands to install any 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 the following command:

CREATE DATABASE example;

Note: You have to change the “example” and instead 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 all the following command one by one after each other.

Grant all Privileges:

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

Flush Privileges:

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

Final Step – How To Host A PHP Script Online

Domain Mapping

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

Namecheap

If your domain name provider is Namecheap go to your DNS management zone and 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.

GoDaddy

If your domain name provider is GoDaddy go to your DNS management zone and 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.

FAQs

What is PHP?

PHP is one of the server side scripting languages that’s used for web development. However, a PHP developer may also use it as a (GPP) general-purpose programming language.

A PHP code may be included in HTML code or utilized in conjunction with various web template systems, content management systems, and web platforms.

So, PHP files are generally interpreted by a PHP interpreter, which is either part of the web server or a (CGI) Common Gateway Interface executable.

The web server displays the results of the executed and interpreted PHP codes, which might be any sort of data, such as binary image data or generated HTML code.

PHP has gone through several changes since its inception in 1997. It now supports the command line interface (CLI) and can be used in standalone graphical programs.

What is a PHP Script File?

A PHP file is a text file containing code written in the PHP programming language. It may also include HTML, CSS, and JavaScript code.

Similarly, PHP files are saved with a “.php” extension.

The code in a PHP file is executed on a web server and is requested by a browser, typically through a URL or form submission.

After that, the output of the executed PHP file code is then returned to the browser to be displayed.

How Does PHP Work?

When a user requests a page that contains PHP files, the web server calls the PHP interpreter program to process the script.

Otherwise, the PHP interpreter will ignore any code in PHP scripts that are not contained within a tag.

The PHP interpreter will execute any code within the tags, and the resulting output is returned to the webserver to be displayed in the user’s browser.

Moreover, PHP scripts can also be executed from the command line or used to create standalone graphical applications.

So, I hope you have figured out how to host a PHP script online from Codecanyon and found this article helpful. 

However, comment down If you have any questions or read here if you want to know how to create a WordPress website.