当前位置:首页 > Linux > 正文内容

Kali配置LNMP环境

tomosak2年前 (2023-10-11)Linux738

安装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


扫描二维码推送至手机访问。

版权声明:本文由Androidnews发布,如需转载请注明出处。

本文链接:https://www.androidnews.top/?id=37

标签: HIFILinux
分享给朋友:

“Kali配置LNMP环境” 的相关文章

Linux一键更换国内软件源脚本

脚本当前使用的开源镜像站 镜像站名称镜像站地址IPv6Kali LinuxFedoraEPEL1阿里云mirrors.aliyun.com✓✓✓✓2腾讯云mirrors.tencent.com✓✓✓✓3华为云mirrors.huaweicloud.com✓✓✓✓4网易mirrors.163...

彻底删除.user.ini文件的方法

.user.ini是干什么的?其实这个文件是军哥LNMP一键包中的文件,根据军哥的官方解释:LNMP 1.2及更高版本防跨目录功能使用.user.ini,该文件在网站根目录下,可以修改.user.ini 里面的open_basedir的值来设置限制访问的目录或删除来移除防跨目录的设置。怎么删除?其实...

nginx网页服务器访问目录设置

编辑nginx.conf文件,在http段添加下面代码:autoindex on; autoindex_exact_size on; autoindex_localtime on; charset utf-8,gbk;...

kali添加Windows分区启动

1、备份grub配置文件sudo cp /boot/grub/grub.cfg /boot/grub/grub.cfg.bak2、编辑grub配置文件sudo nano /boot/grub/grub.cfg### BEGIN /etc/grub.d/30_os_prober&n...

Docker管理

启动dockerdocker run -d -i -t/bin/bash上述命令执行某些命令回报错Failed to get D-Bus connection: Operation not permitted可使用如下命令启动docker run&n...

发表评论

访客

◎欢迎参与讨论,请在这里发表您的看法和观点。