How to Install LEMP & Docker on CentOs8

How to install a LEMP server on CentOS 8

sudo dnf update

sudo dnf install nginx

sudo systemctl enable nginx

sudo systemctl start nginx

sudo systemctl status nginx

nginx -v

rpm -qi nginx

sudo dnf install mariadb-server mariadb -y

sudo systemctl enable mariadb

sudo systemctl start mariadb

sudo systemctl status mariadb

sudo mysql_secure_installation

mysql -u root -p

sudo dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm

sudo dnf install dnf-utils http://rpms.remirepo.net/enterprise/remi-release-8.rpm

sudo dnf module list php

sudo dnf module reset php

sudo dnf module enable php:remi-7.4

sudo dnf install php php-opcache php-gd php-curl php-mysqlnd

php -v

sudo systemctl enable php-fpm

sudo systemctl start php-fpm

sudo systemctl status php-fpm

yum install nano -y

nano /etc/php-fpm.d/www.conf
user = apache
group = apache

เปลี่ยนเป็น

user = nginx
group = nginx

 

nano /usr/share/nginx/html/index.php
<?php
phpinfo();
?>

 

sudo systemctl restart nginx

sudo systemctl restart php-fpm

Install phpMyAdmin

sudo yum update

yum install wget -y

wget https://files.phpmyadmin.net/phpMyAdmin/5.0.1/phpMyAdmin-5.0.1-all-languages.tar.gz

sudo tar -zxvf phpMyAdmin-5.0.1-all-languages.tar.gz

wget https://files.phpmyadmin.net/phpMyAdmin/5.0.2/phpMyAdmin-5.0.2-all-languages.zip

yum install unzip -y

unzip phpMyAdmin-5.0.2-all-languages.zip -d /usr/share/nginx/html/

cd /usr/share/nginx/html/

mv phpMyAdmin-5.0.2-all-languages/ phpMyAdmin

cd phpMyAdmin

cp config.sample.inc.php config.inc.php

nano /etc/nginx/conf.d/phpMyAdmin.conf

server {
        server_name Your_IP_ADDRESS;
        root /usr/share/nginx/html/;
        location / {
		index index.html index.htm index.php;
        }

        location ~ \.php$ {
		include /etc/nginx/fastcgi_params;
		fastcgi_pass 127.0.0.1:9000;
		fastcgi_index index.php;
		fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html/$fastcgi_script_name;
        }
}

systemctl restart nginx

systemctl restart php-fpm

mysql -u root -p
GRANT ALL PRIVILEGES ON . TO ‘root’@’localhost’ WITH GRANT OPTION;
FLUSH PRIVILEGES;

sudo chmod 777 /var/lib/php/session/

Install Docker on Centos 8

yum remove docker docker-client \
docker-client-latest docker-common docker-latest \

docker-latest-logrotate docker-logrotate \
docker-engine

yum install -y yum-utils \
device-mapper-persistent-data lvm2

yum-config-manager \
–add-repo \
https://download.docker.com/linux/centos/docker-ce.repo

yum install -y –nobest docker-ce docker-ce-cli \
containerd.io

systemctl enable –now docker

docker version

systemctl start docker

systemctl enable docker

dnf install curl -y

curl -L “https://github.com/docker/compose/releases/download/1.27.4/docker-compose-$(uname -s)-$(uname -m)” -o /usr/local/bin/docker-compose

chmod +x /usr/local/bin/docker-compose

docker-compose –version