Recommended: Min PHP 7.1 for Drupal 8
Although Drupal 8 PHP requirements state that version 5.5.9+ is supported, it isn't recommended.
| PHP version | Supported | Recommended? |
|---|---|---|
| 5.5 | 5.5.9+ | No |
| 5.6 | Yes | No |
| 7.0 | Yes | No |
| 7.1 | Yes | Yes |
| 7.2 | Yes as of Drupal 8.5.0* | Yes |
You probably won't get far with the default PHP installation on Ubuntu 14.04 when it comes to Drupal 8. There will be things that won't work properly and it will be difficult to figure out why.
The good news is that it's possible to update the PHP to a newer version and have everything working without problems. With PHP 7 you also get the additional benefits of performance improvements, error handling, and other new features.
Back to topUpdate PHP to 7.1 on Ubuntu 14.04
Here are the steps how to update the PHP to 7.1 on Ubuntu 14.04 so your websites will work without issues:
# Add the repositorysudo add-apt-repository ppa:ondrej/php
# Update your repos listsudo apt-get update
# Install all the necessary packagessudo apt-get install libapache2-mod-php7.1 php7.1-cli php7.1-common php7.1-json php7.1-opcache libssl1.0.2 php7.1-readline php-common php7.1-xml php7.1-mbstring php7.1-mysql php7.1-gd php7.1-curl
# Disable the existing php5 modulessudo a2dismod php5# Enable php7.1 modulesudo a2enmod php7.1# Restart Apachesudo service apache2 restart
You can now proceed to install Drupal 8 through the usual composer dependencies manager.
Back to topInstall Drupal 8 through composer
If you have already created the database for your new site and if you have composer already installed you can install Drupal 8 into d8 folder with these commands:
cd /var/www/html
composer create-project drupal-composer/drupal-project:8.x-dev d8 --stability dev --no-interaction
cd d8# Some special characters like & and # in your password can be problematic!../vendor/bin/drush site-install --db-url=mysql://{username}:{password}@localhost/{database}
Add Trusted hosts to settings.php
$settings['trusted<em>host</em>patterns'] = array(
'^d8\.local$',
'^www\.d8\.local$',
'^localhost$',
);
Check folder permissions
Make sure your web/sites/default/files folder and it's subfolders are owned by the server user:
cd /var/www/html/d8/web/sites/default/
sudo chown -R www-data:www-data files/
If the web/sites/default/files/styles/ folder doesn't have appropriate permissions you may see a problem where you can upload images, but they won't display.
Start tracking your project
cd /var/www/html
git init# Adjust more files to ignorenano .gitignoregit add .git commit -m "Drupal 8 init"
Install modules through composer, enable them with Drush
To install modules through composer:
# --dev for modules that aren't used on production sitescomposer require --dev drupal/devel
# Commit composer.json and composer.lock anytime they changegit add .git commit -m "Devel module added for dev environments"
cd d8../vendor/bin/drush en devel
