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, 2019 in Others by Vijay
1,123 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, 2019 by Abha
• 28,140 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, 2019 in Others by Anvi
• 14,150 points
1,297 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, 2019 in Others by Anvi
• 14,150 points
1,934 views
0 votes
1 answer

How to run C# code on Ubuntu

Hey @Abha, you can create and run ...READ MORE

answered Mar 1, 2019 in Others by Anvi
• 14,150 points
6,523 views
0 votes
0 answers

EC2 Ubuntu hangs on go install

I am running the golang rest API ...READ MORE

Apr 4, 2022 in Others by Kichu
• 19,040 points
530 views
0 votes
1 answer
0 votes
2 answers

Install postgreSQL on Ubuntu

Follow the below commands to install PostgreSQL (PSQL) ...READ MORE

answered Nov 12, 2020 in Database by Prachi
• 140 points
1,307 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
1,210 views
0 votes
1 answer

Install Python on Ubuntu

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

answered Mar 1, 2019 in Python by Pratibha
• 3,690 points
1,172 views
0 votes
1 answer

Perl Install on Ubuntu

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

answered Mar 1, 2019 in Others by Abha
• 28,140 points
6,643 views
0 votes
1 answer

How do I install Ruby on Rails?

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

answered Mar 1, 2019 in Others by Abha
• 28,140 points
1,469 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP