#!/usr/bin/ruby puts

SunDi3yansyah

;
puts

App Server, Database App, Web App

;

Cara Install Nginx, MySQL, PHP Di CentOS

| Comments | Cahyadi Triyansyah Cahyadi Triyansyah

Pada artikel sebelumnya saya sudah menjelaskan tentang Install LEMP Di CentOS 5-6 Dan Fedora 18-13, namun disini saya akan menjabarkan lebih datail Cara Install Nginx, MySQL, PHP di CentOS menggunakan recorder.

Requirements

  • CentOS 6.*
  • Architecture i386, x86_64

Silakan di simak, recordernya. Remi repositorinya menyesuikan arsitektur OS yang kalian pakai

Anda bisa melihat command line di bawah ini untuk mengikuti dari recorder di atas.

64bit / x86_x64

1
rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

32bit / i386

1
rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm

Jika gagal download silakan menggunakan mirror, ganti dl.fedoraproject.org dengan download.fedoraproject.org tapi tetap hati-hati menggunakan mirror, takut terjadi gagal atau repositorinya 404, lanjutkan dibawah ini:

1
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
1
nano /etc/yum.repos.d/nginx.repo
1
2
3
4
5
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=0
enabled=1
1
yum --enablerepo=remi,remi-test install nginx mysql mysql-server php php-common php-fpm
1
yum --enablerepo=remi,remi-test install php-mysql php-pgsql php-sqlite php-pecl-memcache php-gd php-mbstring php-mcrypt php-xml php-pecl-apc php-cli php-pear php-pdo
1
chkconfig --levels 235 httpd off
1
service httpd stop
1
chkconfig --add nginx
1
chkconfig --add mysqld
1
chkconfig --add php-fpm
1
chkconfig --levels 235 nginx on
1
chkconfig --levels 235 mysqld on
1
chkconfig --levels 235 php-fpm on
1
service nginx start
1
service mysqld start

Konfigurasi MySQL

1
/usr/bin/mysql_secure_installation
1
service php-fpm start

Merubah user dan group

1
nano /etc/php-fpm.d/www.conf
1
2
user = nginx
group = nginx
1
nano /etc/nginx/conf.d/default.conf

Merubah config default server

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
server {
    listen 80;
    server_name DOMAINorIP;

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

    error_page  404              /404.html;
    location = /404.html {
        root   /usr/share/nginx/html;
    }

    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }

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

Selesai merubah config default server

Test php info

1
nano /usr/share/nginx/html/info.php
1
service nginx restart
1
service php-fpm restart
Comments