Optimasi SSD & Konfigurasi Web Server di Ubuntu 18.04
Sun, Aug 4, 2019
3-minute read
Catatan pribadi
:
SSD
untukUbuntu 18.04.2 LTS
, full hanya satu partisiroot
/HDD
untukmenyimpan
data
fstab
- buka
fstab
sudo gedit /etc/fstab
- matikan update tanggal file
noatime,nodiratime
:
UUID=d8c6a126-8cbe-4f72-8ab2-2e9b09b28a25 / ext4 noatime,nodiratime,errors=remount-ro 0 1
- pindah file
log
keRAM
:
tmpfs /tmp tmpfs defaults,noatime,mode=1777 0 0
tmpfs /var/spool tmpfs defaults,noatime,mode=1777 0 0
tmpfs /var/log tmpfs defaults,noatime,mode=0755 0 0
Scheduler I/O :
Untuk SSD direkomendasikan oleh Wiki Ubuntu memakai I/O deadline
.
- bikin file
60-ssd-scheduler.rules
sudo touch /etc/udev/rules.d/60-ssd-scheduler.rules
- buka file
60-ssd-scheduler.rules
sudo gedit /etc/udev/rules.d/60-ssd-scheduler.rules
- tambahkan
ACTION=="add|change", KERNEL=="sd[a-z]", ATTR{queue/rotational}=="0", ATTR{queue/scheduler}="deadline"
- cek konfigurasi
for f in /sys/block/sd?/queue/scheduler; do printf "$f is "; cat $f; done
Web Server dan Database
Tujuan penggunaan untuk develop aplikasi, untuk aplikasi web dalam membangun Web Server
menggunakan Apache
.
Karena tidak akan menyimpan aplikasi di /var/www/html tetapi di HDD menggunakan Symbolic link
.
Log yang sudah dipindah di RAM (fstab
) akan hilang ketika di restart akan terjadi error tidak bisa menjalankan Apache
maupun MySql
.
Maka dari itu memerlukan konfigurasi ekstra.
Apache2
- membuat
log apache
sudo mkdir /var/apache2/
sudo touch /var/apache2/error.log
sudo touch /var/apache2/access.log
sudo touch /var/apache2/other_vhosts_access.log
sudo chown root:adm /var/apache2
sudo chown root:adm /var/apache2/error.log
sudo chown root:adm /var/apache2/access.log
sudo chown root:adm /var/apache2/other_vhosts_access.log
sudo chmod 0750 /var/apache2
sudo chmod 0640 /var/apache2/error.log
sudo chmod 0640 /var/apache2/access.log
sudo chmod 0640 /var/apache2/other_vhosts_access.log
- edit envvars
APACHE_LOG_DIR
sudo gedit /etc/apache2/envvars
export APACHE_LOG_DIR=/var/apache2$SUFFIX
- melakukan
Symbolic link
sudo ln -s /mnt/32a34605-e617-4bf9-87bf-9d7c2a44a10f/project/web/ /var/www/
- konfigurasi apache2.conf edit
LogLevel
danAllowOverride
sudo gedit /etc/apache2/apache2.conf
LogLevel error
AllowOverride All
- aktifkan
a2enmod
sudo a2enmod rewrite
- arahkan
localhost
keSymbolic link
dan konfigurasi
sudo gedit /etc/apache2/sites-available/000-default.conf
DocumentRoot /var/www/web
LogLevel error
ErrorLog /var/www/web/error.log
CustomLog /var/www/web/access.log combined
restart
apache
sudo service apache2 restart
Mrcrypt
install ekstensi
mcrypt
sudo apt-get install php7.2-dev
sudo apt-get -y install libmcrypt-dev
sudo pecl install mcrypt-1.0.1
- tekan Enter untuk
autodetect
. - tambahkan ke
cli
danapache2
php.ini
sudo bash -c "echo extension=/usr/lib/php/20170718/mcrypt.so > /etc/php/7.2/cli/conf.d/mcrypt.ini"
sudo bash -c "echo extension=/usr/lib/php/20170718/mcrypt.so > /etc/php/7.2/apache2/conf.d/mcrypt.ini"
cek
ekstensi terinstall
php -i | grep mcrypt
- restart apache
sudo service apache2 restart
Mysql
- membuat
log mysql
sudo mkdir /var/mysql/
sudo touch /var/mysql/error.log
sudo chown mysql:adm /var/mysql
sudo chown mysql:adm /var/mysql/error.log
sudo chmod 0750 /var/mysql
sudo chmod 0640 /var/mysql/error.log
- mengubah log file
apparmor
mysql
sudo gedit /etc/apparmor.d/usr.sbin.mysqld
# Allow log file access :
/var/mysql.err rw,
/var/mysql.log rw,
/var/mysql/ r,
/var/mysql/** rw,
- reload
apparmor
sudo systemctl reload apparmor
mengarahkan
log danizin
remote koneksi
sudo gedit /etc/mysql/mysql.conf.d/mysqld.cnf
log_error = /var/mysql/error.log
bind-address = 0.0.0.0
restart
MySql
sudo service mysql restart
Allow remote dbquery
membuat
user untukremote
db
CREATE USER 'docker'@'localhost' IDENTIFIED BY 'docker';
GRANT ALL PRIVILEGES ON *.* TO 'docker'@'localhost' WITH GRANT OPTION;
CREATE USER 'docker'@'%' IDENTIFIED BY 'docker';
GRANT ALL PRIVILEGES ON *.* TO 'docker'@'%' WITH GRANT OPTION;
FLUSH PRIVILEGES;