Installing Apache web server and PHP on the linux machine

Rating: 2.50 Votes: 1
Nov 21, 2019
2388 Views
3 Comments

Installing Apache web server on the Linux machine is hardly an issue. I recommend that first you update the repository of your linux machine, that means updating of mirror site urls in the .repo file from where Apache packages are being downloaded with all of their dependent packages. In the ubuntu you may get this file at /etc/apt/sources.list and in fedora it is at /etc/yum.repos.d/. Make sure your internet connectivity is strong while you install Apache and PHP described in this post as commands being used here are downloading all dependencies.

Now open the command prompt window of your linux machine (you must know what that is).

If you are using Fedora / RHEL / CentOS, type the following command:

sudo   yum   update

This will update installed all packages in your Linux.

Now run the command for Fedora / RHEL / CentOs to start installation of Apache web server.

sudo    yum    install    httpd

And start the apache web server with

sudo      /etc/init.d/httpd      start    or    systemctl start httpd.service

You will prefer to start Apache web server in your machine as soon you boot and load the Linux in your machine so you do not have to explicitly start Apache every time you start the machine.

Use following to get apache starts automatic with the Linux is loaded,

sudo    chkconfig    httpd   on       or       systemctl enable httpd.service

Install PHP with the following command

sudo    yum    install   php    php-common    php-cli    php-mysqlnd  …….

Space separated list of packages you want to install.

You can also execute a one liner command to install Apache and PHP like,

sudo   yum   install   httpd   httpd-devel   mysql   php   php-mysql   php-common   php-gd   php-mbstring   php-mcrypt   php-devel   php-xml   –y

 

Mostly you will find the configuration file for apache web server under etc/httpd/conf/httpd.conf.  And the last line should install PHP version 5.X whichever is latest in your repo file, will be installed.

Using my favorite debian or ubuntu flavor of linux!! follow this. Explanations for ubuntu commands are almost same as Fedora or CentOS.

sudo      apt-get      update

sudo      apt-get     install     apache2

Now use the command to start the apache web server.

sudo       /etc/init.d/apache2      start

Start  Aapche with the Ubuntu is boot and is loaded, with the command

sudo   chkconfig   apache2   enable   or   sysv-rc-conf  apache2  on

Install PHP with the following command

sudo     apt-get    install   php5  libapache2-mod-php5     php5-gd    php5-mysql ……

Space separated list of packages you want to install.

If you hit the “localhost” in the browser url bar, it should show the page “It works”. That’s it for the Apache Web Server and PHP.  This post just explains what you can do to install the Apache web server and PHP on the linux. Check the other post in the configuration category, if you want to know how PHP is configured with Apache to work together.

Keep me posting better ways of installations of Apache and PHP on the linux platform. Also let me know about your major troubleshooting and how you resolved that in this task to become helpful to others.

Leave Comment

The date and time of submission and your device`s IP address will be recorded when you click Save comment.
You can enter your social network profile link here
Answer simple math : 6 + 2 = ?

3 Comments