Installing PHP on Ubuntu

0 votes
Can I directly install PHP on Ubuntu or do I need to install LAMP or XAMPP stack to work with PHP? Please suggest how to install in Linux? I am using a Ubuntu machine.
Mar 1 in Others by Vijay
33 views

1 answer to this question.

0 votes

Hi Vijay, althought its not necessary to install the LAMP or XAMPP stack along with PHP, but as you might know PHP is a scripting language and it needs some server to interact with. So its a good practice to install the full stack including server (Apache/Apache2) so that you can test and run your php scripts.

Now I am going to show you the step by step installation process of LAMP (Linux-Apache-MySql-PHP) stack:

1. To install Apache server, use the following command:

>>sudo apt install apache2

2. Next start installing MySQL using the mentioned command:

>>sudo apt install mysql-server

3. After installing Mysql, use this command to finally start installing PHP:

>>sudo apt install php-pear php-fpm php-dev php-zip php-curl php-xmlrpc php-gd php-mysql php-mbstring php-xml libapache2-mod-php

4. After successful installation of PHP, apache server should restart automatically. If not, type in the following command to restart it:

>>sudo service apache2 restart

5. To check whether server is running successfully, open browser and navigate to http://localhost/. You should see a web page like this:

6. And everything should be working fine now as all the installations are done. To check the php, type the following command in terminal and you should see a response like shown in screenshot below:

>>php -r 'echo "\n\nYour PHP installation is working fine.\n\n\n";'

answered Mar 1 by Abha
• 27,180 points

Related Questions In Others

0 votes
1 answer

Installling PHP on windows

As @Abha and @Abhi suggested, its best ...READ MORE

answered Feb 28 in Others by Anvi
• 13,960 points
86 views
0 votes
1 answer

How to do Installation of Ruby on Rails on Linux (Ubuntu)?

Hi Pratibha, installing ROR on ubuntu is ...READ MORE

answered Mar 1 in Others by Anvi
• 13,960 points
90 views
0 votes
1 answer
0 votes
1 answer

Using unserialize in PHP throws the same error repeatedly

I googled 'Node no longer exists', and ...READ MORE

answered Nov 14, 2018 in Others by DataKing99
• 8,130 points
162 views
0 votes
1 answer
0 votes
1 answer

Install postgreSQL on Ubuntu

Installing PostgreSQL on Ubuntu is very simple, ...READ MORE

answered Mar 22 in Database by Nitesh
60 views
0 votes
1 answer

How do I set variable if a specific package version is installed in CFEngine?

Here is what you can do.Just use packagesmatching to ...READ MORE

answered Jul 12, 2018 in Other DevOps Questions by Atul
• 10,240 points
91 views
0 votes
1 answer

Install Python on Ubuntu

@Abha you are right about pre-installation of python, ...READ MORE

answered Mar 1 in Python by Pratibha
• 3,680 points
65 views
0 votes
1 answer

Perl Install on Ubuntu

Hi Ashmita, on every ubuntu machine, perl ...READ MORE

answered Mar 1 in Others by Abha
• 27,180 points
50 views
0 votes
1 answer

How do I install Ruby on Rails?

Hi @Anvi, what @Pratibha has mentioned is ...READ MORE

answered Feb 28 in Others by Abha
• 27,180 points
57 views