hmjrun / hmj

my Note
1 stars 1 forks source link

Linux-Nginx-Mysql-Php 安装笔记 #11

Open hmjrun opened 7 years ago

hmjrun commented 7 years ago

Introduction

The LNMP software stack is a group of software that can be used to serve dynamic web pages and web applications. This is an acronym that describes a Linux operating system, with an Nginx web server. The backend data is stored in the MySQL database and the dynamic processing is handled by PHP.

1. Prerequisites:Linux( Ubuntu 16.04 )

hmjrun commented 7 years ago

Install the Nginx Web Server

sudo apt-get update
sudo apt-get install nginx

After install php,Configure Nginx to Use the PHP Processor

# 1. /etc/nginx/sites-available/default-php.conf
server {
    listen 80 default_server;
    listen [::]:80 default_server;

    root /var/www/html;
    index index.php index.html index.htm index.nginx-debian.html;
    server_name localhost;
    location / {
        try_files $uri $uri/ =404;
    }
    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php7.0-fpm.sock;
    }
    location ~ /\.ht {
        deny all;
    }
}

# 2. Test your configuration file for syntax errors by typing:
sudo nginx -t

# 3. buit soft link conf file to nginx sites-enabled
sudo ln -s  /etc/nginx/sites-available/default-php.conf  /etc/nginx/sites-enabled

# 4. restart nginx 
sudo service nginx restart
hmjrun commented 7 years ago

Install MySQL to Manage Site Data

sudo apt-get install mysql-server
hmjrun commented 7 years ago

Install PHP for Processing

# install PHP
sudo apt-get install php-fpm php-mysql

# change both of these conditions by uncommenting the line and setting it to "0" 
sudo vim /etc/php/7.0/fpm/php.ini
cgi.fix_pathinfo=0

# restart our PHP processor
sudo systemctl restart php7.0-fpm