Last active
March 12, 2020 11:32
-
-
Save kngvamxx/75c48d0d746719bc65d125037e569816 to your computer and use it in GitHub Desktop.
set up Mysql,MariaDB,PHP MYADMIN
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Install NGINX | |
sudo apt-get update | |
sudo apt-get install nginx | |
sudo systemctl start nginx | |
sudo systemctl enable nginx | |
sudo systemctl restart nginx | |
sudo systemctl stop nginx | |
sudo systemctl start nginx | |
sudo systemctl status nginx | |
nginx -v | |
#Install MariaDB | |
sudo apt install mariadb-server | |
sudo systemctl start mariadb.service | |
sudo systemctl enable mariadb.service | |
sudo systemctl restart mariadb.service | |
sudo systemctl stop mariadb.service | |
sudo systemctl start mariadb.service | |
sudo systemctl status mariadb.service | |
mysql --version | |
#Secure MariaDB | |
sudo mysql_secure_installation | |
#When prompted, answer the questions below by following the guide. | |
Enter current password for root (enter for none): Just press the Enter | |
Set root password? [Y/n]: Y | |
New password: Enter any password | |
Re-enter new password: Repeat same 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 | |
#Now that MariaDB is installed, to test whether the database server was successfully installed | |
sudo mysql -u root -p | |
mysql -u root -p | |
CREATE DATABASE school DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci; | |
GRANT ALL ON school.* TO 'trainee'@'localhost' IDENTIFIED BY 'D@y-7869'; | |
FLUSH PRIVILEGES; | |
EXIT; | |
# Install PHP-FPM | |
sudo apt install php7.2 php7.2-fpm php7.2-cli php7.2-curl php7.2-mysql php7.2-curl php7.2-gd php7.2-mbstring php-pear -y | |
sudo systemctl start php7.2-fpm | |
sudo systemctl enable php7.2-fpm | |
netstat -pl | grep php | |
# Configure Nginx and PHP-FPM | |
cd /etc/nginx/ | |
sudo gedit nginx.conf | |
# Uncomment the following lines. | |
keepalive_timeout 2; | |
server_tokens off; | |
# Now edit the default Nginx virtual host file. | |
sudo gedit sites-available/default | |
=====================not required------------------------------------- | |
# Uncomment the PHP line shown below and change the sock file line. | |
location ~ \.php$ { | |
#include snippets/fastcgi-php.conf; | |
# | |
# # With php-fpm (or other unix sockets): | |
# fastcgi_pass unix:/var/run/php/php7.2-fpm.sock; | |
# # With php-cgi (or other tcp sockets): | |
# fastcgi_pass 127.2.0.1:9000; | |
} | |
------------------------not required........................... | |
sudo nginx -t | |
sudo systemctl reload nginx | |
# Configure PHP-FPM | |
cd /etc/php/7.2/ | |
sudo gedit fpm/php.ini | |
# Uncomment the 'cgi.fix_patinfo' line and change the value to '0'. | |
cgi.fix_pathinfo=0 | |
sudo systemctl reload php7.2-fpm | |
# Install PhpMyAdmin | |
sudo apt install phpmyadmin -y | |
# Configure PhpMyAdmin | |
cd /etc/nginx/ | |
sudo gedit sites-available/default | |
# Paste the following Nginx configuration for phpmyadmin inside the 'server {...}' bracket. | |
location /phpmyadmin { | |
root /usr/share/; | |
index index.php; | |
try_files $uri $uri/ =404; | |
location ~ ^/phpmyadmin/(doc|sql|setup)/ { | |
deny all; | |
} | |
location ~ /phpmyadmin/(.+\.php)$ { | |
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock; | |
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
include fastcgi_params; | |
include snippets/fastcgi-php.conf; | |
} | |
} | |
sudo nginx -t | |
sudo systemctl reload nginx |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment