Search Suggest

Bài đăng

How to install Nginx with MariaDB and PHP7.0 in Ubuntu 16.04

Install Nginx Web Server
$ sudo apt install nginx

Start nginx service
$ sudo systemctl start nginx

Enable nginx service permanently
$ sudo systemctl enable nginx

Check nginx service status
$ sudo systemctl status nginx

Access nginx Web server from your browser
http://server-ipaddress

Install MariaDB database
$ sudo apt install mariadb-server mariadb-client

Start and enable MariaDB service 
$ sudo systemctl start mysql.service
$ sudo systemctl enable mysql.service
$ sudo systemctl status mysql.service

Setup MariaDB password with below steps:
$ sudo mysql_secure_installation

Enter current password for root (enter for none): Just press the Enter
Set root password? [Y/n]: Y
New password: Enter password
Re-enter new password: Repeat password
Remove anonymous users? [Y/n]: Y
Disallow root login remotely? [Y/n]: Y
Remove test database and access to it? [Y/n]:  Y
Reload privilege tables now? [Y/n]:  Y
Restart MariaDB server

Check database version
$ mysql --version
mysql  Ver 15.1 Distrib 10.0.38-MariaDB

Install PHP 7.0

$ sudo apt-get install php7.0

Start php service
$ sudo systemctl start php7.0-fpm

Check PHP version
$ php --version

PHP 7.0.33-0ubuntu0.16.04.5 (cli) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
    with Zend OPcache v7.0.33-0ubuntu0.16.04.5, Copyright (c) 1999-2017, by Zend Technologies

Configure Nginx to read the PHP

max_execution_time = 300
max_input_time = 60
memory_limit = 256M
upload_max_filesize = 100M

$ sudo vim.tiny  /etc/nginx/sites-available/default

location ~ \.php$ {
                include snippets/fastcgi-php.conf;

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

Restart Service
$ sudo service nginx restart
$ sudo service php7.0-fpm restart

Create php test page
$ sudo vim.tiny /var/www/html/phpinfo.php
<?php phpinfo( ); ?>

Access php test page
http://server-ipaddress/phpinfo.php

Đăng nhận xét