I wrote this post because I tried to have on one Linux server .NET Core app and MySQL with PhpMyAdmin tool. On the
I wrote that post base on articles: https://www.digitalocean.com/community/tutorials/how-to-install-linux-nginx-mysql-php-lemp-stack-in-ubuntu-16-04 and https://www.digitalocean.com/community/tutorials/how-to-install-and-secure-phpmyadmin-with-nginx-on-ubuntu-16-04.
Login to linux as root. First add a new user with sudo permissions:
adduser myuser
sudo adduser myuser sudo
You may log to the new one which you’ve just created and get all available updates to your Linux:
sudo apt-get update
Then install server www and proxy server:
sudo apt-get install nginx
Install MySql Server:
sudo apt-get install mysql-server
Install PHP. Currently, by default, php version 7.2 is installed. To run
sudo apt-get install php-fpm php-mysql
sudo apt-add-repository ppa:ondrej/php
sudo apt-get install php7.1-mbstring
sudo apt-get install php7.1-mcrypt
sudo ln -s /etc/php/7.1/mods-available/mcrypt.ini /etc/php/7.2/mods-available/
sudo apt-get install php7.2-mbstring
sudo phpenmod mcrypt
Change PHP configuration /etc/php/7.2/fpm/php.ini.
Change ;cgi.fix_pathinfo=1 to cgi.fix_pathinfo=0 (line 778)
Add line extension=mcrypt.so (line 893)
Restart PHP service
sudo service php7.2-fpm restart
Change your
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 <your-server-name.com>;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.2-fpm.sock;
}
location ~ /\.ht {
deny all;
}
}
Add to /var/www/html/index.php with following piece of code
<?php
phpinfo();
First check if
sudo nginx -t
sudo systemctl restart nginx
Install PhpMyAdmin
sudo apt-get install phpmyadmin
During
After installation make phpmyadmin visible your under address: <your-server-name.com>/phpmyadmin.
sudo ln -s /usr/share/phpmyadmin /var/www/html
Create admin user in mysql server
mysql -u root -p
GRANT ALL PRIVILEGES ON *.* TO 'youruser'@'localhost' IDENTIFIED BY 'yourpassword' WITH GRANT OPTION;
For my own purposes I create different databases and different users with restricted access to that databases
CREATE DATABASE prod;
CREATE DATABASE test;
GRANT ALL PRIVILEGES ON prod.* TO 'prod'@'localhost' IDENTIFIED BY 'prodpass';
GRANT ALL PRIVILEGES ON test.* TO 'test'@'localhost' IDENTIFIED BY 'testpass';
Install git
sudo apt-get install git-core
Install .net core (https://dotnet.microsoft.com/download/linux-package-manager/ubuntu18-04/sdk-current)
wget -q https://packages.microsoft.com/config/ubuntu/18.04/packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
sudo add-apt-repository universe
sudo apt-get install apt-transport-https
sudo apt-get update
sudo apt-get install dotnet-sdk-2.2