We all know that installing Drupal 8 and required components on a new Server is as easy as it sounds. I came up with these steps required to install Drupal 8 for the Development environment:
Start
Log into the Linux Server (SSH or GUI)
Tip: If you want the installation to go without prompting you for an answer, you can append a (-y) switch to answer every prompt "Yes"
Server Maintainance
Run: sudo apt-get install (Will install pending System Installation)
Run: sudo apt-get install nginx (Intuitive Web Server)
Install Memcached Server for caching assets
Run: sudo apt-get install libmemcached-tools (A library that provides several tools to manage Memcached Server)
Run: sudo apt-get install Memcached
Check if memcached Server is set to run on 127.0.0.1 in Run: sudo nano /etc/memcached.conf and find the line that begins with -l
Run: sudo systemctl restart memcached (to restart the Memcached Server)
Run netstat -plunt (to verify the port Memcached Server is running on. The port should be 127.0.0.1:11211)
[NB] Make sure that Memcached extension is enabled in PHP.ini (Open/edit php.ini in etc/php/php7.2/fpm/ and get access to php.ini, while in there, search for extensions, add extension=memcached.so and uncomment extension=curl, extension=gd2, mbstring, mysqlcli,pdo and xml for Drupal 8 to Work with PHP processing engine.). This part is kind of tricky if you are using Drupal Web App that relies on Memcached Server. The way you do this is by make an index.php that will print php information file and place it inside your Web Server directory. Then access that file and see if Memcached is included in the php information. -If you don't see Memcached listed on php information. Run: sudo service php.7.2-fpm stop and then start php.7.2-fpm again. In addition, Run: sudo service nginx stop or reload (to restart the Web Server) -Try to access the index.php to see if thememcached extension has been loaded in php.ini. If you see it, then congratulations.
Install PHP7.2-fpm and Extensions
Run: sudo add-apt-repository universe
Run: sudo apt-get install php-fpm php-memcached php-cli php-mysql php-gd(you could append several other extensions like mbstring and others if you like)
Modify php.ini inside /etc/php/7.2/fpm folder in Ubuntu 18.04 File System and include (extension = memcache.so) this will compile memcached library when processing php files.
Run: sudo apt-get install php7.2-xml (If you are hosting a Drupal Site)
While in the php.ini file, comment uncomment the like that begins with cgi.fix_pathinfo=1 and change the value from 1 to 0 (This is for security, what this flag does is, it executes whatever script php finds first. Which is unsafe and not secure)
While doing this, have your log file present and monitor the errors that come. error.log can be found in /var/log folder (Linux)
Restart php7.2-fpm server with this command (sudo service php7.2-fpm start)
Firewall
Run: sudo ufw allow 'Nginx HTTP'
Configure Nginx to Run PHP Files and Reload Nginx Server
Run: sudo systemctl reload nginx.service
Navigate to /etc/nginx/sites-available and make a copy of a default file
In the original default file, include index.php in the line of types of files in Server Section
Then down below where it says: pass PHP scripts to FastCGI server, uncomment and customize the block to match the version of php you installed (This is the hard part, to configure nginx to run PHP. make sure you do extra research when you have problems)
After last step, restart php7.2-fpm service again: Run sudo service php7.2-fpm start
Reload Nginx (Before you reload Nginx Run: nginx -t (see if the configuration file does not contain any errors))
Run: sudo apt-get install && update && upgrade
Install Mysql or MariaDB Database Server
Run: sudo apt-get install mysql server
Run: sudo mysql (Remember, Maria DB is an open source version of Mysql, you might want to install MariaDB instead)
Run: sudo mysql_secure_installation (What this does is, it will execute secure installation script that comes with MySQL server, remove test database, disallow anonymous login and remote access if you want to)
[NB] If you want MySQL service to start on boot time, Run: sudo systemctl enable mysql
Run: CREATE DATABASE databaseName;
Run: GRANT ALL PRIVILEGES ON *.* TO 'username'@'root' IDENTIFIED BY 'password' WITH GRANT OPTION;
Run: FLUSH PRIVILEGES ( for new privileges to be in effect)
Install Composer Dependency Management App/Shell
Run: cd \var\www\yourDrupalProject\var\bin
Run: sudo apt-get install -g composer
Install Drush Console to Manage Drupal Websites
Run: composer require drush/drush
Make sure your database connections are correct in Drupal settings file
When you are in a nano command/shell, searching for phrases becomes really handy. Here is how you do it. Press CTL + W . (and a search bar appears down the Shell)