- By asma
- September 5, 2023
If you are working as a developer and desire to host a PHP script 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:
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.
When getting started, a Public VPS Server is the first thing you need to host your PHP web application. So, in this scenario, I will use Digital Ocean for the VPS Server for the following two reasons:
If you want to install WordPress on DigitalOcean then you need this article to follow
You will get the email containing the root default password when you create the Droplet. So, use the Putty SSH Client to connect to your Droplet and reset the password.
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.
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
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 is not locally 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:
Now, point your domain name to your IP address in the DNS management zone. That’s it.
Thanks for Reading.