LAMP stands for  Linux, Apache, MySQL, and PHP.Linux is an open source Operating System while Apache is a web server. MySQL/MariaDB is a relational database management system and PHP is a server-side scripting language. All these software must be installed on your Virtual Private Server (VPS) if you want to run most dynamic websites.

Steps to install LAMP stack on centos 7 VPS

  1. Login to root user or sudo user
  2. Update the system
    yum update <span id="mce_marker" data-mce-type="bookmark" data-mce-fragment="1">​</span>
  3. Install Apache
    yum install httpd <span id="mce_marker" data-mce-type="bookmark" data-mce-fragment="1">​</span>
  4. Next, we need to start Apache service by running the command below
    systemctl start httpd.service <span id="mce_marker" data-mce-type="bookmark" data-mce-fragment="1">​</span>

    At this point, you can enter your public IP address on a browser to confirm the installation. You should get the default Apache page as shown below:

  5. The page above indicates that Apache was installed successfully on your CentOs 7 server.

    Next, you need to activate Apache to start during system boot using the command below:

     systemctl enable httpd.service

     

  6. Install MariaDB Database.MariaDB is a forked version of MySQL.We will need MariaDB to store information for our dynamic websites. We can install MariaDB together with additional packages that we require on our CentOs server by running the commands below
    yum install mariadb-server mariadb <span id="mce_marker" data-mce-type="bookmark" data-mce-fragment="1">​</span>

     

  7. Start the service
    systemctl start mariadb <span id="mce_marker" data-mce-type="bookmark" data-mce-fragment="1">​</span>

     

  8. Securing MariaDB
    mysql_secure_installation <span id="mce_marker" data-mce-type="bookmark" data-mce-fragment="1">​</span>

    You will be prompted to enter your MariaDB root password, just press Enter because you haven’t set any password yet. Please note that this should not be confused by the root password of your server.

    Once you have done this, you will be asked a series of questions. We have provided the answers below for simplicity:

    Set root password? [Y/n] Y New password: Enter your password here Re-enter new password: repeat your password Remove anonymous users? [Y/n] Y Disallow root login remotely? [Y/n] Y Remove test database and access to it? [Y/n] Y Reload privilege tables now? [Y/n] Y <span id="mce_marker" data-mce-type="bookmark" data-mce-fragment="1">​</span>

    Finally, you will get a success message as shown below:

    ... Success! Cleaning up... All done! If you've completed all of the above steps, your MariaDB Installation should now be secure.<span id="mce_marker" data-mce-type="bookmark" data-mce-fragment="1">​</span>

     

  9. Your MariaDB server is now secure. Type the command below to enable it during boot:
    systemctl enable mariadb.service

     

  10. Install PHP
    yum install php php-mysql <span id="mce_marker" data-mce-type="bookmark" data-mce-fragment="1">​</span>
    systemctl restart httpd.service

    Test PHP

    Apache installs a default website on the directory ‘/var/www/html/’. So to test PHP on our CentOs 7 Server, we need to create a file there using a vi editor.

    vi /var/www/html/info.php

    A blank text file should be displayed, just copy paste the content below on the page:

    <?php phpinfo(); ?>

    You need to visit the following URL on your browser to check whether PHP is working:

    http://ip_address/info.php <span id="mce_marker" data-mce-type="bookmark" data-mce-fragment="1">​</span>

    Replace th ip_address with ip address of your system

    If the installation was completed without a problem, you should see the below page on the browser:

Leave a Reply

Your email address will not be published. Required fields are marked *