Ubuntu 如何安装LNMP

准备安装文件

下载地址

https://lnmp.org/

准备安装

su - root

输入root用户密码

cd /home/soft/

手动复制安装包到“/home/soft/”路径下

tar -zxvf xxx.tar.gz
chmod -R 777 xxx
cd xxx/
./install.sh lnmp

按照提示选择安装选项(设置数据库root用户密码)

配置

sudo gedit /usr/local/nginx/conf/nginx.conf

输入用户密码,在弹出的窗口中按下面内容编辑

{
#(允许请求头参数带下划线,但是会自动将下划线“_”转换为“-”)
http
    {
# 改为
http
    {
        underscores_in_headers on;
        
        #(此路径为PHP页面文件的根目录路径)
        root  /home/wwwroot/default;
        
        #(解决路径问题)
        include enable-php.conf;
        # 改为
        #include enable-php.conf;
        include enable-php-pathinfo.conf;
        
        #(隐藏index.php)
        # 新加
        location ~ .*/public/.*
        {
            if (!-e $request_filename) {
                rewrite ^(.*)/public/(.*)$ $1/public/index.php?s=/$2 last; break;
            }
        }
}
su - root

输入root用户密码

lnmp restart

测试:

创建测试页面

su - root

输入root用户密码

cd /home/wwwroot/default/
touch index.php
chmod 777 index.php
exit
cd /home/wwwroot/default/
gedit index.php

添加以下内容

<!DOCTYPE html>
<html>
<body>

<h1>我的第一张 PHP 页面</h1>

<?php
echo "Hello World!";
?>

</body>
</html>

测试

打开浏览器,在地址栏输入“http://localhost/index.php”,进行测试

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

skyksksksksks

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值