LNMP:LNMP是指一组通常一起使用来运行动态网站或者服务器的自由软件名称首字母缩写。L指Linux,N指Nginx,M一般指MySQL,也可以指MariaDB,P一般指PHP,也可以指Perl或Python。
进过前面三小节,我们已经初步搭建完成了LNMP基础架构了,但是有些小伙伴想确认下环境是否确认搭建无误,那么我们接下来就验证一下环境的准确性。
1、在nginx目录下,新建测试文件
<code>[root@one nginx]# cd /home/nginx/
[root@one nginx]# touch html/huaxin_mysql.php
[root@one nginx]# ls html/
50x.html index.html huaxin_mysql.php test.php
[root@one nginx]# /<code>
2、在 huaxin_mysql.php 中写入我们的测试信息
<code>[root@one nginx]# vim html/huaxin_mysql.php
# 写入信息
$link=mysql_connect("192.168.20.128:3316","huaxin","Nihao@123456");
if(!$link){
echo "mysql_connect fail";
}else{
echo "mysql_connect success";
}
?>
# 保存退出 :wq
[root@one nginx]# /<code>
添加内容如图:
添加的内容解读:
使用 mysql 用户名 “huaxin” 密码 “Nihao@123456” 连接数据库 “192.168.20.128”;
如果成功就返回 “mysql_connect success” ;
如果失败就返回 “mysql_connect fail”;
3、重新加载nginx
PS:每次重启nginx之前,最好先检查下配置文件的准确性
<code>[root@one nginx]# ./sbin/nginx -t
nginx: the configuration file /home/nginx//conf/nginx.conf syntax is ok
nginx: configuration file /home/nginx//conf/nginx.conf test is successful
[root@one nginx]# ./sbin/nginx -s reload
[root@one nginx]#/<code>
4、浏览器访问进行验证
输入地址:http://192.168.20.128:8010/huaxin_mysql.php
此处的IP地址要换成你本地实际的IP地址
至此,就可以证明我们LNMP架构整体搭建完成,接下来开启第二章:Zabbix安装,继续加油~
閱讀更多 花芯 的文章