Drupal 8 Installation on Linux Systems


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
  1. Log into the Linux Server (SSH or GUI)
  2. 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

  3. Run: sudo apt-get install (Will install pending System Installation)
  4. Run: sudo apt-get update (Will update pending installation)
  5. Run: sudo apt-get upgrade

    Install Nginx Web Server
  6. Run: sudo apt-get install nginx (Intuitive Web Server)

    Install Memcached Server for caching assets
  7. Run: sudo apt-get install libmemcached-tools (A library that provides several tools to manage Memcached Server)
  8. Run: sudo apt-get install Memcached
  9. 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
  10. Run: sudo systemctl restart memcached (to restart the Memcached Server)
  11. Run netstat -plunt (to verify the port Memcached Server is running on. The port should be 127.0.0.1:11211)
  12. [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 the memcached extension has been loaded in php.ini. If you see it, then congratulations.

    Install PHP7.2-fpm and Extensions
  13. Run: sudo add-apt-repository universe
  14. 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)
  15. 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.
  16. Run: sudo apt-get install php7.2-xml (If you are hosting a Drupal Site)
  17. 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)
  18. While doing this, have your log file present and monitor the errors that come. error.log can be found in /var/log folder (Linux)
  19. Restart php7.2-fpm server with this command (sudo service php7.2-fpm start)

    Firewall
  20. Run: sudo ufw allow 'Nginx HTTP'

    Configure Nginx to Run PHP Files and Reload Nginx Server
  21. Run: sudo systemctl reload nginx.service
  22. Navigate to /etc/nginx/sites-available and make a copy of a default file 
  23. In the original default file, include index.php in the line of types of files in Server Section
  24. 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)
  25. After last step, restart php7.2-fpm service again: Run sudo service php7.2-fpm start
  26. Reload Nginx (Before you reload Nginx Run: nginx -t (see if the configuration file does not contain any errors))
  27. Run: sudo apt-get install && update && upgrade

    Install Mysql or MariaDB Database Server
  28. Run: sudo apt-get install mysql server
  29. Run: sudo mysql (Remember, Maria DB is an open source version of Mysql, you might want to install MariaDB instead)
  30. 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)
  31. [NB] If you want MySQL service to start on boot time, Run: sudo systemctl enable mysql
  32. Run: CREATE DATABASE databaseName;
  33. Run: GRANT ALL PRIVILEGES ON *.* TO 'username'@'root' IDENTIFIED BY 'password' WITH GRANT OPTION;
  34. Run: FLUSH PRIVILEGES ( for new privileges to be in effect)

    Install Composer Dependency Management App/Shell
  35. Run: cd \var\www\yourDrupalProject\var\bin
  36. Run: sudo apt-get install -g composer

    Install Drush Console to Manage Drupal Websites
  37. Run: composer require drush/drush
  38. Make sure your database connections are correct in Drupal settings file
  39. Configure Nginx Server to run PHP7.2-fpm docs can be found here
  40. Configure Nginx to run Drupal configuration docs can be found here

    Important
  41. Enable or sudo apt-get install all these:  ext-dom, ext-gd, ext-simplexml,ext-xml,curl in php.ini for drupal to work with composer
  42. Read More LinkHere to Unbuntu documentation

    Bonus
  43. 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) 

Linux
published
v.0.01





For peering opportunity Autonomouse System Number: AS401345 Custom Software Development at ErnesTech Email AddressContact: [email protected]