Cara Install Linux Nginx MySQL PHP CentOS Bab1

berikut ini adalah tutorial Cara Install Linux Nginx MySQL PHP CentOS Bab1, sebagai informasi untuk pembaca GemarOprek. blog ini sudah tidak menggunakan kloxoMR sebagai control panelnya, hal ini karena keinginan penulis untuk “kembali ke jalan yang benar”, eh?

alasan utama penulis meng-downgrade server ini menggunakan versi manual dengan LEMP (Linux, Nginx, MariaDB, PHP) adalah untuk lebih membiasakan diri dengan keyboard daripada klik-klik.

kali ini saya akan berbagi tutorial menginstall LEMP + varnish, sebelum memulai dan mengikuti tutorial ini. ada baiknya anda compare dahulu system yang telah ada seperti apache dan MySQL untuk meminimalisir kesalahan yang tidak diinginkan.

  • Migration Apache to Nginx (cooming soon)

Saran dari saya, ada baiknya backup data website/blog anda dan reinstall server atau VPS anda. hal ini akan lebih memudahkan anda dalam bereksplorasi

Namun jika anda telah membaca tutorial diatas, mari kita mulai untuk menginstall LEMP

Cara Install Linux Nginx MySQL PHP CentOS Bab1

pertama-tama, cek terlebih dahulu versi Centos anda dengan perintah

[root@oprek ~]# uname -m
i686

lalu cari repo yang sesuai dengan versi CentOS anda pada link ini

Baca juga:  Restore file permission Pada RHEL

selanjutnya pastikan apache dan MySQL tidak terinstall

[root@oprek ~]# yum -y remove httpd
[root@oprek ~]# yum -y remove mysql* mysql-server mysql-devel mysql-libs
  • install Nginx
[root@oprek ~]# yum update && yum upgrade
[root@oprek ~]# wget http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
[root@oprek ~]# rpm -Uvh epel-release-6-8.noarch.rpm
[root@oprek ~]# yum repolist
[root@oprek ~]# yum -y install nginx
  • restart Nginx dan setting Nginx di startup CentOS
[root@oprek ~]# service nginx start && chkconfig nginx on
  • setting nginx untuk mencocokkan core CPU server anda:
[root@oprek ~] sed "s/.*worker_processes.*/worker_processes $(nproc);/" /etc/nginx/nginx.conf
  • Increase server bucket size untuk URL panjang dengan nginx:
sed '/^.*include /etc/nginx/.*/{s/$/\n    server_names_hash_bucket_size 64;}' /etc/nginx/nginx.conf
  • edit file /etc/nginx/conf.d/default.conf dan replace dengan nama website/blog anda
#
# The default server
#
server {
    listen       80 default_server;
    server_name  gemaroprek.com;

    #charset koi8-r;

    #access_log  logs/host.access.log  main;

    location / {
        root   /usr/share/nginx/html;
        index  index.php index.html index.htm;
        try_files $uri $uri/ /index.php?$args;
    }

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

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }

    # proxy the PHP scripts to Apache listening on 127.0.0.1:80
    #
    #location ~ \.php$ {
    #    proxy_pass   http://127.0.0.1;
    #}

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    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;
    #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        include        fastcgi_params;
    }
    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /\.ht {
    #    deny  all;
    #}
}
  • restart kembali nginx
[root@oprek ~]#  service nginx restart

download dan install REMI repository

[root@oprek ~]# wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
[root@oprek ~]# rpm -Uvh remi-release-6.rpm
[root@oprek ~]# sed "s/.*enabled=0.*/enabled=1/" /etc/yum.repos.d/remi.repo
[root@oprek ~]# yum repolist
  • enable remi repository
[root@oprek ~]# yum --enablerepo=remi-test --disablerepo=remi install compat-mysql55
  • buat file repository MariaDB pada dengan nama file /etc/yum.repos.d/mariadb.repo
[root@oprek ~]# vim /etc/yum.repos.d/mariadb.repo

isi sesuai versi OS anda

Baca juga:  Mengetahui Virtualisasi Cloud atau VPS

Untuk system 32bit

[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/5.5/centos6-x86
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1

Untuk system 64bit

[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/5.5/centos6-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
  • update kembali dengan perintah yum
[root@oprek ~]# yum -y update
[root@oprek ~]# yum -y install MariaDB-devel MariaDB-client MariaDB-server
  • restart MariaDB dan setting agar berjalan di startup CentOS
[root@oprek ~]# service mysql start && chkconfig mysql on
  • setting SQL root password:
[root@oprek ~]# /usr/bin/mysql_secure_installation
  • Install PHP
[root@oprek ~]# yum -y install php php-common php-fpm php-mysql
  • restart PHP dan setting agar berjalan di startup CentOS
[root@oprek ~]# service php-fpm start && chkconfig php-fpm on
  • Configure PHP:
[root@oprek ~]# sed "s/.*cgi.fix_pathinfo=.*/cgi.fix_pathinfo=0/" /etc/php.ini
  • setting php5-fpm user/group untuk nginx:
[root@oprek ~]# sed "s/.*user =.*/user = nginx/" etc/php-fpm.d/www.conf && sed "s/.*group =.*/group = nginx/" etc/php-fpm.d/www.conf
  • Restart php5-fpm
[root@oprek ~]# service php-fpm restart
  • buat file info.php untuk mengecek apakah server sudah berjalan dengan baik
[root@oprek ~]# echo " /usr/share/nginx/html/info.php >> echo "phpinfo();" >> /usr/share/nginx/html/info.php >> echo "?>" >> /usr/share/nginx/html/info.php

jika tidak terjadi error, berarti server telah siap digunakan namun tulisan Cara Install Linux Nginx MySQL PHP CentOS Bab1 ini semakin panjang. mari kita lanjut ke sesi ke 2

Write a Comment

Your email address will not be published.

8 + eleven =

%d bloggers like this: