Cara Install Nginx Server, PHP 7, PhpMyadmin Pada Ubuntu


Berikut langkah demi langkah menginstall nginx pada linux ubuntu :
  1. Menghapus lampp yang sudah terinstall
          
    $ sudo apt-get purge apache2* php5* mysql* phpmyadmin*
    $ sudo apt-get autoremove
    $ sudo apt-get autoclean
         
        
  2. Menghapus konfigurasi file apache
          
    $ whereis apache2
    $ sudo rm -Rf /usr/sbin/apache2 /usr/lib/apache2 /etc/apache2 /usr/share/apache2 /usr/share/man/man8/apache2.8.gz
         
        
  3. Menghapus konfigurasi file MySql
          
    $ sudo rm -Rf /var/lib/mysql/
    $ sudo rm -Rf /etc/mysql/
         
        
  4. Install NGINX dibaca (Engine X)
          
    $ sudo sh -c "echo 'deb http://nginx.org/packages/ubuntu/ `lsb_release -cs` nginx' >> /etc/apt/sources.list"
    $ sudo sh -c "echo 'deb-src http://nginx.org/packages/ubuntu/ `lsb_release -cs` nginx' >> /etc/apt/sources.list"
    $ curl http://nginx.org/keys/nginx_signing.key | apt-key add -
    $ sudo apt-get update
    $ sudo apt-get install nginx
         
        
  5. Install MariaDB
          
    [Add MariaDB 10.1 Repo]
    $ sudo apt-get install software-properties-common
    $ sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xcbcb082a1bb943db
    $ sudo add-apt-repository 'deb [arch=amd64,i386] http://mirrors.opencas.cn/mariadb/repo/10.1/ubuntu '$(lsb_release -cs)' main'
    $ sudo apt-get update
    $ sudo apt-get -y install mariadb-server
    
    [Start, enable & status checking systemd System]
    $ sudo systemctl start mariadb.service
    $ sudo systemctl enable mariadb.service
    $ sudo systemctl status mariadb.service
    
    [Start, enable & status checking Sysvinit System]
    $ sudo service mysqld start
    $ sudo chkconfig mysqld on
         
        
  6. Konfigurasi password MySql
          
    [MariaDB Secure installation]
    $ sudo mysql_secure_installation
    
    Enter current password for root (enter for none): Enter Your Current Password
    OK, successfully used password, moving on...
    
    Set root password? [Y/n] n
     ... skipping.
    
    Remove anonymous users? [Y/n] y
     ... Success!
    
    Disallow root login remotely? [Y/n] y
     ... Success!
    
    Remove test database and access to it? [Y/n] y
     - Dropping test database...
     ... Success!
     - Removing privileges on test database...
     ... Success!
    
    Reload privilege tables now? [Y/n] y
     ... Success!
    
    Cleaning up...
    
    All done!  If you've completed all of the above steps, your MariaDB
    installation should now be secure.
    
    Thanks for using MariaDB!
         
        
  7. Install PHP-FPM & Modul PHP
          
    [Install php7]
    $ sudo apt-get install php7.0 php7.0-fpm php7.0-mysql php7.0-mbstring php7.0-common php7.0-gd php7.0-mcrypt php-gettext php7.0-curl php7.0-cli php7.0-xml
         
        
  8. Konfigurasi PHP
          
    [For php7]
    $ sudo gedit /etc/php/7.0/fpm/php.ini
    
    cgi.fix_pathinfo=0
         
        
  9. Konfigurasi Nginx
          
    $ gedit /etc/nginx/nginx.conf
    
    user www-data;
    worker_processes 4;  
         
        
          
    server 
    {
            listen 8000;
     # ssl    on;
     server_name localhost;
    
            root /usr/share/nginx/html;
    
            index index.php index.html index.htm;
            
     error_page 404 /404.html;
            error_page 500 502 503 504 /50x.html;
    
    # Redirect server error pages to the static page #        
            location / 
     {
      try_files $uri $uri/ /index.php;
            }
    
            location = /50x.html 
     {
             root /usr/share/nginx/html;
            }
    
    # Pass the PHP scripts to FastCGI server # 
     location ~ \.php$ 
     {
      try_files $uri =404;
      fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
      fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
      fastcgi_index index.php;
      include fastcgi_params;
            }
    }
         
        
  10. Test konfigurasi
          
    $ sudo nano /usr/share/nginx/html/phpinfo.php
    
    
         
        
  11. Menjalankan untuk test Konfigurasi nginx
          
    $ sudo nginx -t
    nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
    nginx: configuration file /etc/nginx/nginx.conf test is successful
         
        
  12. Restart Nginx
          
    $ sudo service nginx restart
     * Restarting nginx nginx                                                [ OK ] 
         
        
  13. Install pohpmyadmin
          
    $ sudo apt-get -y install phpmyadmin
         
        
  14. Membuat symlink dari phpmyadmin
          
    $ sudo ln -s /usr/share/phpmyadmin /usr/share/nginx/html
         
        

Subscribe to receive free email updates: