10

DISCOUNT

REGISTER NOW

How to Install LAMP (Linux,Apache,MySQL,PHP) on Centos 7 Instance

A "LAMP" stack is a group of open source software that is typically installed together to enable a server to host dynamic websites and web apps.

Before you begin with this guide, you should install Apache Web Server by following this guide and you should install MySQL by following this  guide. After that we will install PHP to complete our LAMP stack.

PHP will process code to display dynamic content and it can connect to our MySQL databases and it can run scripts. We should install some helper packages for PHP to talk to MySQL and run PHP code under the Apache server.

$ sudo yum install php php-mysql -y

After installation is completed, you should restart apache servise by typing:

$ sudo systemctl restart httpd.service

After that, we will test our server with simple PHP script located at /var/www/html/ , info.php:

$ sudo vi /var/www/html/info.php
<?php
phpinfo();
?>

After that save and close the file.

Now we can test our web server can correctly display content generated by a PHP script. For visiting this page, you should write your instance public ip to web browser search bar like this:

YOUR_INSTANCE_PUBLIC_IP_ADDRESS/info.php

After that, the page that you come to should look like this:

centosphp.png

If you see the above page, this means your PHP is working as expected. This page gives you information about your server.

After testing PHP, you should remove info.php file because it give information about your instance to unauthorized users.

 

 

 

 

Have more questions? Submit a request
Powered by Zendesk