VOOZH about

URL: https://www.digitalocean.com/community/tutorials/how-to-install-linux-nginx-mysql-php-lemp-stack-on-centos-7

โ‡ฑ How To Install Linux, Nginx, MySQL, PHP (LEMP) stack On CentOS 7 | DigitalOcean


How To Install Linux, Nginx, MySQL, PHP (LEMP) stack On CentOS 7

Updated on April 21, 2020
Not using CentOS 7?
Choose a different version or distribution.
CentOS 7
๐Ÿ‘ How To Install Linux, Nginx, MySQL, PHP (LEMP) stack On CentOS 7

Introduction

A LEMP software stack is a group of open source software that is typically installed together to enable a server to host dynamic websites and web apps. This term is actually an acronym which represents the Linux operating system, with the ENginx web server (which replaces the Apache component of a LAMP stack). The site data is stored in a MySQL-based database, and dynamic content is processed by PHP.

In this guide, weโ€™ll get a LEMP stack with PHP 7.4 installed on a CentOS 7 server, using MariaDB as the database management system. MariaDB works as a drop-in replacement for the original MySQL server, which in practice means you can switch to MariaDB without having to make any configuration or code changes in your application.

Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.

Learn more about our products

About the author(s)

Software Engineer @ DigitalOcean. Former Seรฑor Technical Writer (I no longer update articles or respond to comments). Expertise in areas including Ubuntu, PostgreSQL, MySQL, and more.

๐Ÿ‘ Erika Heidi
Erika Heidi
Author
Developer Advocate
See author profile

Dev/Ops passionate about open source, PHP, and Linux. Former Senior Technical Writer at DigitalOcean. Areas of expertise include LAMP Stack, Ubuntu, Debian 11, Linux, Ansible, and more.

Still looking for an answer?

Was this helpful?

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

I have the next error when I type sudo systemctl start nginx.service

Job for nginx.service failed. See โ€˜systemctl status nginx.serviceโ€™ and โ€˜journalctl -xnโ€™ for details.

:(

@dgonzalez: Sounds like there is a typo or syntax error in your Nginx configuration file. To test it, run:

sudo nginx -t

Not all changes are highlighted red in default.conf listing in my nginx config file.

The instructions root and index are carried out into the section server{}, although by default they are found inside the section of location / {}.

Also added try_files $uri $uri/ =404; instruction into location / {}.

I think, instead of the edit file, simpler it will copy the listing of configuration proposed.

I get error: 404 Not Found when I try to access websiteaddress.com/info.php

I put info.php in /usr/share/nginx/html/ via FileZilla.

Itโ€™a all good now. :)

Thanks, d.v.bogdanov - I was stuck on this tutorial for a bit, and your comment helped me fixed the problem! :)

Yeah, thanks d.v.bogdanov and rdebeasi. I completely missed that as well. Be nice if the author could go back and make those changes a little clearer. Otherwise very helpful startup article.

To save some the headache that I went through.

  1. In the line sudo rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm : the el7 is the letter E, the letter L, the Numbr 7

  2. Before sudo yum install nginx will work, you must install EPEL. This can be done with these codes.

wget http://dl.fedoraproject.org/pub/epel/beta/7/x86_64/epel-release-7-0.2.noarch.rpm

rpm -ivh epel-release-7-0.2.noarch.rpm

works for me all but a small detail that I can not fix โ€ฆ

when I put in the nginx configuration file (/etc/nginx/nginx.conf) about โ€œlisten = /var/run/php-fpm/php-fpm.sock " the web does not work, I get a little clear errorโ€

the file โ€œ/etc/nginx/conf.d/default.confโ€ is well configured with the following "fastcgi_pass unix:/var/run/php-fpm/ php-fpm.sock; " but does not work.

however when I put in the two configuration files that โ€œ127.0.0.1:9000โ€ if it works

the question is, what can be the problem? in the tutorial I see that you just have to edit what I put, but it may be that I miss something?

thank you very much for your tutorial and help

๐Ÿ‘ Creative Commons
This work is licensed under a Creative Commons Attribution-NonCommercial- ShareAlike 4.0 International License.
  • Deploy on DigitalOcean

    Click below to sign up for DigitalOcean's virtual machines, Databases, and AIML products.

Become a contributor for community

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and AI-native businesses

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOceanโ€™s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

The developer cloud

Scale up as you grow โ€” whether you're running one virtual machine or ten thousand.

Start building today

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.

ยฉ 2026 DigitalOcean, LLC.Sitemap.
Dark mode is coming soon.