Install Linux ,Nginx, MySQL,PHP,phpmyadmin on Ubuntu 18.04

Step 1 – Install the Nginx Web Server

$ sudo update
$ sudo apt-get install nginx

Enable firewall

$ sudo ufw allow http
$ sudo ufw allow https

Check status

$ sudo ufw status

Step 2 Install PHP PHP-mysql and Config

$ sudo apt install php-fpm php-mysql

config nginx

$ sudo nano /etc/nginx/sites-available/example.com
server {
        listen 80;
        root /var/www/html;
        index index.php index.html index.htm index.nginx-debian.html;
        server_name example.com;

        location / {
                try_files $uri $uri/ =404;
        }

        location ~ \.php$ {
                include snippets/fastcgi-php.conf;
                fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
        }

        location ~ /\.ht {
                deny all;
        }
}
$ sudo ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/
$ sudo unlink /etc/nginx/sites-enabled/default
$ sudo nginx -t
$ sudo  systemctl reload nginx

step 3 Creating a PHP File to test Configuaration

$ sudo nano /var/www/html/info.php
<?php   phpinfo(); ?>

Step 4 Install MySQL

$ sudo apt install mysql-server
$ sudo mysql_secure_installation

กำหนดรหัสผ่านให้กับฐานข้อมูล  MySQL

$ sudo mysql
mysql> SELECT user,authentication_string,plugin,host FROM mysql.user;
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
mysql>FLUSH PRIVILEGES;
mysql> exit

Step 5 Install phpMyAdmin

$ sudo apt install phpmyadmin
$ sudo ln -s /usr/share/phpmyadmin /var/www/html/phpmyadmin
Share

You may also like...