{"id":2800,"date":"2022-12-23T21:33:20","date_gmt":"2022-12-23T15:33:20","guid":{"rendered":"https:\/\/staging.arifbillah.com\/new\/?p=1337"},"modified":"2022-12-23T21:33:20","modified_gmt":"2022-12-23T15:33:20","slug":"a-complete-tutorial-of-ngnix-server-configuration-in-ubuntu-22-04","status":"publish","type":"post","link":"https:\/\/arifbillah.com\/?p=2800","title":{"rendered":"A complete tutorial of ngnix server configuration in ubuntu 22.04"},"content":{"rendered":"\t\t<div data-elementor-type=\"wp-post\" data-elementor-id=\"2800\" class=\"elementor elementor-2800\">\n\t\t\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-c91a7bd elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"c91a7bd\" data-element_type=\"section\" data-e-type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-9a692f7\" data-id=\"9a692f7\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-400bec6 elementor-widget elementor-widget-text-editor\" data-id=\"400bec6\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<h2><span style=\"color: #000000;\">1. Overview<\/span><\/h2><article class=\"l-tutorial-section__content\">Nginx is an open-source web server that is often used as a reverse proxy or HTTP cache. It is available for Linux for free.<p>In this tutorial, we\u2019ll install Nginx and set up a basic site.<\/p><h2><span style=\"color: #000000;\">What you\u2019ll learn<\/span><\/h2><ul><li>How to set up Nginx<\/li><li>PHP installation<\/li><li>Mysql Installation<\/li><li>Basic Mysql configuration<\/li><li>Firewall install and configuration<\/li><li>Website demo hosting<\/li><\/ul><\/article>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-63ed0d2 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"63ed0d2\" data-element_type=\"section\" data-e-type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-af8d954\" data-id=\"af8d954\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-0f6b4fd elementor-widget elementor-widget-heading\" data-id=\"0f6b4fd\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\">Setup Nginx<\/h2>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-9a2f3fe elementor-widget elementor-widget-text-editor\" data-id=\"9a2f3fe\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>To install Nginx, use following command:<\/p><p><span style=\"color: #ff0000;\"><code> sudo apt update<\/code><\/span><br \/><span style=\"color: #ff0000;\">sudo apt install nginx<\/span><\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-551cb93 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"551cb93\" data-element_type=\"section\" data-e-type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-94ab216\" data-id=\"94ab216\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-eb0533b elementor-widget elementor-widget-heading\" data-id=\"eb0533b\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\">PHP installation<\/h2>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-998aa74 elementor-widget elementor-widget-text-editor\" data-id=\"998aa74\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>To run PHP 8.2 on Ubuntu 22.04, we need to add Ondrej sury PPA into our system. This is the maintainer of the PHP repository at the moment. This PPA is not currently checked so installing from it will not be guaranteed 100% results.<\/p><p>To add this PPA use the following command on our terminal.<\/p><p><span style=\"color: #ff0000;\">sudo add-apt-repository ppa:ondrej\/php<\/span><br \/>After installation is complete we need to update the repositories again for the changes to take effect.<\/p><p><span style=\"color: #ff0000;\">sudo apt update<\/span><br \/>Install PHP 8.2 on Ubuntu 22.04<br \/>We should now be able to install PHP 8.2 on Ubuntu 22.04 Linux machine. The commands to run are as shared below:<\/p><p><span style=\"color: #ff0000;\">sudo apt install php8.2 -y<\/span><br \/>Check for the currently active version of PHP with the following command:<\/p><p><span style=\"color: #ff0000;\">php &#8211;version<\/span><\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-63cb68e elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"63cb68e\" data-element_type=\"section\" data-e-type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-a6d5dc2\" data-id=\"a6d5dc2\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-d2a7f84 elementor-widget elementor-widget-heading\" data-id=\"d2a7f84\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\">MYsqL server install and configuration<\/h2>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-9ae39e3 elementor-widget elementor-widget-text-editor\" data-id=\"9ae39e3\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>To install it, update the package index on your server if you\u2019ve not done so recently:<\/p><p>Then install the mysql-server package:<br \/><span style=\"color: #ff0000;\">sudo apt install mysql-server<\/span><br \/>Ensure that the server is running using the systemctl start command:<span style=\"color: #ff0000;\"> <br \/><\/span><span style=\"color: #ff0000;\">sudo systemctl start mysql.service<\/span><\/p><p>Then run mysql secure command:<\/p><p>These commands will install and start MySQL, but will not prompt you to set a password or make any other configuration changes. Because this leaves your installation of MySQL insecure, we will address this next.<\/p><p>First, open up the MySQL prompt:<\/p><p><span style=\"color: #ff0000;\">mysql -u root -p<\/span><\/p><p>Then go back to using the default authentication method using this command:<\/p><p><span style=\"color: #ff0000;\">ALTER USER &#8216;root&#8217;@&#8217;localhost&#8217; IDENTIFIED WITH auth_socket;<\/span><br \/>This will mean that you can once again connect to MySQL as your root user using the sudo mysql command.<\/p><p>Run the security script with sudo:<\/p><p><span style=\"color: #ff0000;\">sudo mysql_secure_installation<\/span><\/p><p>This will take you through a series of prompts where you can make some changes to your MySQL installation\u2019s security options. The first prompt will ask whether you\u2019d like to set up the Validate Password Plugin, which can be used to test the password strength of new MySQL users before deeming them valid.<\/p><h2>Database Installation command:\u00a0<\/h2><p><span style=\"color: #ff0000;\">mysql&gt; CREATE DATABASE wpdb;<\/span><br \/><span style=\"color: #ff0000;\">mysql&gt; CREATE USER &#8216;wpuser&#8217;@&#8217;localhost&#8217; IDENTIFIED BY &#8216;BNlerp4@38%4o^G7&#8217;;<\/span><br \/><span style=\"color: #ff0000;\">mysql&gt; GRANT ALL ON wpdb.* TO &#8216;wpuser&#8217;@&#8217;localhost&#8217;;<\/span><br \/><span style=\"color: #ff0000;\">mysql&gt; FLUSH PRIVILEGES;<\/span><br \/><span style=\"color: #ff0000;\">mysql&gt; EXIT;<\/span><\/p><p><span style=\"color: #000000;\">Another basic command of mysql database;<\/span><\/p><p><span style=\"color: #ff0000;\">SHOW DATABASES;<br \/>systemctl status mysql.service<br \/>mysql -v<\/span><\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-3edfd3e elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"3edfd3e\" data-element_type=\"section\" data-e-type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-46837d5\" data-id=\"46837d5\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap\">\n\t\t\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<\/div>\n\t\t","protected":false},"excerpt":{"rendered":"<p>1. Overview Nginx is an open-source web server that is often used as a reverse proxy or HTTP cache. It is available for Linux for free. In this tutorial, we\u2019ll install Nginx and set up a basic site. What you\u2019ll learn How to set up Nginx PHP installation Mysql Installation Basic Mysql configuration Firewall install [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":3144,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[119],"tags":[],"class_list":["post-2800","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-website"],"_links":{"self":[{"href":"https:\/\/arifbillah.com\/index.php?rest_route=\/wp\/v2\/posts\/2800","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/arifbillah.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/arifbillah.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/arifbillah.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/arifbillah.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2800"}],"version-history":[{"count":0,"href":"https:\/\/arifbillah.com\/index.php?rest_route=\/wp\/v2\/posts\/2800\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/arifbillah.com\/index.php?rest_route=\/wp\/v2\/media\/3144"}],"wp:attachment":[{"href":"https:\/\/arifbillah.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2800"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/arifbillah.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2800"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/arifbillah.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2800"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}