Install Nginx, PHP 5.6.0 and PHP-FPM on CentOS 7/6.5/5.10, Red Hat (RHEL) 7/6.5/5.10
Yang pertama kita masuk dahulu ke root, dengan perintah
# su -# enter password :
Yang kedua kita harus menginstall repository yang dibutuhkan. yaitu dengan :
## Remi Dependency on CentOS 7 and Red Hat (RHEL) 7 ##rpm –Uvh http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel–release–7–1.noarch.rpm
## CentOS 7 and Red Hat (RHEL) 7 ##
rpm –Uvh http://rpms.famillecollet.com/enterprise/remi–release–7.rpm
## Remi Dependency on CentOS 6 and Red Hat (RHEL) 6 ##
rpm –Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel–release–6–8.noarch.rpm
## CentOS 6 and Red Hat (RHEL) 6 ##
rpm –Uvh http://rpms.famillecollet.com/enterprise/remi–release–6.rpm
## Remi Dependency on CentOS 5 and Red Hat (RHEL) 5 ##
rpm –Uvh http://dl.fedoraproject.org/pub/epel/5/i386/epel–release–5–4.noarch.rpm
## CentOS 5 and Red Hat (RHEL) 5 ##
rpm –Uvh http://rpms.famillecollet.com/enterprise/remi–release–5.rpm
Ketiga membuat atau menambah file repository di /etc/yum.repos.d/nginx.repo, dan ikuti seperti berikut :
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=0
enabled=1
Keempat untuk menginstall aplikasi yang di butuh kan :
yum –enablerepo=remi,remi-php56 install nginx php-fpm php-common
Kelima ikuti perintah tersebut
yum –enablerepo=remi,remi-php56 install php-opcache php-pecl-apcu php-cli php-pear php-pdo php-mysqlnd php-pgsql php-pecl-mongo php-pecl-sqlite php-pecl-memcache php-pecl-memcached php-gd php-mbstring php-mcrypt php-xml
Keenam matikan aplikasi yang tidak di butuhkan yang telah berjalan, dan jalankan aplikasi yang akan dibutuh kan, dengan perintah sebagai berikut:
service httpd stop
service nginx start
service php-fpm start
chkconfig httpd off
chkconfig –add nginx
chkconfig –levels 235 nginx on
chkconfig –add php-fpm
chkconfig –levels 235 php-fpm on
Dan buatlah Direktori untuk penempatan file website anda :
mkdir -p /var/www/truegalih.tk/public_html
mkdir /var/www/truegalih.tk/logs
chown -R apache:apache /var/www/truegalih.tk
mkdir -p /var/www/truegalih.tk/public_html
mkdir -p /var/log/nginx/truegalih.tk
chown -R apache:apache /var/www/truegalih.tk
chown -R nginx:nginx /var/log/nginx
mkdir /etc/nginx/sites-available
mkdir /etc/nginx/sites-enabled
Ke-7 Anda harus menambahkan perintah tersebut ke /etc/nginx/nginx.conf :
include /etc/nginx/sites-enabled/*;
8 buat lah file dengan sqript berikut di direktori /etc/nginx/sites-available/truegalih.tk :
server {
server_name truegalih.tk;
access_log /var/www/truegalih.tk/logs/access.log;
error_log /var/www/truegalih.tk/logs/error.log;
root /var/www/truegalih.tk/public_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 /var/www/truegalih.tk/public_html
$fastcgi_script_name;
}
}
Ke-9 tambah kan di /etc/hosts/
127.0.0.1 localhost.localdomain localhost truegalih.tk
192.168.1.1 wordpress
Ke-10 tambahkan di /var/www/truegalih.tk/public_html/index.php
<?php
phpinfo();
?>
Matikan Selinux
nano /etc/selinux/config
SELINUX=disable
chcon -R -t httpd_sys_content_t /var/www/truegalih.tk/public_html
chcon -R -t httpd_sys_rw_content_t /var/www/truegalih.tk/public_html
Tambahkan Ip Tables
-A INPUT -m state –state NEW -m tcp -p tcp –dport 80 -j ACCEPT
/etc/init.d/iptables restart
Add New Rule to Firewalld
firewall-cmd –permanent –zone=public –add-service=http
firewall-cmd –permanent –zone=public –add –port=80/tcp
Restart firewalld.service
systemctl restart firewalld.service