美文网首页
Ubuntu 16.04 LTS下LNMP环境配置简述

Ubuntu 16.04 LTS下LNMP环境配置简述

作者: 柠檬的眼泪是酸的 | 来源:发表于2018-06-05 21:22 被阅读0次

1、Ubuntu信息

2、将系统软件库更新到最新

sudo apt-get update

3、安装Nginx

sudo apt install nginx

4、配置Nginx

vim /etc/nginx/sites-available/default

server {

             listen 80 default_server;

             listen [::]:80 default_server;

             root /home/wwwroot/default;

             index index.php index.html index.htm index.nginx-debian.html;

             server_name imooc-lemon.tk;

             location / {

                           try_files $uri $uri/ =404;

             }

             location ~ \.php$ {

                               include snippets/fastcgi-php.conf;

                               fastcgi_pass unix:/run/php/php7.0-fpm.sock;

            }

}

5、重启Nginx

sudo service nginx restart

6、安装PHP

默认安装的是php7.0

sudo apt install php

7、验证Nginx和PHP是否安装成功

在/home/wwwroot/default下新建一个info.php,如果没有目录则需要新建wwwroot和default目录

在info.php里写入<?php phpinfo();?>

在浏览器输入 http://imooc-lemon.tk/info.php

8、安装Mysql

sudo apt install mysql-server

9、安装php Mysql扩展

sudo apt install php-mysql

10、验证php-mysql扩展是否安装成功

浏览器http://imooc-lemon.tk/info.php ctrl+f  输入mysql

11、注意事项

如果系统中之前安装过lnmp环境,先将旧的环境卸载干净再安装最新的版本。

在搭建环境的过程中总会遇到各种各样的问题,所以遇到问题要勤查日志,这一点非常重要。

相关文章

网友评论

      本文标题:Ubuntu 16.04 LTS下LNMP环境配置简述

      本文链接:https://www.haomeiwen.com/subject/axnmsftx.html