Friday, 10 December 2021

Install PHP 7.2 Debian Server Wordpress

 

Di artikel ini, kami menggunakan PHP 7.2, ikuti instruksi di bawah ini untuk menjalankan instalasinya.

Import dan tambahkan repositori SURY.

 

root@debian:~# wget https://packages.sury.org/php/apt.gpg
--2021-12-10 08:48:24--  https://packages.sury.org/php/apt.gpg
Resolving packages.sury.org (packages.sury.org)... 172.67.182.150, 104.21.18.148, 2606:4700:3030::ac43:b696, ...
Connecting to packages.sury.org (packages.sury.org)|172.67.182.150|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1769 (1.7K) [application/octet-stream]
Saving to: 'apt.gpg'

apt.gpg            100%[==============>]   1.73K  --.-KB/s    in 0s      

2021-12-10 08:48:24 (7.08 MB/s) - 'apt.gpg' saved [1769/1769]

root@debian:~# apt-key add apt.gpg
OK
root@debian:~# echo "deb https://packages.sury.org/php/
> echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/php7.list^C
root@debian:~# echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/php7.list
-bash: sudo: command not found
 

ralat jadi ini (tanpa sudo)

root@debian:~# echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" |  tee /etc/apt/sources.list.d/php7.list
deb https://packages.sury.org/php/ buster main
 

Update repositori indeks:

$ apt-get update -y 
 
root@debian:~# apt-get update -y 
Get:1 https://packages.sury.org/php buster InRelease [6837 B]
Hit:2 http://security.debian.org/debian-security buster/updates InRelease
Hit:3 http://deb.debian.org/debian buster InRelease
Hit:4 http://deb.debian.org/debian buster-updates InRelease
Get:5 https://packages.sury.org/php buster/main amd64 Packages [350 kB]
Fetched 357 kB in 2s (170 kB/s)
Reading package lists... Done
 
 

Kemudian install PHP dengan:

root@debian:~# apt-get install php7.2 php7.2-fpm php7.2-mysql php-common php7.2-cli php7.2-common php7.2-json php7.2-opcache php7.2-readline php7.2-mbstring php7.2-xml php7.2-gd php7.2-curl -y
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
libpcre3
Suggested packages:
php-pear
The following NEW packages will be installed:
php-common php7.2 php7.2-cli php7.2-common php7.2-curl php7.2-fpm
php7.2-gd php7.2-json php7.2-mbstring php7.2-mysql php7.2-opcache
php7.2-readline php7.2-xml
The following packages will be upgraded:
libpcre3
1 upgraded, 13 newly installed, 0 to remove and 9 not upgraded.
Need to get 4860 kB of archives.
After this operation, 20.3 MB of additional disk space will be used.
Get:1 https://packages.sury.org/php buster/main amd64 libpcre3 amd64 2:8.44-2+0~20210301.9+debian10~1.gbpa278ad [344 kB]
Get:2 https://packages.sury.org/php buster/main amd64 php-common all 2:85+0~20211110.38+debian10~1.gbp73ad3b [16.4 kB]
Get:3 https://packages.sury.org/php buster/main amd64 php7.2-common amd64 7.2.34-28+0~20211119.67+debian10~1.gbpf24e81 [569 kB]
Get:4 https://packages.sury.org/php buster/main amd64 php7.2-json amd64 7.2.34-28+0~20211119.67+debian10~1.gbpf24e81 [19.0 kB]
Get:5 https://packages.sury.org/php buster/main amd64 php7.2-opcache amd64 7.2.34-28+0~20211119.67+debian10~1.gbpf24e81 [167 kB]
Get:6 https://packages.sury.org/php buster/main amd64 php7.2-readline amd64 7.2.34-28+0~20211119.67+debian10~1.gbpf24e81 [12.3 kB]
Get:7 https://packages.sury.org/php buster/main amd64 php7.2-cli amd64 7.2.34-28+0~20211119.67+debian10~1.gbpf24e81 [1448 kB]
Get:8 https://packages.sury.org/php buster/main amd64 php7.2-fpm amd64 7.2.34-28+0~20211119.67+debian10~1.gbpf24e81 [1454 kB]
Get:9 https://packages.sury.org/php buster/main amd64 php7.2 all 7.2.34-28+0~20211119.67+debian10~1.gbpf24e81 [56.4 kB]
Get:10 https://packages.sury.org/php buster/main amd64 php7.2-curl amd64 7.2.34-28+0~20211119.67+debian10~1.gbpf24e81 [29.7 kB]
Get:11 https://packages.sury.org/php buster/main amd64 php7.2-gd amd64 7.2.34-28+0~20211119.67+debian10~1.gbpf24e81 [27.9 kB]
Get:12 https://packages.sury.org/php buster/main amd64 php7.2-mbstring amd64 7.2.34-28+0~20211119.67+debian10~1.gbpf24e81 [486 kB]
Get:13 https://packages.sury.org/php buster/main amd64 php7.2-mysql amd64 7.2.34-28+0~20211119.67+debian10~1.gbpf24e81 [120 kB]
Get:14 https://packages.sury.org/php buster/main amd64 php7.2-xml amd64 7.2.34-28+0~20211119.67+debian10~1.gbpf24e81 [111 kB]
Fetched 4860 kB in 22s (218 kB/s)
apt-listchanges: Can't set locale; make sure $LC_* and $LANG are correct!
apt-listchanges: Reading changelogs...
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = "en_US:en",
LC_ALL = (unset),
LC_TIME = "id_ID.UTF-8",
LC_MONETARY = "id_ID.UTF-8",
LC_ADDRESS = "id_ID.UTF-8",
LC_TELEPHONE = "id_ID.UTF-8",
LC_NAME = "id_ID.UTF-8",
LC_MEASUREMENT = "id_ID.UTF-8",
LC_IDENTIFICATION = "id_ID.UTF-8",
LC_NUMERIC = "id_ID.UTF-8",
LC_PAPER = "id_ID.UTF-8",
LANG = "en_US.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to a fallback locale ("en_US.UTF-8").
locale: Cannot set LC_ALL to default locale: No such file or directory
(Reading database ... 127249 files and directories currently installed.)
Preparing to unpack .../libpcre3_2%3a8.44-2+0~20210301.9+debian10~1.gbpa278ad_amd64.deb ...
Unpacking libpcre3:amd64 (2:8.44-2+0~20210301.9+debian10~1.gbpa278ad) over (2:8.39-12) ...
Setting up libpcre3:amd64 (2:8.44-2+0~20210301.9+debian10~1.gbpa278ad) ...
Selecting previously unselected package php-common.
(Reading database ... 127249 files and directories currently installed.)
Preparing to unpack .../00-php-common_2%3a85+0~20211110.38+debian10~1.gbp73ad3b_all.deb ...
Unpacking php-common (2:85+0~20211110.38+debian10~1.gbp73ad3b) ...
Selecting previously unselected package php7.2-common.
Preparing to unpack .../01-php7.2-common_7.2.34-28+0~20211119.67+debian10~1.gbpf24e81_amd64.deb ...
Unpacking php7.2-common (7.2.34-28+0~20211119.67+debian10~1.gbpf24e81) ...
Selecting previously unselected package php7.2-json.
Preparing to unpack .../02-php7.2-json_7.2.34-28+0~20211119.67+debian10~1.gbpf24e81_amd64.deb ...
Unpacking php7.2-json (7.2.34-28+0~20211119.67+debian10~1.gbpf24e81) ...
Selecting previously unselected package php7.2-opcache.
Preparing to unpack .../03-php7.2-opcache_7.2.34-28+0~20211119.67+debian10~1.gbpf24e81_amd64.deb ...
Unpacking php7.2-opcache (7.2.34-28+0~20211119.67+debian10~1.gbpf24e81) ...
Selecting previously unselected package php7.2-readline.
Preparing to unpack .../04-php7.2-readline_7.2.34-28+0~20211119.67+debian10~1.gbpf24e81_amd64.deb ...
Unpacking php7.2-readline (7.2.34-28+0~20211119.67+debian10~1.gbpf24e81) ...
Selecting previously unselected package php7.2-cli.
Preparing to unpack .../05-php7.2-cli_7.2.34-28+0~20211119.67+debian10~1.gbpf24e81_amd64.deb ...
Unpacking php7.2-cli (7.2.34-28+0~20211119.67+debian10~1.gbpf24e81) ...
Selecting previously unselected package php7.2-fpm.
Preparing to unpack .../06-php7.2-fpm_7.2.34-28+0~20211119.67+debian10~1.gbpf24e81_amd64.deb ...
Unpacking php7.2-fpm (7.2.34-28+0~20211119.67+debian10~1.gbpf24e81) ...
Selecting previously unselected package php7.2.
Preparing to unpack .../07-php7.2_7.2.34-28+0~20211119.67+debian10~1.gbpf24e81_all.deb ...
Unpacking php7.2 (7.2.34-28+0~20211119.67+debian10~1.gbpf24e81) ...
Selecting previously unselected package php7.2-curl.
Preparing to unpack .../08-php7.2-curl_7.2.34-28+0~20211119.67+debian10~1.gbpf24e81_amd64.deb ...
Unpacking php7.2-curl (7.2.34-28+0~20211119.67+debian10~1.gbpf24e81) ...
Selecting previously unselected package php7.2-gd.
Preparing to unpack .../09-php7.2-gd_7.2.34-28+0~20211119.67+debian10~1.gbpf24e81_amd64.deb ...
Unpacking php7.2-gd (7.2.34-28+0~20211119.67+debian10~1.gbpf24e81) ...
Selecting previously unselected package php7.2-mbstring.
Preparing to unpack .../10-php7.2-mbstring_7.2.34-28+0~20211119.67+debian10~1.gbpf24e81_amd64.deb ...
Unpacking php7.2-mbstring (7.2.34-28+0~20211119.67+debian10~1.gbpf24e81) ...
Selecting previously unselected package php7.2-mysql.
Preparing to unpack .../11-php7.2-mysql_7.2.34-28+0~20211119.67+debian10~1.gbpf24e81_amd64.deb ...
Unpacking php7.2-mysql (7.2.34-28+0~20211119.67+debian10~1.gbpf24e81) ...
Selecting previously unselected package php7.2-xml.
Preparing to unpack .../12-php7.2-xml_7.2.34-28+0~20211119.67+debian10~1.gbpf24e81_amd64.deb ...
Unpacking php7.2-xml (7.2.34-28+0~20211119.67+debian10~1.gbpf24e81) ...
Setting up php-common (2:85+0~20211110.38+debian10~1.gbp73ad3b) ...
Created symlink /etc/systemd/system/timers.target.wants/phpsessionclean.timer → /lib/systemd/system/phpsessionclean.timer.
Setting up php7.2-common (7.2.34-28+0~20211119.67+debian10~1.gbpf24e81) ...
locale: Cannot set LC_ALL to default locale: No such file or directory

Creating config file /etc/php/7.2/mods-available/calendar.ini with new version
locale: Cannot set LC_ALL to default locale: No such file or directory

Creating config file /etc/php/7.2/mods-available/ctype.ini with new version
locale: Cannot set LC_ALL to default locale: No such file or directory

Creating config file /etc/php/7.2/mods-available/exif.ini with new version
locale: Cannot set LC_ALL to default locale: No such file or directory

Creating config file /etc/php/7.2/mods-available/fileinfo.ini with new version
locale: Cannot set LC_ALL to default locale: No such file or directory

Creating config file /etc/php/7.2/mods-available/ftp.ini with new version
locale: Cannot set LC_ALL to default locale: No such file or directory

Creating config file /etc/php/7.2/mods-available/gettext.ini with new version
locale: Cannot set LC_ALL to default locale: No such file or directory

Creating config file /etc/php/7.2/mods-available/iconv.ini with new version
locale: Cannot set LC_ALL to default locale: No such file or directory

Creating config file /etc/php/7.2/mods-available/pdo.ini with new version
locale: Cannot set LC_ALL to default locale: No such file or directory

Creating config file /etc/php/7.2/mods-available/phar.ini with new version
locale: Cannot set LC_ALL to default locale: No such file or directory

Creating config file /etc/php/7.2/mods-available/posix.ini with new version
locale: Cannot set LC_ALL to default locale: No such file or directory

Creating config file /etc/php/7.2/mods-available/shmop.ini with new version
locale: Cannot set LC_ALL to default locale: No such file or directory

Creating config file /etc/php/7.2/mods-available/sockets.ini with new version
locale: Cannot set LC_ALL to default locale: No such file or directory

Creating config file /etc/php/7.2/mods-available/sysvmsg.ini with new version
locale: Cannot set LC_ALL to default locale: No such file or directory

Creating config file /etc/php/7.2/mods-available/sysvsem.ini with new version
locale: Cannot set LC_ALL to default locale: No such file or directory

Creating config file /etc/php/7.2/mods-available/sysvshm.ini with new version
locale: Cannot set LC_ALL to default locale: No such file or directory

Creating config file /etc/php/7.2/mods-available/tokenizer.ini with new version
Setting up php7.2-opcache (7.2.34-28+0~20211119.67+debian10~1.gbpf24e81) ...
locale: Cannot set LC_ALL to default locale: No such file or directory

Creating config file /etc/php/7.2/mods-available/opcache.ini with new version
Setting up php7.2-gd (7.2.34-28+0~20211119.67+debian10~1.gbpf24e81) ...
locale: Cannot set LC_ALL to default locale: No such file or directory

Creating config file /etc/php/7.2/mods-available/gd.ini with new version
Setting up php7.2-curl (7.2.34-28+0~20211119.67+debian10~1.gbpf24e81) ...
locale: Cannot set LC_ALL to default locale: No such file or directory

Creating config file /etc/php/7.2/mods-available/curl.ini with new version
Setting up php7.2-json (7.2.34-28+0~20211119.67+debian10~1.gbpf24e81) ...
locale: Cannot set LC_ALL to default locale: No such file or directory

Creating config file /etc/php/7.2/mods-available/json.ini with new version
Setting up php7.2-mysql (7.2.34-28+0~20211119.67+debian10~1.gbpf24e81) ...
locale: Cannot set LC_ALL to default locale: No such file or directory

Creating config file /etc/php/7.2/mods-available/mysqlnd.ini with new version
locale: Cannot set LC_ALL to default locale: No such file or directory

Creating config file /etc/php/7.2/mods-available/mysqli.ini with new version
locale: Cannot set LC_ALL to default locale: No such file or directory

Creating config file /etc/php/7.2/mods-available/pdo_mysql.ini with new version
Setting up php7.2-mbstring (7.2.34-28+0~20211119.67+debian10~1.gbpf24e81) ...
locale: Cannot set LC_ALL to default locale: No such file or directory

Creating config file /etc/php/7.2/mods-available/mbstring.ini with new version
Setting up php7.2-xml (7.2.34-28+0~20211119.67+debian10~1.gbpf24e81) ...
locale: Cannot set LC_ALL to default locale: No such file or directory

Creating config file /etc/php/7.2/mods-available/dom.ini with new version
locale: Cannot set LC_ALL to default locale: No such file or directory

Creating config file /etc/php/7.2/mods-available/simplexml.ini with new version
locale: Cannot set LC_ALL to default locale: No such file or directory

Creating config file /etc/php/7.2/mods-available/wddx.ini with new version
locale: Cannot set LC_ALL to default locale: No such file or directory

Creating config file /etc/php/7.2/mods-available/xml.ini with new version
locale: Cannot set LC_ALL to default locale: No such file or directory

Creating config file /etc/php/7.2/mods-available/xmlreader.ini with new version
locale: Cannot set LC_ALL to default locale: No such file or directory

Creating config file /etc/php/7.2/mods-available/xmlwriter.ini with new version
locale: Cannot set LC_ALL to default locale: No such file or directory

Creating config file /etc/php/7.2/mods-available/xsl.ini with new version
Setting up php7.2-readline (7.2.34-28+0~20211119.67+debian10~1.gbpf24e81) ...
locale: Cannot set LC_ALL to default locale: No such file or directory

Creating config file /etc/php/7.2/mods-available/readline.ini with new version
Setting up php7.2-cli (7.2.34-28+0~20211119.67+debian10~1.gbpf24e81) ...
update-alternatives: using /usr/bin/php7.2 to provide /usr/bin/php (php) in auto mode
update-alternatives: using /usr/bin/phar7.2 to provide /usr/bin/phar (phar) in auto mode
update-alternatives: using /usr/bin/phar.phar7.2 to provide /usr/bin/phar.phar (phar.phar) in auto mode
locale: Cannot set LC_ALL to default locale: No such file or directory

Creating config file /etc/php/7.2/cli/php.ini with new version
Setting up php7.2-fpm (7.2.34-28+0~20211119.67+debian10~1.gbpf24e81) ...
locale: Cannot set LC_ALL to default locale: No such file or directory

Creating config file /etc/php/7.2/fpm/php.ini with new version
Created symlink /etc/systemd/system/multi-user.target.wants/php7.2-fpm.service → /lib/systemd/system/php7.2-fpm.service.
Setting up php7.2 (7.2.34-28+0~20211119.67+debian10~1.gbpf24e81) ...
Processing triggers for systemd (241-7~deb10u8) ...
Processing triggers for man-db (2.8.5-2) ...
Processing triggers for libc-bin (2.28-10) ...
Processing triggers for php7.2-cli (7.2.34-28+0~20211119.67+debian10~1.gbpf24e81) ...
Processing triggers for php7.2-fpm (7.2.34-28+0~20211119.67+debian10~1.gbpf24e81) ...
 
 

Start dan enable PHP 7.2-FPM on-boot:

 
 root@debian:~# systemctl enable php7.2-fpm
Synchronizing state of php7.2-fpm.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable php7.2-fpm
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = "en_US:en",
LC_ALL = (unset),
LC_TIME = "id_ID.UTF-8",
LC_MONETARY = "id_ID.UTF-8",
LC_ADDRESS = "id_ID.UTF-8",
LC_TELEPHONE = "id_ID.UTF-8",
LC_NAME = "id_ID.UTF-8",
LC_MEASUREMENT = "id_ID.UTF-8",
LC_IDENTIFICATION = "id_ID.UTF-8",
LC_NUMERIC = "id_ID.UTF-8",
LC_PAPER = "id_ID.UTF-8",
LANG = "en_US.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to a fallback locale ("en_US.UTF-8").
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = "en_US:en",
LC_ALL = (unset),
LC_TIME = "id_ID.UTF-8",
LC_MONETARY = "id_ID.UTF-8",
LC_ADDRESS = "id_ID.UTF-8",
LC_TELEPHONE = "id_ID.UTF-8",
LC_NAME = "id_ID.UTF-8",
LC_MEASUREMENT = "id_ID.UTF-8",
LC_IDENTIFICATION = "id_ID.UTF-8",
LC_NUMERIC = "id_ID.UTF-8",
LC_PAPER = "id_ID.UTF-8",
LANG = "en_US.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to a fallback locale ("en_US.UTF-8").
root@debian:~# systemctl start php7.2-fpm

Cek status php7.2-fpm, apakah sudah aktif atau belum:

root@debian:~# systemctl status php7.2-fpm
● php7.2-fpm.service - The PHP 7.2 FastCGI Process Manager
Loaded: loaded (/lib/systemd/system/php7.2-fpm.service; enabled; vendor
Active: active (running) since Fri 2021-12-10 08:56:00 WITA; 1min 24s a
Docs: man:php-fpm7.2(8)
Main PID: 15416 (php-fpm7.2)
Status: "Processes active: 0, idle: 2, Requests: 0, slow: 0, Traffic: 0
Tasks: 3 (limit: 4529)
Memory: 14.2M
CGroup: /system.slice/php7.2-fpm.service
├─15416 php-fpm: master process (/etc/php/7.2/fpm/php-fpm.conf)
├─15417 php-fpm: pool www
└─15418 php-fpm: pool www

Dec 10 08:56:00 debian systemd[1]: Starting The PHP 7.2 FastCGI Process Ma
Dec 10 08:56:00 debian systemd[1]: Started The PHP 7.2 FastCGI Process Man
lines 1-15/15 (END)

 

Configure PHP.ini

Buka file php.ini dan PHP-FPM configuration. Ubah config sesuai di bawah ini.

Buka file php.ini dan PHP-FPM configuration. Ubah config sesuai di bawah ini.

$ nano /etc/php/7.2/fpm/php.ini

;cgi.fix_pathinfo=1 menjadi cgi.fix_pathinfo=0

 

$ nano /etc/php/7.2/cli/php.ini

;cgi.fix_pathinfo=1 menjadi cgi.fix_pathinfo=0

 

Kemudian simpan dan keluar.

 

Create Database

Agar dapat meng-install WordPress, kamu perlu membuat database dan user database-nya terlebih dulu.

root@debian:~# mysql -u root -p
Enter password:     (masukkan password root mysql)
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 57
Server version: 10.3.31-MariaDB-0+deb10u1 Debian 10

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
 

MariaDB [(none)]> CREATE DATABASE wp DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
Query OK, 1 row affected (0.002 sec)

MariaDB [(none)]> GRANT ALL ON wp.* TO 'wpuser'@'localhost' IDENTIFIED BY 'p4ssw0rd123';
Query OK, 0 rows affected (0.002 sec)

MariaDB [(none)]> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.002 sec)
 MariaDB [(none)]> EXIT;
BYE


Konfigurasi Virtual Host Nginx

Atur virtual host Nginx hingga dapat menghubungkan domain ke server. Caranya, buat file sesuai dengan nama domain kamu, di sini kami menggunakan sman2kandangan.sch.id

nano /etc/nginx/sites-enabled/sman2kandangan
 
isinya:
 server {
listen 80;
listen [::]:80;
server_name 192.168.100.9;
root /var/www/html/;
index index.php index.html index.htm index.nginx-debian.html;

location / {
try_files $uri $uri/ /index.php;
}

location ~ \.php$ {
fastcgi_pass unix:/run/php/php7.2-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
include snippets/fastcgi-php.conf;
}

# A long browser cache lifetime can speed up repeat visits to your page
location ~* \.(jpg|jpeg|gif|png|webp|svg|woff|woff2|ttf|css|js|ico|xml)$
access_log off;
log_not_found off;
expires 360d;
}

# disable access to hidden files
location ~ /\.ht {
access_log off;
log_not_found off;
deny all;
}
}

 Arahkan hasil config tersebut ke sites-available.

 $ ln -s /etc/nginx/sites-enabled/sman2kandangan /etc/nginx/sites-available/sman2kandangan
 

 Cek konfigurasi yang sudah dilakukan, apakah ada syntax error atau tidak:

  

 root@debian:~# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful


Reload dan restart Nginx:

 root@debian:~# systemctl reload nginx
root@debian:~# systemctl restart nginx

 

 

Share:

0 comments:

Post a Comment