Call + (44) 0843 289 4539

0
  • No products in the cart.

Upgrade from LAMP to LEMP ubuntu 14.04

I needed to upgrade my Ubuntu 14.04 LAMP (Linux, Apache, MySql, PHP5) stack development machine to a LEMP (Linux, Nginx, MySQL, PHP7).  My first instinct was to turn to the internet and consult the millions of blog posts and forum posts, but they all seem to be lacking vital bit of information I was after in my particular situation.

I have detailed the complete steps I undertook to complete the upgrade.

Remove PHP 5

I wanted to completely remove PHP5 from my workstation.  I found by using the bash command was the best approach

[pastacode manual=”sudo%20bash%20-c%20%22sudo%20apt-get%20remove%20php*%22%0D%0Asudo%20apt-get%20update%0D%0Asudo%20apt-get%20purge%20php5-fpm%0D%0Asudo%20apt-get%20–purge%20autoremove%0D%0A” provider=”manual” lang=”sh”/]

Remove phpMyAdmin

Although this command is not necessarily for removing phpMyAdmin, it appears when you remove php5-mcrypt it removes phpmyadmin.

[pastacode manual=”sudo%20apt-get%20purge%20php5-mcrypt” provider=”manual” lang=”sh”/]

Remove Apache

[pastacode manual=”sudo%20apt-get%20remove%20apache2*%0D%0A” provider=”manual” lang=”javascript”/]

Once complete ensure all is clean by executing an autoremove

[pastacode manual=”sudo%20apt-get%20autoremove” provider=”manual” lang=”javascript”/]

Our workstation should now be ready for re-configuring it for LEMP.

Install PHP7

It seems that PHP7 is not currently in the default ubuntu repository, so we will need to add a private repository .

[pastacode manual=”sudo%20add-apt-repository%20ppa%3Aondrej%2Fphp%0D%0A” provider=”manual” lang=”javascript”/]

Now install all the PHP modules required

[pastacode manual=”sudo%20apt-get%20install%20php7.0-fpm%20php7.0-mysql%20php7.0-curl%20php7.0-gd%20php7.0-json%20php7.0-mcrypt%20php7.0-opcache%20php7.0-xml%20php7-mbstring%0D%0A” provider=”manual” lang=”sh”/]

Install NGINX

[pastacode manual=”%20sudo%20apt-get%20install%20nginx” provider=”manual” lang=”sh”/]

Update NGINX Default site configuration

I just used Gedit to open the file and copied and pasted the configuration over.

[pastacode manual=”sudo%20gedit%20%2Fetc%2Fnginx%2Fsites-enabled%2Fdefault” provider=”manual” lang=”sh”/]

[pastacode manual=”server%20%7B%0D%0A%20%20%20%20listen%2080%20default_server%3B%0D%0A%20%20%20%20listen%20%5B%3A%3A%5D%3A80%20default_server%20ipv6only%3Don%3B%0D%0A%0D%0A%20%20%20%20root%20%2Fvar%2Fwww%2Fhtml%3B%0D%0A%20%20%20%20index%20index.php%20index.html%20index.htm%3B%0D%0A%0D%0A%20%20%20%20server_name%20localhost%3B%0D%0A%0D%0A%20%20%20%20location%20%2F%20%7B%0D%0A%20%20%20%20%20%20%20%20try_files%20%24uri%20%24uri%2F%20%3D404%3B%0D%0A%20%20%20%20%7D%0D%0A%0D%0A%20%20%20%20error_page%20404%20%2F404.html%3B%0D%0A%20%20%20%20error_page%20500%20502%20503%20504%20%2F50x.html%3B%0D%0A%20%20%20%20location%20%3D%20%2F50x.html%20%7B%0D%0A%20%20%20%20%20%20%20%20root%20%2Fusr%2Fshare%2Fnginx%2Fhtml%3B%0D%0A%20%20%20%20%7D%0D%0A%0D%0A%20%20%20%20location%20~%20%5C.php%24%20%7B%0D%0A%20%20%20%20%20%20%20%20try_files%20%24uri%20%3D404%3B%0D%0A%20%20%20%20%20%20%20%20fastcgi_split_path_info%20%5E(.%2B%5C.php)(%2F.%2B)%24%3B%0D%0A%20%20%20%20%20%20%20%20fastcgi_pass%20unix%3A%2Fvar%2Frun%2Fphp%2Fphp7.0-fpm.sock%3B%0D%0A%20%20%20%20%20%20%20%20fastcgi_index%20index.php%3B%0D%0A%20%20%20%20%20%20%20%20fastcgi_param%20SCRIPT_FILENAME%20%24document_root%24fastcgi_script_name%3B%0D%0A%20%20%20%20%20%20%20%20include%20fastcgi_params%3B%0D%0A%20%20%20%20%7D%0D%0A%7D” provider=”manual” lang=”php”/]

Save and close Gedit and now we can test our configuration

[pastacode manual=”sudo%20nginx%20-t” provider=”manual” lang=”sh”/]

We also edit the PHP.ini file

[pastacode manual=”sudo%20gedit%20%2Fetc%2Fphp%2F7.0%2Ffpm%2Fphp.ini%0D%0A” provider=”manual” lang=”sh”/]

Findcgi.fix_pathinfo without quotation mark. change its value to 0 like this: cgi.fix_pathinfo=0 and save it

Install the new PHP-FPM package

[pastacode manual=”sudo%20apt-get%20install%20php7.0-fpm” provider=”manual” lang=”php”/]

Install phpMyadmin

[pastacode manual=”sudo%20apt-get%20install%20phpmyadmin%0D%0Asudo%20ln%20-s%20%2Fusr%2Fshare%2Fphpmyadmin%2F%20%2Fvar%2Fwww%2Fhtml%2F%0D%0Asudo%20service%20nginx%20restart” provider=”manual” lang=”javascript”/]

 

Follow Me

Gary Woodfine

Helps businesses by improving their technical proficiencies and eliminating waste from the software development pipelines.

A unique background as business owner, marketing, software development and business development ensures that he can offer the optimum business consultancy services across a wide spectrum of business challenges.
Follow Me
Advertisements