Selasa, 21 Februari 2023

Cara instalasi web server nginx dan php-fpm pada Server CentOS 7 | 21 Feb 2023

 referensi : https://www.youtube.com/watch?v=RqYFHD0bgUE&ab_channel=impstudio


#NGINX

sudo yum -y install epel-release

sudo yum -y install nginx


sudo systemctl start nginx

sudo systemctl enable nginx


sudo firewall-cmd --add-service=http --permanent

sudo firewall-cmd --add-service=https --permanent

sudo firewall-cmd --reload


#PHP-FPM

--cd /tmp

--sudo yum -y install wget

--sudo wget -q http://rpms.remirepo.net/enterprise/remi-release-7.rpm

--sudo rpm -Uvh remi-release-7.rpm


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


sudo yum -y install yum-utils

sudo yum-config-manager --enable remi-php74


sudo yum -y install php-fpm php-common

sudo yum -y install php-opcache php-pecl-apcu php-cli php-pear php-pdo php-mysqlnd php-pgsql \

php-pecl-mongodb php-pecl-redis php-pecl-memcache php-pecl-memcached php-gd php-mbstring \

php-mcrypt php-xml


sudo vim /etc/php.ini

cgi.fix_pathinfo=0

date.timezone = Asia/Jakarta


sudo vim /etc/php-fpm.d/www.conf

user = nginx

group = nginx

listen.owner = nginx

listen.group = nginx

listen.mode = 0660


sudo systemctl start php-fpm

sudo systemctl enable php-fpm


#KONFIGURASI NGINX

server {

    listen 80;

    server_name localhost;

    root /var/www/example;

    index index.php index.html index.htm;


    location / {

      try_files $uri $uri/ /index.php;

    }


    location ~ \.php$ {

      try_files $uri =404;

      fastcgi_pass localhost:9000;

      fastcgi_index index.php;

      fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

      include fastcgi_params;

   }

}


sudo vim /var/www/example/index.php


phpinfo();



sudo service nginx restart

Tidak ada komentar:

Posting Komentar