Drupal adalah sistem manajemen konten sumber terbuka dan gratis yang membantu Anda membuat dan mengirimkan konten digital untuk web dan ponsel. Itu ditulis dalam PHP dan digunakan oleh banyak organisasi di seluruh dunia. Dengan Drupal, Anda dapat membuat berbagai jenis situs web, dari blog kecil hingga situs web perusahaan besar. Ini menawarkan antarmuka yang mudah digunakan dan alat pengeditan yang kuat untuk mengelola konten.
Dalam tutorial ini, kami akan menunjukkan cara menginstal Drupal dengan Nginx dan mengamankannya dengan Let's Encrypt SSL di Ubuntu 20.04.
Prasyarat
- Server yang menjalankan Ubuntu 20.04.
- Nama domain yang valid ditunjukkan dengan server Anda.
- Kata sandi root dikonfigurasi di server Anda.
Instal Server LEMP
Pertama, Anda perlu menginstal server web Nginx, database MariaDB, PHP, dan ekstensi lain yang diperlukan ke server Anda. Anda dapat menginstal semuanya menggunakan perintah berikut:
apt-get install nginx mariadb-server php7.4 php7.4-fpm php7.4-common php7.4-mysql php7.4-gmp php7.4-curl php7.4-intl php7.4-mbstring php7.4-xmlrpc php7.4-gd php7.4-xml php7.4-cli php7.4-zip -y
Setelah semua paket terinstal, edit file php.ini dan atur beberapa pengaturan:
nano /etc/php/7.4/fpm/php.ini
Ubah baris berikut:
short_open_tag = On cgi.fix_pathinfo=0 memory_limit = 256M upload_max_filesize = 100M max_execution_time = 300 date.timezone = America/Chicago
Simpan dan tutup file setelah Anda selesai.
Konfigurasi Database MariaDB
Pertama, amankan instalasi MariaDB dan atur kata sandi root MariaDB dengan perintah berikut:
mysql_secure_installation
Jawab semua pertanyaan seperti yang ditunjukkan di bawah ini:
Enter current password for root (enter for none): Set root password? [Y/n] Y New password: Re-enter new password: Remove anonymous users? [Y/n] Y Disallow root login remotely? [Y/n] Y Remove test database and access to it? [Y/n] Y Reload privilege tables now? [Y/n] Y
Setelah MariaDB diamankan, masuk ke shell MariaDB dengan perintah berikut:
mysql -u root -p
Berikan kata sandi root MariaDB Anda lalu buat database dan pengguna untuk Drupal:
MariaDB [(none)]> CREATE DATABASE drupaldb;
MariaDB [(none)]> CREATE USER 'drupal'@'localhost' IDENTIFIED BY 'password';
Selanjutnya, berikan semua hak istimewa ke database Drupal dengan perintah berikut:
MariaDB [(none)]> GRANT ALL ON drupaldb.* TO 'drupal'@'localhost' WITH GRANT OPTION;
Selanjutnya, flush hak istimewa dan keluar dari shell MariaDB dengan perintah berikut:
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> EXIT;
Setelah selesai, Anda dapat melanjutkan ke langkah berikutnya.
Unduh Drupal
Pada saat penulisan tutorial ini, versi terbaru dari Drupal adalah 8.8.5. Anda dapat mengunduhnya ke direktori root web Nginx dengan perintah berikut:
cd /var/www/html/
wget https://ftp.drupal.org/files/projects/drupal-8.8.5.tar.gz
Setelah unduhan selesai, ekstrak file yang diunduh dengan perintah berikut:
tar -xvzf drupal-8.8.5.tar.gz
Selanjutnya, ganti nama direktori yang diekstrak menjadi drupal dan berikan izin yang sesuai dengan perintah berikut:
mv drupal-8.8.5 drupal
chown -R www-data:www-data drupal
chmod -R 755 drupal
Setelah selesai, Anda dapat melanjutkan ke langkah berikutnya.
Konfigurasi Nginx untuk Drupal
Selanjutnya, buat file konfigurasi virtual host Nginx untuk drupal menggunakan perintah berikut:
nano /etc/nginx/sites-available/drupal
Tambahkan baris berikut:
server { listen 80; listen [::]:80; root /var/www/html/drupal; index index.php index.html index.htm; server_name drupal.linuxbuz.com; client_max_body_size 100M; autoindex off; location ~ \..*/.*\.php$ { return 403; } location ~ ^/sites/.*/private/ { return 403; } # Block access to scripts in site files directory location ~ ^/sites/[^/]+/files/.*\.php$ { deny all; } location ~ (^|/)\. { return 403; } location / { try_files $uri /index.php?$query_string; } location @rewrite { rewrite ^/(.*)$ /index.php?q=$1; } # Don't allow direct access to PHP files in the vendor directory. location ~ /vendor/.*\.php$ { deny all; return 404; } location ~ '\.php$|^/update.php' { include snippets/fastcgi-php.conf; fastcgi_pass unix:/run/php/php7.4-fpm.sock; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } location ~ ^/sites/.*/files/styles/ { # For Drupal >= 7 try_files $uri @rewrite; } location ~ ^(/[a-z\-]+)?/system/files/ { # For Drupal >= 7 try_files $uri /index.php?$query_string; } }
Simpan dan tutup file, lalu buat tautan simbolis ke direktori yang mendukung situs:
ln -s /etc/nginx/sites-available/drupal /etc/nginx/sites-enabled/
Selanjutnya, atur hash_bucket_size di file konfigurasi default Nginx:
nano /etc/nginx/nginx.conf
Tambahkan baris berikut di bawah "http { "
server_names_hash_bucket_size 64;
Simpan dan tutup file, lalu periksa Nginx apakah ada kesalahan sintaks:
nginx -t
Anda akan mendapatkan output berikut:
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful
Selanjutnya, restart layanan Nginx untuk menerapkan perubahan:
systemctl restart nginx
Setelah selesai, Anda dapat melanjutkan ke langkah berikutnya.
Amankan Drupal dengan Let's Encrypt SSL
Disarankan untuk mengamankan Drupal dengan Let's Encrypt SSL. Pertama, tambahkan repositori Certbot dengan perintah berikut:
add-apt-repository ppa:ahasenack/certbot-tlssni01-1875471
Selanjutnya, perbarui repositori dan instal klien Certbot dengan perintah berikut:
apt-get update -y
apt-get install certbot python3-certbot-nginx -y
Setelah klien Certbot diinstal, jalankan perintah berikut untuk mengunduh dan menginstal Let's Encrypt SSL untuk situs web Anda:
certbot --nginx -d drupal.linuxbuz.com
Anda akan diminta untuk memberikan email yang valid dan menerima persyaratan layanan seperti yang ditunjukkan di bawah ini:
Saving debug log to /var/log/letsencrypt/letsencrypt.log Plugins selected: Authenticator nginx, Installer nginx Enter email address (used for urgent renewal and security notices) (Enter 'c' to cancel): [email protected] - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Please read the Terms of Service at https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must agree in order to register with the ACME server at https://acme-v02.api.letsencrypt.org/directory - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - (A)gree/(C)ancel: A - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Would you be willing to share your email address with the Electronic Frontier Foundation, a founding partner of the Let's Encrypt project and the non-profit organization that develops Certbot? We'd like to send you email about our work encrypting the web, EFF news, campaigns, and ways to support digital freedom. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - (Y)es/(N)o: Y Obtaining a new certificate Performing the following challenges: http-01 challenge for drupal.linuxbuz.com Waiting for verification... Cleaning up challenges Deploying Certificate to VirtualHost /etc/nginx/sites-enabled/drupal
Selanjutnya, pilih apakah akan mengalihkan lalu lintas HTTP ke HTTPS atau tidak:
Please choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1: No redirect - Make no further changes to the webserver configuration. 2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for new sites, or if you're confident your site works on HTTPS. You can undo this change by editing your web server's configuration. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 2
Ketik 2 dan tekan Enter untuk menyelesaikan instalasi:
Redirecting all traffic on port 80 to ssl in /etc/nginx/sites-enabled/drupal - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Congratulations! You have successfully enabled https://drupal.linuxbuz.com You should test your configuration at: https://www.ssllabs.com/ssltest/analyze.html?d=drupal.linuxbuz.com - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - IMPORTANT NOTES: - Congratulations! Your certificate and chain have been saved at: /etc/letsencrypt/live/drupal.linuxbuz.com/fullchain.pem Your key file has been saved at: /etc/letsencrypt/live/drupal.linuxbuz.com/privkey.pem Your cert will expire on 2020-08-12. To obtain a new or tweaked version of this certificate in the future, simply run certbot again with the "certonly" option. To non-interactively renew *all* of your certificates, run "certbot renew" - If you like Certbot, please consider supporting our work by: Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate Donating to EFF: https://eff.org/donate-le
Pada titik ini, situs web Drupal Anda diamankan dengan Let's Encrypt SSL.
Mengakses Panduan Instalasi Web Drupal
Sekarang, buka browser web Anda dan ketik URL https://drupal.linuxbuz.com. Anda akan diarahkan ke halaman pemilihan bahasa Drupal:
Pilih bahasa yang Anda inginkan dan klik Simpan dan lanjutkan tombol. Anda akan melihat halaman profil Instalasi:
Pilih profil pemasangan yang Anda inginkan dan klik Simpan dan lanjutkan tombol. Anda akan melihat halaman konfigurasi Database:
Klik tombol Simpan dan lanjutkan tombol. Anda akan melihat halaman Konfigurasi Situs:
Berikan nama situs, nama pengguna admin, sandi, dan klik Simpan dan lanjutkan tombol. Anda akan diarahkan ke dasbor default Drupal di halaman berikut:
Kesimpulan
Selamat! Anda telah berhasil menginstal dan mengamankan Drupal dengan Let's Encrypt SSL di Ubuntu 20.04. Anda sekarang dapat mulai menyesuaikan situs web Drupal Anda. Untuk informasi lebih lanjut, kunjungi dokumentasi resmi Drupal.