当前位置:网站首页>sqli-labs安装 环境:ubuntu18 php7
sqli-labs安装 环境:ubuntu18 php7
2022-07-25 09:17:00 【目标是技术宅】
1.安装环境
sudo apt-get install apache2 //下载apache
sudo apt-get install php //2019.7.23现在下载的都是php7.2
sudo apt-get install mysql-server //下载mysql
sudo apt-get install libapache2-mod-php //php与apache2关联
sudo apt-get install php-mysql //mysql与php关联
2.验证环境是否搭建成功
浏览器打开http://localhost,出现It works界面,说明Apache2环境搭建成功。
在/var/www/html文件夹下,新建文件test.php,内容如下:
<?php
phpinfo();
?>
浏览器打开http://localhost/test.php,出现php的info信息,说明php安装成功。
再在/var/www/html文件夹下,新建文件test.html,内容和test.php相同,浏览器访问http://localhost/test.html,如果出现php的info信息,说明Apache2可以正确解析html中的php,可以进行下一步操作;如果是空白,说明Apache2不能正确解析html中的php,需要再做额外的操作。
网上解决这个问题的方法有很多,有一种便捷而有趣的方法分享一下:
该方法思路参考链接:https://blog.csdn.net/qq_37756513/article/details/70821168,但是略有不同。
找到/etc/apache2/mods-available/下的php7.2.conf文件,将第一行的
<FilesMatch ".+\.ph(ar|p|tml)$">
改成:
<FilesMatch ".+\.(ph(ar|p|tml)|html|htm)$">
解释一下引号中的部分:
.用于匹配除换行符的任意字符,+表示匹配前面的子表达式一次或多次,\.用于匹配.字符,所以.+\.就可以匹配任意文件名加上.符号。例如对于test.php,它可以匹配test.这一部分。
原来第一行中的ph(ar|p|tml)是指可以匹配后缀为phar、php、phtml的文件。$符号表示结束。
考虑到我们的目的是让Apache2可以匹配html等文件,所以在后面加上了html和htm两种后缀类型,如果后续有需要,也可以接着加。
下面重启Apache2服务:sudo /etc/init.d/apache2 restart,得到重启成功的提示。
再次访问http://localhost/test.html,可以得到php的info信息,说明Apache2可以正确解析html中的php。
命令行窗口输入sudo mysql -uroot -p,默认密码为空,直接回车,进入mysql命令交互界面,说明mysql数据库安装成功。
3.数据库配置
我的用户名为root,密码为空的账号在使用时遇到了一些问题,所以我决定新建一个用户来本地或者远程连接数据库。
首先以刚才提到的方式进入MySQL命令交互界面,先创建新用户user,使用户可以在任意远程主机上登录:
CREATE USER 'user'@'%' IDENTIFIED BY '123';
再赋予用户对所有数据库中的所有表增删改查的权限:
GRANT ALL ON *.* TO 'user'@'%';
4.下载sqli-labs
由于我们使用的是PHP7,原来的sqli-labs使用的是PHP5,所用函数有所区别。
所以这里从https://github.com/skyblueee/sqli-labs-php7下载文件,解压后放入目录/var/www/html中。
修改sqli-labs文件夹中,sql-connections文件夹下的db-creds.inc文件,将用户名dbuser和密码dbpass改成自己新设置的。
观察自己sqli-labs文件夹的结构,如果你文件夹的路径大概是/var/www/html/sqli-labs/index.html,那么通过:
http://localhost/sqli-labs/index.html
就可以成功访问sqli-labs的首页了!
记得点击Setup/reset Database for labs链接,来重新设置数据库。如果返回页面都是successfully或者correctly等信息,说明安装成功了!
下一步可以获取自己ubuntu的IP地址,尝试通过其它主机来访问sqli-labs,点击Setup/reset Database for labs链接,观察远程主机是否能够成功重设数据库。
边栏推荐
- Troubleshooting error: NPM install emojis list failed
- 黑马程序员JDBC
- Druid 查询超时配置的探究 → DataSource 和 JdbcTemplate 的 queryTimeout 到底谁生效?
- [machine learning] Finally, the important steps of machine learning modeling have been clarified
- 前台页面打印
- 『每日一问』LockSupport怎么实现线程等待、唤醒
- registration status: 204
- The annualization of financial products is 4%. How much profit can you get from buying 10000 yuan a month?
- Notes on in-depth analysis of C language 2
- API parsing of JDBC
猜你喜欢

Silicon Valley classroom lesson 15 - Tencent cloud deployment

JMeter test plan cannot be saved solution

Ranking of data results in MySQL

Feiling ok1028a core board adapts to rtl8192cu WiFi module

idea 热部署
![[stl]stack & queue simulation implementation](/img/92/c040c0e937e2666ee179189c60a3f2.png)
[stl]stack & queue simulation implementation
![[STL]stack&queue模拟实现](/img/92/c040c0e937e2666ee179189c60a3f2.png)
[STL]stack&queue模拟实现
[learn rust together] a preliminary understanding of rust package management tool cargo

This ten-year content industry infrastructure company is actually an invisible Web3 pioneer

什么是单机、集群与分布式?
随机推荐
idea实用tips---如今将pom.xml(红色)改为pom.xml(蓝色)
Difference between redis and mongodb (useful for interview)
【线程知识点】-- 自旋锁
centos更改mysql数据库目录
C#语言和SQL Server数据库技术
Bi business interview with data center and business intelligence (I): preparation for Industry and business research
leetcode-238.除自身以外数组的乘积
ActiveMQ -- message retry mechanism
Redis-哨兵,主从部署详细篇
Wechat applet obtains the data of ---- onenet and controls the on-board LED of STM32
Software examination system architecture designer concise tutorial | software life cycle
ActiveMQ -- kahadb of persistent mechanism
C#语言和SQL Server数据库技术
ActiveMQ -- AMQ of persistent mechanism
Druid 查询超时配置的探究 → DataSource 和 JdbcTemplate 的 queryTimeout 到底谁生效?
Opencv realizes simple face tracking
[STL]stack&queue模拟实现
OverTheWire-Bandit
OverTheWire-Natas
mysql中的数据结果排名