Host A PHP Script Online
If you are working as a developer and desired to host and install the web application i.e., host a PHP script online, then follow the above guidelines to complete the installation process successfully.
In this article, I will walk you through a brief guideline on how to host a 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.
- The first reason is already configured servers (LAMP) that make it a lot easier to host a 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.
What will you need
If you want to install WordPress on DigitalOcean then you need this article to follow
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:
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:
Then, change the directory to /var/www/html by running the following command:
Unzip the files by running the following command:
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.
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;
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.
Thanks for Reading.