Ubuntu 18.04 配置Nginx+php开发环境

本文当初在CSDN发的时间:2018年06月29日 16:59:08

Nginx与PHP的开发环境搭建一直让我很烦恼。 本次环境搭建的方法比较懒惰,但有用。记录备查。

本机版本信息如下:

nginx version: nginx/1.14.0 (Ubuntu)
PHP 7.2.5-0ubuntu0.18.04.1 (cli) (built: May  9 2018 17:21:02) ( NTS )

nginx配置只是将/etc/nginx/sites-available/default 去掉了几个注释,全文如下:

##
# You should look at the following URL's in order to grasp a solid understanding
# of Nginx configuration files in order to fully unleash the power of Nginx.
# https://www.nginx.com/resources/wiki/start/
# https://www.nginx.com/resources/wiki/start/topics/tutorials/config_pitfalls/
# https://wiki.debian.org/Nginx/DirectoryStructure
#
# In most cases, administrators will remove this file from sites-enabled/ and
# leave it as reference inside of sites-available where it will continue to be
# updated by the nginx packaging team.
#
# This file will automatically load configuration files provided by other
# applications, such as Drupal or Wordpress. These applications will be made
# available underneath a path with that package name, such as /drupal8.
#
# Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.
##

# Default server configuration
#
server {
    listen 80 default_server;
    listen [::]:80 default_server;

    # SSL configuration
    #
    # listen 443 ssl default_server;
    # listen [::]:443 ssl default_server;
    #
    # Note: You should disable gzip for SSL traffic.
    # See: https://bugs.debian.org/773332
    #
    # Read up on ssl_ciphers to ensure a secure configuration.
    # See: https://bugs.debian.org/765782
    #
    # Self signed certs generated by the ssl-cert package
    # Don't use them in a production server!
    #
    # include snippets/snakeoil.conf;

    root /var/www/public;

    # Add index.php to the list if you are using PHP
    index index.php index.html index.htm index.nginx-debian.html;

    server_name _;

    location / {
        # First attempt to serve request as file, then
        # as directory, then fall back to displaying a 404.
        try_files $uri $uri/ =404;
    }

    # pass PHP scripts to FastCGI server
    #
    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
    #
    #   # With php-fpm (or other unix sockets):
        fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
    #   # With php-cgi (or other tcp sockets):
    }

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /\.ht {
    #   deny all;
    #}
}

# Virtual Host configuration for example.com
#
# You can move that to a different file under sites-available/ and symlink that
# to sites-enabled/ to enable it.
#
#server {
#   listen 80;
#   listen [::]:80;
#
#   server_name example.com;
#
#   root /var/www/example.com;
#   index index.html;
#
#   location / {
#       try_files $uri $uri/ =404;
#   }
#}
版权声明

翼安博客


首发 翼安博客,转载请附链接!

赞赏支持

感谢支持!


建站不易,感谢支持!

推荐阅读
Git for windows 修改Home路径(版本号:2.14)
前人留下的网络资料有解决1.9版本的这个问题,但对2.14版本已经不再适用。前人资料:http://www.cnblogs.com/fenpho/p/6208896.htmlhttp://www.cnblogs.com/xunzhiyou/p/5028789.html实际操作后,修改/etc/profile文件后,重新开始GitBash并没有生效。由于Git的默认路径在C:\Users\Admin
469

thinkphp6设置Content-type解决header添加不生效问题
thinkphp6设置Content-type解决header添加不生效问题原生php只需要加入header就可以实现输出各种格式的文件内容,如header("Content-type:text/css");然而,在thinkphp6中却不能生效。response总会自动的将内容以网页的形式输出。即自动添加<html>、<body>等标签,无法达到预期的效果。tp6框架中提
4965

每天上班都像上坟一样难受,怎么办?三条妙招让上班像踏青
经常听到身边有些朋友抱怨,说每天上班的心情就想上坟。然而,真是如此么?小编相信,每位上班像上坟的朋友,身边不会缺少这样的朋友:每天上班精神抖擞,很有干劲,心情愉悦就像是来踏青一样。他们是怎么做到的呢?其实,上班不愉快无非就是上班时心情不好,感觉焦虑。要知道,这些都是可以解决的!人的一生,就是适应、利用、创造法则的一生。法则就是自然法则、社会秩序和公司规章制度。最无力的时候只能去学习、适应法则,成长
3154

CSDN-markdown编辑器示意效果
欢迎使用Markdown编辑器写博客本Markdown编辑器使用StackEdit修改而来,用它写博客,将会带来全新的体验哦:Markdown和扩展Markdown简洁的语法代码块高亮图片链接和图片上传LaTex数学公式UML序列图和流程图离线写博客导入导出Markdown文件丰富的快捷键快捷键加粗Ctrl+B斜体Ctrl+I引用Ctrl+Q插入链接Ctrl+L插入代码Ctrl+K插入图片Ctrl
1419

php开发遇到的Access denied for user
php开发遇到的Accessdeniedforuser'root'@'localhost'(usingpassword:NO)首发:2017-09-2413:44:38环境:CentOS6.5+php5.3.3在php开发过程中,我遇到了一个问题:在命令行中登录Mysql完全正常,然而PHP代码读取数据库却出了问题。报错如下:Accessdeniedforuser'root'@'localhost
3227

Linux环境C C++起Socket Server监听8080端口的代码实现
代码抄录自《UNUX网络编程卷一》,在实现开发环境中调试通过,经测试发现可以正常监听。(2017-09-0621:56:31)开发环境:CentOS,g++,VIM功能:C++实现Socket通信的Server端,实现监听8080端口接收到的消息。#include#include/*SeeNOTES*/#include#include#include#include#include#include
2717

CentOS 系统简易搭建FTP服务(四步足矣)
本文作者之前在CSDN发过(2017-09-0313:09:28),现在入驻本站。网上有很多的FTP搭建步骤,但普遍很繁琐,个人临时使用太麻烦。本次实验使用腾讯云服务器CentOS简易搭建FTP服务器,四行命令足矣完成基本使命。yuminstallvsftpdservicevsftpdstartuseradd-m-d/home/uftp-s/sbin/nologinuftppasswduftp目前
2490

linux中查看C C++程序或调用其中某个函数(类)消耗内存的方法实现
验证C/C++程序或调用其中某个函数(类)消耗内存的方法:获取进程ID,调用/proc/[pid]/status查看消耗的内存页(4KB/内存页)进程ID获取方法UNIX环境高级编程中提到的getpid(),可以获取。头文件``查看内存信息sprintf(FILE_NAME,"/proc/%d/statm",pid);FILE*fp=fopen(FILE_NAME,"r");fscanf(fp,"
2602

Linux(Android)系统Root实现原理
方案主旨思想是查找系统漏洞,让本身具有root权限的进程执行打开root权限的操作。重烧engboot.img方案Android版本有user版本和eng版本的区别,其中eng版本可以用于开发调试,所以本身可以开启root权限。通过重烧engboot.img版本来获取root权限。这个原理理解起来很简单,原理章节不再详述。死锁问题root需要考虑两个问题:(1)root权限的获取;(2)root权
2979

typecho修改站点logo图标
typecho修改站点logo图标,,DATE:,2017-10-10,10:33:21,先准备logo素材。,,我将其放在typecho代码的主目录下。,分析typecho目录结构,站点logo应在header.php文件中修改。文件目录如下:,/var/www/html/blog/usr/themes/default/header.php,使用IDE自带的插入图片功能,会自动生成代码。插入图片
1398

nprogress官网教程小记
官网文档大概翻译了下,部分内容按照小编的语言习惯做了调整。安装npminprogress主页github.com/rstacruz/nprogress资料库github.com/rstacruz/nprogressNProgress适用于Ajax类型应用程序的超薄进度条。灵感来自Google,YouTube和Medium。安装将nprogress.js和nprogress.css添加到您的项目。&
1303

php创建数数据表的简单实现
php创建数数据表的简单实现,,DATE:,2017-09-18,17:06:40,代码参考自http://www.runoob.com/php/php-mysql-create-table.html,<?php,,//mysql,$servername,=,"localhost";,$username,=,"root";,$password,=,"****";,$dbname,=,"***
1208