To build a web environment that supports PHP on a cloud server Linux instance, follow these steps:
Choose a Linux Distribution: Common choices include Ubuntu, CentOS, or Debian. For example, Ubuntu 20.04 LTS is widely used for its stability and package support.
Install a Web Server: Apache or Nginx are popular options.
sudo apt update
sudo apt install apache2
sudo apt update
sudo apt install nginx
Install PHP and Required Extensions:
sudo apt install php libapache2-mod-php php-mysql php-curl php-gd php-mbstring php-xml php-zip
sudo yum install php php-mysqlnd php-fpm php-opcache php-gd php-curl php-mbstring php-xml php-zip
Configure the Web Server for PHP:
libapache2-mod-php is enabled. Restart Apache:sudo systemctl restart apache2
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;
}
Restart Nginx:sudo systemctl restart nginx
Test PHP: Create a info.php file in the web root (e.g., /var/www/html/ for Apache or /usr/share/nginx/html/ for Nginx):
<?php phpinfo(); ?>
Access it via http://your-server-ip/info.php to verify PHP is working.
Deploy Your Web Application: Upload your PHP files (e.g., WordPress, Laravel) to the web root. Ensure file permissions are correct (e.g., www-data user for Apache).
Use Tencent Cloud Services for Enhanced Performance and Security:
By following these steps and leveraging Tencent Cloud services, you can efficiently deploy a PHP-supported web environment on a Linux cloud server.