<\/span><\/h2>\nBefore installing Grav, we need to install PHP and all of the required PHP extensions.<\/p>\n
First, let\u2019s install the following required packages:<\/p>\n
apt install software-properties-common python-software-properties<\/pre>\nAfter the installation is complete, add the Ond\u0159ej PPA:<\/p>\n
add-apt-repository ppa:ondrej\/php<\/pre>\nRun the update command again:<\/p>\n
apt update<\/pre>\nNow we will install PHP7.3 and all required PHP7.3 extensions, by running the following command:<\/p>\n
sudo apt install php7.3 php7.3-cli php7.3-fpm php7.3-common php7.3-curl php7.3-gd php7.3-json php7.3-mbstring php7.3-xml php7.3-zip php7.3-opcache php-apcu<\/pre>\nYou can check the version by running:<\/p>\n
php -v<\/pre>\nOutput:<\/p>\n
PHP 7.3.7-2+ubuntu18.04.2+deb.sury.org+1 (cli) (built: Jul 25 2019 11:44:40) ( NTS )<\/pre>\n<\/span>Step 3: Install and Configure Nginx<\/span><\/span><\/h2>\nWe will use Nginx as a web server as well as configure server block for a specific domain. We will install Nginx from the official Ubuntu repositories.<\/p>\n
To install Nginx run:<\/p>\n
sudo apt install nginx<\/pre>\nTo check the Nginx version, execute this:<\/p>\n
sudo nginx -v<\/pre>\nThe output should look similar to this:<\/p>\n
nginx version: nginx\/1.14.0 (Ubuntu)<\/pre>\nNext, we will configure a new Nginx server block for Grav.<\/p>\n
To create a new Grav configuration file, run the following command:<\/p>\n
sudo nano \/etc\/nginx\/sites-available\/grav.conf<\/pre>\nEdit and paste the following Nginx configuration:<\/p>\n
NOTE:<\/strong> don’t forget to replace yourdomain.com<\/span> with your actual registered domain name.<\/p>\nserver {\r\n\r\nlisten 80;\r\n\r\nserver_name yourdomain.com<\/span>;\r\nroot \/var\/www\/grav;\r\n\r\nindex index.html index.php;\r\n\r\nlocation \/ {\r\n try_files $uri $uri\/ \/index.php?$query_string;\r\n }\r\n\r\n location ~* \/(\\.git|cache|bin|logs|backup|tests)\/.*$ { return 403; }\r\n location ~* \/(system|vendor)\/.*\\.(txt|xml|md|html|yaml|yml|php|pl|py|cgi|twig|sh|bat)$ { return 403; }\r\n location ~* \/user\/.*\\.(txt|md|yaml|yml|php|pl|py|cgi|twig|sh|bat)$ { return 403; }\r\n location ~ \/(LICENSE\\.txt|composer\\.lock|composer\\.json|nginx\\.conf|web\\.config|htaccess\\.txt|\\.htaccess) { return 403; }\r\n\r\nlocation ~ \\.php$ {\r\n fastcgi_pass unix:\/var\/run\/php\/php7.3-fpm.sock;\r\n fastcgi_split_path_info ^(.+\\.php)(\/.+)$;\r\n fastcgi_index index.php;\r\n include fastcgi_params;\r\n fastcgi_param SCRIPT_FILENAME $document_root\/$fastcgi_script_name;\r\n }\r\n\r\n}<\/pre>\nTo activate the new Grav configuration, we need to create a symbolic link to the sites-enabled\u00a0directory:<\/span><\/span><\/p>\nsudo ln -s \/etc\/nginx\/sites-available\/grav.conf \/etc\/nginx\/sites-enabled\/<\/pre>\nNow, test the Nginx configuration:<\/p>\n
nginx -t<\/pre>\nIf the test is successful, restart the Nginx service:<\/p>\n
sudo systemctl restart nginx.service<\/pre>\n