How to install PHP 7.2, MariaDB and Drupal 8 on CentOS 7

Submitted by aknnn on Sun, 10/07/2018 - 11:14

Install PHP 7.2 from Remi repository

yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
yum install yum-config-manager
yum-config-manager --enable-remi-php72
yum update
yum install php
yum install php72-php-fpm php72-php-gd php72-php-json php72-php-mbstring php72-php-mysqlnd php72-php-xml php72-php-xmlrpc
yum install php-opcache php-mysql php-pdo

I don't know if the above is the recommended way because I had to:
cp /opt/remi/php72/root/usr/lib64/php/modules/* /usr/lib64/php/modules/
to make PHP find all the .so files I included in the php.ini:
extension=xmlwriter.so
extension=pdo_mysql.so
extension=mysql.so
extension=mysqli.so
extension=msqlind.so
extension=dom.so
extension=pdo.so
extension=gd.so
extension=simplexml.so
extension=xml.so
extension=mbstring.so
zend_extension=opcache.so

Well, fuckit. It works.

Allow access to web server from the internet (*BONUS: change SSH port for added security)
*vim /etc/ssh/sshd_config
*Port SSH_PORT_NUMBER
In /etc/sysconfig/iptables and ip6tables
add lines to enable web access *and access to new ssh port:
-A INPUT -m state --state NEW -p tcp --dport 80 -j ACCEPT
*-A INPUT -m state --state NEW -p tcp --dport SSH_PORT_NUMBER -j ACCEPT
systemctl disable firewalld
systemctl stop firewalld
systemctl enable iptables
systemctl restart iptables
*systemctl restart sshd

*If you changed your ssh port, you can ssh into your server with:
*ssh -p port_number username@server.com
*and scp works like: (Note the capital -P)
*scp -P PORT_NUMBER /path/to/file username@server.com:/path/to/directory/

yum install mariadb-server
systemctl enable mariadb
systemctl start mariadb

Download Composer installer from getcomposer.org:
Install it globally by running:
php installer (run this in the directory the installer is in)
Move composer.phar to somewhere in your $PATH (renaming it to just composer is also convenient).
You can check the folders in your $PATH by typing:
echo $PATH
mv composer.phar /usr/local/bin/composer

Create drupal project.
cd in to the directory you want to create the project in (for example: cd /var/www/html/).
composer require alchemy/zippy
composer create-project drupal-composer/drupal-project:8.x-dev DESIRED_PROJECT_FOLDER_NAME --stability dev --no-interaction

In the end of the process Drupal asks you to make a couple of files with custom privileges. Make them.

Now you need to configure Apache to allow access to your web site folder.
I made a virtual host configuration, because I might want to add additional
sites to server afterwards:

Edit /etc/httpd/conf/httpd.conf like this:

DocumentRoot "/var/www/html/YOUR_PROJECT_FOLDER_NAME"> <<-- the folder made by composer during drupal installation.

<Directory "/var/www/html">
    AllowOverride All
    require all granted
</Directory>

Create /etc/httpd/conf.d/vhost.conf and add these lines:

NameVirtualHost *:80

<VirtualHost *:80>
    ServerAdmin "your_email@example.com"
    ServerName "yourwebsite.com"
    ServerAlias "www.yourwebsite.com"
    DocumentRoot /var/www/html/aknnn/web
    <Directory />
        Options FollowSymlinks
        require all granted
        AllowOverride All
    </Directory>
</VirtualHost>

After restarting httpd, you should be covered.

visit your-server.com to check out if drupal is working. If not, check logs (e.g. /var/log/httpd/error_log).

Add new comment