Blogging Mengelola VPS

Masalah dan Solusi Mengelola VPS Ubuntu 14.04

detiklife.com – Ketika kita mempertimbangkan untuk mengelola website dengan biaya murah tapi berkualitas maka pilihannya akan jatuh pada layanan VPS unmanaged. Unmanaged berarti kita sendiri yang mengelola virtual private server tersebut.  Ini adalah pekerjaan yang susah-susah-gampang. Lebih banyak sulitnya daripada mudahnya.

Walaupun akan dihadapkan dengan berbagai masalah dalam mengelola VPS, jangan khawatir, karena Anda tidak sendiri. Dengan bermodalkan kemampuan bahasa inggris yang cukup, Anda akan menemukan solusi permasalahan diberbagai forum diseluruh dunia.

Menggunakan VPS berkualitas dengan harga terjangkau adalah alur yang pasti akan dialami oleh pemilik website atau blogger. Karena biasanya, siklus seorang blogger akan melalui tahapan seperti gambar ini.

gambar siklus penggunaan hosting blogger

Tidak berhenti belajar adalah syarat mutlak bagi seorang webmaster. Karena segala sesuatu dalam industri informasi dan teknologi akan terus terbaharukan. Sistem yang terus diupdate akan menghasilkan permasalahan baru yang harus dicarikan jalan keluarnya.

Daftar dibawah ini adalah beberapa permasalahan yang biasanya akan dihadapi dalam menjalankan VPS. Solusi dan permasalahan disini adalah hasil pembelajaran dalam mengelola instalasi wordpress di LAMP Ubuntu 14.04. Catatan yang harus diperhatikan file/to/path disini harus disesuaikan dengan directory path yang Anda gunakan.

#masalah tidak bisa update atau delete plugins wordpress

cd /var/www/html
sudo chown www-data:www-data * -R
sudo usermod -a -G www-data zzzzz

*zzzzz adalah username, directory path (contoh: /var/www/html) disesuaikan dengan lokasi penyipanan file website Anda


#cara mengaktifkan module yg tidak aktif tapi dibutuhkan

sudo a2enmod expires
sudo service apache2 restart

*contoh mengaktifkan module expires yang dibutuhkan oleh wp super cache, untuk menonaktifkan perintahnya a2dismod


#cara mengganti file permission file tertentu

sudo chmod 666 /var/www/html/wp-content/wp-config.php

*ini adalah command untuk mengganti file permission wp-config.php menjadi 666


#cara mengubah file permission semua file dalam folder tertentu

sudo chmod -R 777 /Your/folder/path/

*command line untuk mengganti file permission semua file didalam folder ‘path’ menjadi 777


#cara mengubah file permission semua folder

sudo find /var/www/html -type d -exec chmod 755 {} \;

*perintah dicommand line untuk menganti semua file permission folder didalam folder ‘html’ menjadi 755


#cara mengubah file permission semua file

sudo find /var/www/html -type f -exec chmod 644 {} \;

*perintah command line untuk menganti semua file permission file didalam folder ‘html’ menjadi 644


Pembahasan lengkap mengenai pengaturan file permission standar wordpress bisa dibaca disini. Berikut adalah summary-nya

  • semua directory/folder: 755 atau 750.
  • semua file: 644 atau 640. Kecuali wp-config.php: 440 atau 400, untuk mencegah penguna lain yang mempunyai akses ke server membaca file tersebut.

#cari tahu jenis file permission yang digunakan

ls -l /path/to/file atau
stat -c “%a %n” /path/of/file

contoh: stat -c “%a %n” /var/www/html/.htaccess


#cara membuka file untuk edit

sudo nano wp-content/wp-cache-config.php

*Command line untuk membuka dan mengedit file wp-cache-config.php. Jika sudah selesai edit tekan ctrl-x lalu tekan tombol Y lalu tekan enter


#3 pilihan cara reboot/restart VPS

sudo reboot
sudo shutdown -r now
sudo shutdown -h now
*shutdown -h mengharuskan untuk menyalakan VPS dari control panel


#3 pilihan cara reboot/restart mysql

sudo service mysql start
sudo service mysql restart
sudo service mysql stop


#3 pilihan cara reboot/restart apache2

sudo service apache2 stop
sudo service apache2 restart
sudo service apache2 start


#cara reboot/restart php

sudo apache2ctl restart


#cara non aktifkan UFW (firewall)

sudo ufw disable

#cara reset UFW Rules (firewall)

sudo ufw reset


#cara memperbesar limit transfer sql pada php.ini ketika akan migrasi server

sudo nano /etc/php5/apache2/php.ini
(cari upload_max_filesize and post_max_size)
tekan ctrl-w, lalu tekan spasi, lalu ketik: 2M, ubah jadi misalnya 20M
tekan ctrl-w, lalu tekan spasi, lalu ketik: 8M, ubah jadi misalnya 80M
tekan ctrl-x, tekan tombol Y, tekan enter
sudo service apache2 restart


#cara menghapus folder dan isinya

sudo rm -rf /var/www/html/wp-content2

*command untuk menghapus folder wp-content2 beserta isi didalamnya


#cara menghapus file

sudo rm /var/www/html/wp-content.zip

*comand untuk menghapus file wp-content.zip


#cara mencari lokasi folder

sudo find / -name wp-content -type d

*instruksi untuk mencari lokasi folder wp-content


#cara mencari lokasi file

sudo find / -name wp-config.php -type f

*instruksi untuk mencari lokasi file wp-config.php


#masalah tidak bisa update core WP

“The update cannot be installed because we will be unable to copy some files. This is usually due to inconsistent file permissions.: wp-admin/includes/update-core.php”
“Cannot write directory”
“Installation Failed”

sudo chmod 777 /var/www/html
update lagi dari wp-admin
sudo chmod 755 /var/www/html

*update tidak bisa dilakukan karena inconsistent file permissions, solusinya mengganti sementara file permissions menjadi 777. Setelah diupdate kembaikan lagi ke 755.


#cara mengetahui user yang sedang logged in

who


#ada 2 user yang sama dimana satu adalah idle dan ingin di remove

who -all | grep zzzzz
zzzzz + pts/0 2016-01-07 14:58 00:38 1690 (76.84.37.44)
sudo kill -1 1690


#pemakaian CPU tinggi, baca sumber ini

http://www.geckoandfly.com/7512/7-methods-to-reduce-wordpress-cpu-usage-without-upgrading-web-hosting-plan/


masalah:
apache2: Could not reliably determine the server’s fully qualified domain name, using 127.0.1.1 for ServerName
… waiting apache2:
Could not reliably determine the server’s fully qualified domain name, using 127.0.1.1 for ServerName

solusi:
echo “ServerName localhost” | sudo tee /etc/apache2/conf-available/fqdn.conf
sudo a2enconf fqdn
sudo service apache2 restart


#The mcrypt extension is missing. Please check your PHP configuration.

sudo php5enmod mcrypt
sudo service apache2 restart

jika belum diinstall:
sudo apt-get install mcrypt php5-mcrypt
sudo php5enmod mcrypt
sudo service apache2 restart

jika masih The mcrypt extension is missing:

sudo updatedb

locate mcrypt.ini
/etc/php5/mods-available/mcrypt.ini

locate mcrypt.so
/usr/lib/libmcrypt.so.4
/usr/lib/libmcrypt.so.4.4.8
/usr/lib/php5/20121212/mcrypt.so

samakan dengan path diatas (baris yang terakhir)
sudo nano /etc/php5/mods-available/mcrypt.ini
extension=/usr/lib/php5/20121212/mcrypt.so

ctrl-x y enter

sudo php5enmod mcrypt

ls -al /etc/php5/apache2/conf.d/20-mcrypt.ini (untuk cek)

sudo service apache2 restart


#setingan gzip untuk mempercepat website, menggunakan module deflate. Simpan di .htaccess atau di apache2.conf

# gzip start
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE image/svg+xml
AddType image/svg+xml .svg
AddType x-font/otf .otf
AddType x-font/ttf .ttf
AddType x-font/eot .eot
AddType x-font/woff .woff
AddType image/x-icon .ico
AddType image/png .jpg
# gzip end


#setting Expiry Date atau Maximum Age di HTTP Headers, menggunakan module expires. Simpan di .htaccess atau di apache2.conf

# BEGIN Expiry Date
ExpiresActive on
ExpiresByType image/x-ico “access plus 1 year”
ExpiresByType image/jpg “access plus 14 days”
ExpiresByType image/jpeg “access plus 14 days”
ExpiresByType image/gif “access plus 14 days”
ExpiresByType image/png “access plus 14 days”
ExpiresByType image/svg+xml “access plus 14 days”
ExpiresByType text/css “access plus 14 days”
# END Expiry Date


#mengkompres file menjadi format zip
sudo apt-get install zip
sudo zip -r wp-content2.zip /var/www/html/wp-content

*hasilnya wp-content2.zip ada di /home/zzzzz, zzzzz adalah username


#unzip file yang berada di folder tertentu

sudo apt-get install unzip
unzip /var/www/html.zip -d /var/www

*hasilnya html.zip akan diunzip didalam folder www


#mencari term di access log apache

sudo grep -r anugerah /var/log/apache2/access.log

hasilnya(contoh):
36.81.99.17 – – [25/Jan/2016:21:49:51 -0500] “GET /tag/anugerah-terindah/ HTTP/1.1” 200 32086 “http://searches.uninstallmaster.com/search/web?channel=unknown&type=sc&q=anugerah” “Mozilla/5.0 (Windows NT 6.1; WOW64; rv:43.0) Gecko/20100101 Firefox/43.0”
36.81.99.17 – – [25/Jan/2016:21:52:23 -0500] “GET /tag/anugerah-terindah/ HTTP/1.1” 200 32203 “http://searches.uninstallmaster.com/search/web?channel=unknown&type=sc&q=anugerah” “Mozilla/5.0 (Windows NT 6.1; WOW64; rv:43.0) Gecko/20100101 Firefox/43.0”
36.81.99.17 – – [25/Jan/2016:21:54:18 -0500] “GET /tag/anugerah-terindah/ HTTP/1.1” 200 32122 “http://searches.uninstallmaster.com/search/web?channel=unknown&type=sc&q=anugerah” “Mozilla/5.0 (Windows NT 6.1; WOW64; rv:43.0) Gecko/20100101 Firefox/43.0”
36.81.99.17 – – [25/Jan/2016:21:54:52 -0500] “GET /tag/anugerah-terindah/ HTTP/1.1” 200 32005 “http://searches.uninstallmaster.com/search/web?channel=unknown&type=sc&q=anugerah” “Mozilla/5.0 (Windows NT 6.1; WOW64; rv:43.0) Gecko/20100101 Firefox/43.0”
36.81.99.17 – – [25/Jan/2016:21:56:51 -0500] “GET /tag/anugerah-terindah/ HTTP/1.1” 304 294 “http://searches.uninstallmaster.com/search/web?channel=unknown&type=sc&q=anugerah” “Mozilla/5.0 (Windows NT 6.1; WOW64; rv:43.0) Gecko/20100101 Firefox/43.0”


#cek error log

sudo tail /var/log/apache2/error.log


Warning: An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the support forums. (WordPress could not establish a secure connection to WordPress.org. Please contact your server administrator.) in /home/XXXXXXXX/public_html/wp-includes/update.php on line 457

*solusi: dalam folder wp-includes timpa file update.php dengan file update.php yang baru hasil download dari https://wordpress.org/download/


#cara edit massal/bulk di phpmyadmin

Update wp_posts SET post_status = ‘publish’ WHERE post_author =1 and post_type =’post’ ;
Update wp_posts SET post_status = ‘publish’ WHERE post_author =1 and post_type =’page’ and post_status =’draft’ ;

*contoh perintah edit masal merubah draft menjadi publish


#cara install module pagespeed untuk mempercepat website pada server Apache Ubuntu

sudo wget https://dl-ssl.google.com/dl/linux/direct/mod-pagespeed-stable_current_amd64.deb
sudo dpkg -i mod-pagespeed-stable_current_amd64.deb
sudo rm mod-pagespeed-*.deb
sudo service apache2 restart


#cara mematikan module pagespeed

sudo nano /etc/apache2/mods-available/pagespeed.conf

rubah

ModPagespeed on menjadi ModPagespeed off


#cara hapus cache mod-pagespeed

sudo touch /var/cache/mod_pagespeed/cache.flush


#cara mengetahui kernel version dan ubuntu version

uname -a (informasi mengenai kernel version)
uname -r (informasi mengenai the exact kernel version)
lsb_release -a (informasi mengenai Ubuntu version)
lsb_release -r (informasi mengenai the exact version)
apache2 -v (apache version)


error:
ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ (111)

solusi:
sudo service mysql start


#cara cek module yang digunakan:

apache2ctl -M


Masalah:
[alias:warn] [pid 8334] AH00671: The Alias directive in /etc/phpmyadmin/apache.conf at line 3 will probably never match because it overlaps an earlier Alias.

solusi:
sudo nano /etc/apache2/apache2.conf
#Include /etc/phpmyadmin/apache.conf (kasih tanda pagar)


#proses update VPS berhenti di tengah jalan (belum selesai)

E: Could not get lock /var/lib/dpkg/lock – open (11: Resource temporarily unavailable)
E: Unable to lock the administration directory (/var/lib/dpkg/), is another process using it?

sudo rm /var/lib/dpkg/lock

atau

ps aux | grep apt (cari nomor proses apt-get)
kill processnumber atau
kill -9 processnumber

kemudian

sudo dpkg –configure -a

lalu ulangi proses updatenya.


To top