Products & Services Submit a ticket My Tickets
Selamat datang
Masuk  Mendaftar

Install Lighttpd, PHP, dan MariaDB Pada Ubuntu 20

Panduan untuk install lighttpd, php, dan MariaDB pada Ubuntu 20.


Lighttpd atau sering dibaca dengan lighty adalah web server yang bersifat open-source yang sangat ringan, dan dapat dipasang bersamaan dengan php dan MariaDB. Secara teori, lighttpd lebih superior ketimbang Apache karena cenderung lebih ringan dan mempunyai banyak module.


Sebelumnya, pastikan sistem operasi anda sudah di update ke versi paling akhir. Kemudian lakukan restart server.


# apt update # apt upgrade -y # reboot


Install Repository Pendukung


Untuk mendapatkan update php paling akhir, maka tambahkan repository berikut.


# apt install software-properties-common  -y # add-apt-repository -y ppa:ondrej/php # apt update


Mulai install lighttpd


# apt install -y lighttpd # lighttpd -v


Kemudian cek versi lighttpd anda saat ini. Ketika artikel ini dibuat, maka seharusnya versi terakhir adalah lighttpd/1.4.55. Ketika anda akses server anda menggunakan IP address atau suatu hostname/domain maka seharusnya akan menampilkan default page dari lighttpd.


Kemudian tambahkan group dari lighttpd.


# groupadd lighttpd # useradd -g lighttpd -d /var/www/html -s /sbin/nologin lighttpd


Kemudian ubah ownsersi dari path public folder


# chown -R lighttpd:lighttpd /var/www/html/


Install MariaDB dan php pendukung


# apt install -y php-{cli,gd,fpm,mysql,curl,json,xml} mariadb-server


Kemudian setup MariaDB.


# mysql_secure_installation 
~# mysql_secure_installation 
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY! 
In order to log into MariaDB to secure it, we'll need the current password for the root user. If you've just installed MariaDB, and you haven't set the root password yet, the password will be blank, so you should just press enter here. 
Enter current password for root (enter for none): OK, successfully used password, moving on... 
Setting the root password ensures that nobody can log into the MariaDB root user without the proper authorisation. 
Set root password? [Y/n] Y New password: Re-enter new password: Password updated successfully! Reloading privilege tables.. ... Success! 

By default, a MariaDB installation has an anonymous user, allowing anyone to log into MariaDB without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment. 
Remove anonymous users? [Y/n] Y ... Success! 
Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network. 
Disallow root login remotely? [Y/n] Y ... Success! 
By default, MariaDB comes with a database named 'test' that anyone can access. This is also intended only for testing, and should be removed before moving into a production environment. 
Remove test database and access to it? [Y/n] Y - Dropping test database... ... Success! - Removing privileges on test database... ... Success! 
Reloading the privilege tables will ensure that all changes made so far will take effect immediately. 
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!


Kemudian pastikan root password sudah anda simpan karena sangat penting sekali. Pastikan jangan sampai hilang atau lupa.


Lakukan penyesuaian sedikit terhadap settingan php-fpm yang akan digunakan.


# mv /etc/php/8.1/fpm/pool.d/www.conf /etc/php/8.1/fpm/pool.d/lighttpd.conf


Ubah beberapa parameter berikut :


# nano /etc/php/8.1/fpm/pool.d/lighttpd.conf 


Ubah [www] menjadi [lighttpd]
Ubah user = www-data ke user = lighttpd
Ubah group = www-data ke group = lighttpd
Ubah listen = /run/php/php8.1-fpm.sock ke listen = /run/php/php8.1-lighttpd-fpm.sock


Lalu restart php-fpm service.

# service php8.1-fpm restart


Konfigurasi lighttpd


Enable module cgi dan php pada lighttpd. Lalu force reload lighttpd service.


# lighttpd-enable-mod fastcgi # lighttpd-enable-mod fastcgi-php # service lighttpd force-reload


Kemudian konfigurasi PHP dan lakukan sedikit penyesuaian. Kita backup terlebih dahulu.


# cp -p /etc/lighttpd/conf-enabled/15-fastcgi-php.conf /etc/lighttpd/conf-enabled/15-fastcgi-php.conf-ori


Kosongkan konfigurasi sebelumnya.


#  >/etc/lighttpd/conf-enabled/15-fastcgi-php.conf # nano /etc/lighttpd/conf-enabled/15-fastcgi-php.conf


Kemudian isikan text berikut


fastcgi.server += ( ".php" => (( "socket" => "/run/php/php8.1-lighttpd-fpm.sock", "broken-scriptfilename" => "enable" )) )


Kemudian lakukan restart service lighttpd


# service lighttpd restart


Kini lighttpd siap digunakan. Namun jika ingin ditambahkan SSL, maka ada beberapa penyesuaian tambahan.


Install Cerbot. Kemudian install pada domain, dimana domain ini adalah nama website anda.


# apt install -y certbot # certbot certonly --webroot -w /var/www/html/ -d domain


Sekarang mengaktifkan module ssl lalu update konfigurasi ssl

# lighttpd-enable-mod ssl # nano /etc/lighttpd/conf-enabled/10-ssl.conf


$HTTP["scheme"] == "http" { $HTTP["host"] == "nama.domain.anda" { url.redirect = ("/.*" => "https://nama.domain.anda$0") }
} 
$SERVER["socket"] == "0.0.0.0:443" { ssl.engine = "enable" ssl.pemfile = "/etc/letsencrypt/live/nama.domain.anda/fullchain.pem" ssl.privkey = "/etc/letsencrypt/live/nama.domain.anda/privkey.pem" ssl.cipher-list = "HIGH" }


Simpan file tersebut dan kemudian restart lighttpd.


# service lighttpd restart


Nama domain anda kini sudah dilengkapi dengan SSL. Dan secara default, ketika diakses tanpa https maka secara otomatis akan mengarah ke https.

Apakah jawaban ini bermanfaat? Ya Tidak

Send feedback
Maaf kami tidak bisa membantu. Bantu kami mengembangkan artikel ini dengan umpan balik Anda.