How to Install PHP on a VPS?
PHP is one of the most popular programming languages for creating websites. If you have a Virtual Private Server (VPS), you can install PHP on it to run your web projects. In this article, we’ll show you how to install PHP on a VPS.
1. Connect to your VPS via SSH
Before installing PHP, you need to connect to your VPS via SSH. To do this, use an SSH client, such as PuTTY on Windows or the terminal on Linux/Mac. Enter your VPS IP address, username, and password to log in.
2. Update System Packages
Before installing PHP, it is recommended to update the system packages using the following command:
sudo apt update
sudo apt upgrade
3. Install PHP and Required Packages
To install PHP on a VPS, run the following commands:
sudo apt install php php-mysql
This will install PHP and the extension for working with MySQL databases.
4. Check the PHP Version
After installing PHP, check its version with the following command:
php -v
You will see the current version of PHP on your VPS.
5. Configure PHP
To configure PHP according to your needs, edit the php.ini configuration file. You can change various settings, such as the maximum upload file size, error reporting, and others.
6. Restart the Web Server
After making changes to the PHP configuration file, you need to restart the web server for them to take effect:
sudo systemctl restart apache2
7. Done!
You now have PHP installed on your VPS. You can create and run web applications using this powerful programming language. Good luck!