Kali配置LNMP环境
安装Nginx
└─$ sudo apt-cache policy nginx nginx: 已安装:(无) 候选: 1.22.0-1 版本列表: 1.22.0-1 500 500 http://http.kali.org/kali kali-rolling/main amd64 Packages └─$ sudo apt install nginx-full └─$ sudo nano /etc/nginx/sites-available/default //nginx └─$ sudo systemctl start nginx
安装PHP和PHP扩展
┌──(kele㉿Roonready)-[/] └─$ sudo apt-cache policy php php-fpm php: 已安装:(无) 候选: 2:8.1+92 版本列表: 2:8.1+92 500 500 http://http.kali.org/kali kali-rolling/main amd64 Packages php-fpm: 已安装:(无) 候选: 2:8.1+92 版本列表: 2:8.1+92 500 500 http://http.kali.org/kali kali-rolling/main amd64 Packages ┌──(kele㉿Roonready)-[/] └─$ sudo apt install php8.1 php8.1-fpm └─$ sudo php -v PHP 8.1.5 (cli) (built: May 16 2022 17:15:25) (NTS) Copyright (c) The PHP Group Zend Engine v4.1.5, Copyright (c) Zend Technologies with Zend OPcache v8.1.5, Copyright (c), by Zend Technologies
配置Nginx和PHP-FPM
└─$ sudo nano /etc/nginx/sites-available/default root /home/music; # Add index.php to the list if you are using PHP index index.php index.html index.htm index.nginx-debian.html; server_name _; location / { # First attempt to serve request as file, then # as directory, then fall back to displaying a 404. try_files $uri $uri/ =404; } # pass PHP scripts to FastCGI server # location ~ \.php$ { include snippets/fastcgi-php.conf; # # # With php-fpm (or other unix sockets): fastcgi_pass unix:/run/php/php8.1-fpm.sock; //php这里注意版本 # # With php-cgi (or other tcp sockets): # fastcgi_pass 127.0.0.1:9000; } └─$ sudo nano /etc/php/8.1/fpm/pool.d/www.conf ; Note: This value is mandatory. listen = /run/php/php8.1-fpm.sock ┌──(kele㉿Roonready)-[/] └─$ sudo systemctl restart nginx.service ┌──(kele㉿Roonready)-[/] └─$ sudo systemctl restart php8.1-fpm.service
测试
┌──(kele㉿Roonready)-[/home/music] └─$ sudo nano test.php ctrl+x localhost/test.php
安装mariadb
┌──(kele㉿Roonready)-[/] └─$ sudo apt-cache policy mariadb-server mariadb-client mariadb-server: 已安装:(无) 候选: 1:10.6.8-1 版本列表: 1:10.6.8-1 500 500 http://http.kali.org/kali kali-rolling/main amd64 Packages mariadb-client: 已安装:(无) 候选: 1:10.6.8-1 版本列表: 1:10.6.8-1 500 500 http://http.kali.org/kali kali-rolling/main amd64 Packages ┌──(kele㉿Roonready)-[/] └─$ sudo apt install mariadb-server mariadb-client //启动 mysql ┌──(kele㉿Roonready)-[/] └─$ sudo systemctl start mariadb.service ┌──(kele㉿Roonready)-[/] └─$ sudo mysql Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 32Server version: 10.6.8-MariaDB-1 Debian buildd-unstable 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)]>
安装PHP Mysql扩展连接数据库
┌──(kele㉿Roonready)-[/] └─$ sudo apt-cache policy php8.1-mysql php8.1-mysql: 已安装:(无) 候选: 8.1.5-1+b1 版本列表: 8.1.5-1+b1 500 500 http://http.kali.org/kali kali-rolling/main amd64 Packages ┌──(kele㉿Roonready)-[/] └─$ sudo apt install php8.1-mysql ┌──(kele㉿Roonready)-[/] └─$ sudo nano /home/music/mysql.php