Simple to configure Nginx and php71 in Ubuntu (adaptive and virtual machines)

Source: Internet
Author: User
Tags fpm aliyun
Simple to configure Nginx and php71 in Ubuntu

Because I am mainly in the use of Mac, just bought a screen, all under the virtual machine installed an Ubuntu system for use.

Reference:
Setup of LNMP Environment in Ubuntu
Ubuntu installation Lnmp laravel into the pit day-1
Install php7.1 in each environment to replace Apt-get with Aliyun source first, cp/etc/apt/source.list/etc/apt/source.list.copy

sudo vim/etc/apt/source.list to replace the content with the

# deb Cdrom:[ubuntu 16.04 LTS _xenial xerus_-Release AMD64 (20160420.1)]/xenial main restricted deb-src. Ubuntu.com/ubuntu xenial main restricted #Added by Software-properties Deb Http://mirrors.aliyun.com/ubuntu/xenial main Restricted deb-src http://mirrors.aliyun.com/ubuntu/xenial main restricted Multiverse universe #Added by Software-properties deb http://mirrors.aliyun.com/ubuntu/xenial-updates main restricted deb-src http:// Mirrors.aliyun.com/ubuntu/xenial-updates main restricted Multiverse Universe #Added by Software-properties Deb http:// Mirrors.aliyun.com/ubuntu/xenial Universe Deb Http://mirrors.aliyun.com/ubuntu/xenial-updates universe Deb http:// Mirrors.aliyun.com/ubuntu/xenial Multiverse Deb Http://mirrors.aliyun.com/ubuntu/xenial-updates Multiverse Deb http ://mirrors.aliyun.com/ubuntu/xenial-backports main restricted universe multiverse deb-src http://mirrors.aliyun.com/ Ubuntu/xenial-backports main restricted universe Multiverse #Added by SoftwarE-properties Deb Http://archive.canonical.com/ubuntu xenial partner Deb-src Http://archive.canonical.com/ubuntu Xenial Partner Deb Http://mirrors.aliyun.com/ubuntu/xenial-security main restricted deb-src http://mirrors.aliyun.com /ubuntu/xenial-security main restricted Multiverse Universe #Added by Software-properties Deb Http://mirrors.aliyun.com
 /ubuntu/xenial-security Universe Deb Http://mirrors.aliyun.com/ubuntu/xenial-security Multiverse

Update the source sudo apt-get update installation nginx and configuration apt-get install nginx configuration support PHP
Modify the row of Index to: index index.html index.php index.htm index.nginx-debian.html;

Remove the comments in the following section to support PHP scripts:

  Location ~ \.php$ {
  include fastcgi.conf; #需放在第一行, otherwise there will be error
  Fastcgi_pass Unix:/run/php/php7.0-fpm.sock;
  Fastcgi_index index.php;
  Fastcgi_intercept_errors on;
  Include Fastcgi_params;
}
Restart Nginx/etc/init.d/nginx restart or systemctl restart Nginx

Create a new test.php in/var/www/html

<?php phpinfo ();

Configure WordPress pseudo-static

Location/{
if (-F $request _filename/index.html) {
    rewrite (. *) $1/index.html break
;
if (f $request _filename/index.php) {
    rewrite (. *) $1/index.php;
}
if (!-f $request _filename) {
    rewrite (. *)/index.php;
}
}

Configuring the Nginx File index configuration

Location/{
  #开启目录浏览功能
  autoindex on;
  #关闭详细文件大小统计, let the file size display MB,GB units, the default is B
  autoindex_exact_size off;
  #开启以服务器本地时区显示文件修改日期
  autoindex_localtime on;
}
Install php71

Installation

sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php7.1
//if needed FPM
sudo apt-get install PHP7.
Installation extensions (similar to the following)
sudo apt-get install php7.1-mbstring Install composer

Install and switch China source

sudo apt-get install composer
composer Config-g Repo.packagist composer https://packagist.phpcomposer.com

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.