Ubuntu16.0.4.1安装lnmp

简介:

 环境:

    系统:Ubuntu16.0.4.1

    内核:Linux os 4.7.10-040710-generic #201610220847 SMP Sat Oct 22 12:50:14 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux (想升级内核可以看前篇文章)

    apt方式安装

    首先安装:nginx

     apt install nginx

    启动sudo /etc/init.d/nginx start

    网页输入127.0.0.1测试

     安装数据库

     sudo apt-get install mysql-server

     会弹出一个输入mysql管理员密码,输入即可.   

  sudo apt-get -y install php7.0
  sudo apt-get -y install php7.0-mysql
  sudo apt-get install php7.0-fpm

  apt-get install php7.0-curl php7.0-xml php7.0-mcrypt php7.0-json php7.0-gd php7.0-mbstring php-xml

     #sudo vim /etc/php/7.0/fpm/php.ini  (最好先备份php.ini)

     将cgi.fix_pathinfo=1 这行去注释,1改成0

     #sudo vim /etc/php/7.0/fpm/pool.d/www.conf     

      修改     

       listen=/var/run/php7.0-fpm.sock  或者   listen = 127.0.0.1 (若此方式,则下面的default配置文件需要改成一样)

      #sudo vim /etc/nginx/sites-available/default (最好先备份default)

       

       修改了以下配置,红色部分

        root /var/www/html;


        # Add index.php to the list if you are using PHP

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


        #server_name _;

        server_name loclhost;


        location / {

                # First attempt to serve request as file, then

                # as directory, then fall back to displaying a 404.

                try_files $uri $uri/ =404;

        }


        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000

        #

        location ~ \.php$ {

        #       include snippets/fastcgi-php.conf;

        #

        #       # With php7.0-cgi alone:

        #       fastcgi_pass 127.0.0.1:9000;  (对应www.conf 中listen ,这里开启则注释下面fastcgi_pass unix )

        #       # With php7.0-fpm:

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

                fastcgi_index index.php;

                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

                include fastcgi_params;

        }

 

    然后重启服务

    /etc/init.d/nginx restart

    /etc/init.d/php7.0-fpm restart

    查看服务是否配置成功

   sudo  vim /var/www/html/index.php

     <?php

     phpinfo();

    ?>

    然后127.0.0.1/index.php

     若有错误请查看日志文件

     cd  /var/log/

本文转自  一招拜师  51CTO博客,原文链接:http://blog.51cto.com/sadoc/1894622


相关文章
|
18天前
|
Ubuntu NoSQL 关系型数据库
Ubuntu系统下安装常用软件
Ubuntu系统下安装常用软件
39 0
Ubuntu系统下安装常用软件
|
1月前
|
Ubuntu Linux C语言
Ubuntu下安装vscode,并解决终端打不开vscode的问题
Ubuntu下安装vscode,并解决终端打不开vscode的问题
117 0
|
2月前
|
存储 Ubuntu 网络协议
|
3月前
|
Kubernetes Ubuntu 安全
百度搜索:蓝易云【在Ubuntu上安装OpenShift并使用】
请注意,以上只是概述,并不包含详细的步骤和指令。安装和使用OpenShift是一个复杂的过程,需要熟悉Kubernetes、Docker、网络和安全等方面的知识。建议在安装和配置OpenShift之前,先学习相关知识并查阅官方文档和教程,以确保正确部署和使用OpenShift平台。
32 3
|
1月前
|
Ubuntu Docker 容器
如何在Ubuntu上安装Docker?
【2月更文挑战第10天】
230 0
|
2月前
|
负载均衡 Ubuntu 应用服务中间件
|
20天前
|
Ubuntu 关系型数据库 MySQL
Ubuntu 中apt 安装MySQL数据库
Ubuntu 中apt 安装MySQL数据库
65 0
|
14天前
|
Ubuntu Linux 虚拟化
【Linux】ubuntu安装samba服务器
【Linux】ubuntu安装samba服务器
|
1月前
|
存储 Ubuntu 网络安全
|
2月前
|
安全 应用服务中间件 开发工具
Ubuntu20安装docker并部署相关漏洞环境
Ubuntu20安装docker并部署相关漏洞环境
49 0