Easy way to setup apache and php7.3-fpm, mysql server on ubuntu 18.04

        When it comes to installation and configuration of a LAMP stack on ubuntu, We normally use
$ sudo apt install lamp-server^  -y
In which above will install php 7.2 along with apache 2.4 and mysql server  5.7 on ubuntu 18.04 platform .

And above stack runs by default with apache handler whcih is not recommended to run for a high traffic website, as it eats memory a lot and gives slowness while on multiple huge connection.

So the best solution is to use apache with php-fpm .
In my bellow setup i will use only few commands to install apache and php7.3 on ubuntu 18.04 .
You may search and find many article on this topic but most of them says to setup fcgid conf file in virtualhost config file. and in case you missed to copy those php-fpm lines in any of virtual host config file, site will not run php.
In my setup i am using only few commands to setup the stack and you do not need to modify anything in any file, All your sites ( virtual hosts) will continue to serve php pages using php-fpm as handler.

1) In order to install  php7.3, lets add ondrej ppa
$ sudo apt install software-properties-common
$ sudo add-apt-repository ppa:ondrej/php
$ sudo apt update


2) lets install all php modules now.
$ sudo apt install php7.3-fpm php7.3-common php7.3-mysql php7.3-xml php7.3-xmlrpc php7.3-curl php7.3-gd php7.3-imagick php7.3-cli php7.3-dev php7.3-imap php7.3-mbstring php7.3-soap php7.3-zip php7.3-bcmath -y

3) check service status of php-fpm (normally in ubuntu all services get start auto  just after install)
$ sudo service php7.3-fpm status





4) Lets install apache now
$ sudo apt install apache2


5) enable  modules for apache
$ sudo a2enmod actions fcgid alias proxy_fcgi

6) now enable php-fpm conf to apply webserver wide
$ sudo a2enconf php7.3-fpm

7) finally restart apache and php-fpm services
$ sudo systemctl restart apache2 && systemctl restart php7.3-fpm

8) if you wish to use database mysql also simply install that too.
$ sudo install mysql-server -y

9) run mysql secure installation
$ sudo mysql_secure_installation

Comments

Popular posts from this blog

Running web ssh client on port 443 /80 with nginx as reverse proxy

Running cockpit behind nginx reverse proxy with nginx ssl and cockpit non ssl

Setup VOD streaming server with nginx using RTMP on Ubuntu 18.04