Skip to content

Instantly share code, notes, and snippets.

@hamidne
Last active January 6, 2021 17:21
Show Gist options
  • Save hamidne/f20e4cd22fed6eb24200ab36845a98ef to your computer and use it in GitHub Desktop.
Save hamidne/f20e4cd22fed6eb24200ab36845a98ef to your computer and use it in GitHub Desktop.
Install LEMP in centos 7

Install Dependencies

sudo yum install -y epel-release
sudo yum install -y http://rpms.remirepo.net/enterprise/remi-release-7.rpm
sudo yum install -y yum-utils

sudo yum groupinstall -y 'Development Tools'
sudo yum install -y pcre perl pcre-devel zlib zlib-devel openssl openssl-devel

Download nginx from source:

wget https://nginx.org/download/nginx-1.17.6.tar.gz

Extract and config and install:

tar -zxvf nginx-1.17.6.tar.gz
cd nginx-1.17.6
./configure --sbin-path=/usr/bin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --with-pcre --pid-path=/var/run/nginx.pid --with-http_ssl_module --with-http_v2_module --with-http_image_filter_module
make
sudo make install

Enable Systemd - source

go to /lib/systemd/system/nginx.service and write this :

[Unit]
Description=The NGINX HTTP and reverse proxy server
After=syslog.target network.target remote-fs.target nss-lookup.target

[Service]
Type=forking
PIDFile=/var/run/nginx.pid
ExecStartPre=/usr/bin/nginx -t
ExecStart=/usr/bin/nginx
ExecReload=/usr/bin/nginx -s reload
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true

[Install]
WantedBy=multi-user.target

Step 4 : Enable nginx when start server

sudo systemctl enable nginx
sudo systemctl start nginx
sudo systemctl status nginx

Enable remi-php73 Repository

sudo yum-config-manager --enable remi-php73

install PHP 7.3

sudo yum install -y php php-fpm php-gd php-json php-mbstring php-mysqlnd php-xml php-xmlrpc php-opcache php-process php-bcmath php-zip php-soap

Enable and Start PHP-FPM

sudo systemctl enable php-fpm
sudo systemctl start php-fpm
sudo systemctl status php-fpm

Add mariaDB repo to yum library - Source

create file /etc/yum.repos.d/MariaDB.repo and paste

# MariaDB 10.4 CentOS repository list - created 2019-12-19 12:53 UTC
# http://downloads.mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.4/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1

Install MariaDB

yum install -y MariaDB-server MariaDB-client

Enable MariaDB run at boot OS

systemctl enable mariadb
systemctl start mariadb
systemctl status mariadb

Add password for MariaDB

mysql_secure_installation

Install phpMyAdmin

yum --enablerepo=remi,remi-test  install phpMyAdmin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment