Drupal Full Stack Installation (trying to)

Log

2020-10-23-11:00

  • Confingure and compile with additional –with-openssl and –with-zlib

  • make test: test passes but there are some warnings i do not understand (or have no time to investigate them)

  • make install: all ok

  • cd ../test_project/

  • /opt/php-7.4.11-fpm/bin/php composer-setup.php: successfully installed to /…/test_project/composer.phar, Use it with php composer.phar

  • Installed phpmailer/phpmailer with command /opt/php…/bin/php composer.phar require phpmailer/phpmailer and it was successfull

  • Tried /opt/php-7.4.11-fpm/bin/php ./composer.phar create-project drupal/recommended-project: Failed, requiring ext-gd

  • Failed to find ext-gd in composer packages

  • Searching on google and eventually on php manual: php should be compiled with –enable-gd. So we recompile.

  • Configure with command:

    ./configure --prefix=/opt/php-7.4.11-fpm --with-fpm-user --with-fpm-group --with-fpm-systemd --with-fpm-acl --enable-fpm --with-mysqli --with-openssl --with-zlib --enable-gd --with-jpeg --with-png-dir --with-zlib-dir --with-xpm --with-webp --with-freetype
    
  • reported: unrecognized –with-png-dir

  • adding more options, like ldap etc

  • Let’s do it without optimal set of options and βλέπουμε.

2020-10-23 15:58

This set of options worked up to a drupal local installation with a local composer:

./configure  \
    --prefix=/opt/php-7.4.11-fpm  \
    --with-fpm-user  \
    --with-fpm-group  \
    --with-fpm-systemd  \
    --with-fpm-acl  \
    --enable-fpm  \
    --with-mysqli  \
    --with-openssl  \
    --with-zlib  \
    --enable-gd  \
    --with-jpeg  \
    --with-zlib-dir  \
    --with-xpm  \
    --with-webp  \
    --with-freetype  \
    --with-fpm-group  \
    --with-fpm-systemd  \
    --with-fpm-acl  \
    --with-bz2  \
    --enable-calendar  \
    --with-curl  \
    --with-ldap

2020-10-23 18:40

Basic installation is Ok with the above options.

But it cannot cooperate with apache, until I make php fpm cooperate with apache

2020-10-26 20:31

Libraries needed (at least) for php compilation (ubuntu 20.04):

libsystemd-dev libacl1-dev libattr1-dev libxml2-dev libcurl4-openssl-dev libwebp-dev libldap2-dev

2020-10-26 21:53

Apache modules for working with php-fpm:

proxy_module
proxy_fcgi_module

2020-10-27 14:08

Drupal testing installation needs almost latest sqlite embodied with php.

First:

sudo apt-get install build-essential autoconf libtool bison re2c libxml2-dev libonig-dev libssl-dev libargon2-0-dev libsodium-dev libcurl4-openssl-dev libreadline-dev libyaml-dev libgmp-dev autoconf-archive gnu-standards autoconf-doc bison-doc readline-doc libyaml-doc m4-doc doc-base

How to embody latest sqlite:

New PHP configure command:

WD=""  # Working Directory
PV="7.4.12" # PHP Version
PKG_CONFIG_PATH="$WD/sqlite-inst/lib/pkgconfig" LDFLAGS="-L/$WD/sqlite-inst/lib"  ./configure --prefix=$WD/php-inst-$PHP_VERSION --with-fpm-user --with-fpm-group --with-fpm-systemd --with-fpm-acl --enable-fpm --enable-bcmath --enable-calendar --enable-opcache --enable-mbstring --enable-intl --with-mysqli --with-openssl --with-zlib --enable-gd --with-jpeg --with-zlib-dir --with-xpm --with-webp --with-freetype --with-fpm-group --with-fpm-systemd --with-fpm-acl --with-bz2 --enable-calendar --with-curl --with-ldap

Then:

make -j 4
make install
./libtool --finish $HOME/local_lab/php-fpm/php-7.4.11/libs  # not sure if this is correct

Still doesn’t work:

The database server version 3.22.0 is less than the minimum required version 3.26.

2020-11-3 14:08

First Let’s try again compiling sqlite:

./configure --prefix=$WD/sqlite-inst/
make
make install

Everything seems to be fine. The result sais:

Libraries have been installed in:
$WD/sqlite-inst/lib

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the '-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the 'LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the 'LD_RUN_PATH' environment variable
     during linking
   - use the '-Wl,-rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to '/etc/ld.so.conf'

Now let’s try compiling php:

export WD="..."
export PV="7.4.12"
export LIBDIR="$WD/sqlite-inst/lib"
export LD_LIBRARY_PATH="$LIBDIR:$LD_LIBRARY_PATH"
export LDFLAGS="-L$LIBDIR"
export LD_RUN_PATH=$LIBDIR:$LD_RUN_PATH"
export PKG_CONFIG_PATH="$WD/sqlite-inst/lib/pkgconfig"
tar xzf php-$PV.tar.gz
cd php-$PV/


./configure --prefix=$WD/php-inst-$PV --with-fpm-user --with-fpm-group --with-fpm-systemd --with-fpm-acl --enable-fpm --enable-bcmath --enable-calendar --enable-opcache --enable-mbstring --enable-intl --with-mysqli --with-openssl --with-zlib --enable-gd --with-jpeg --with-zlib-dir --with-xpm --with-webp --with-freetype --with-fpm-group --with-fpm-systemd --with-fpm-acl --with-bz2 --enable-calendar --with-curl --with-ldap

make -j 4
make install

No error reported. Keep walking; installing composer and drupal core:

cd ../test_project/
cp ../php-$PV/php.ini-production .
ln -s php.ini-production ./php.ini
../php-inst-$PV/bin/php -c ./php.ini -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
../php-inst-$PV/bin/php -c ./php.ini -r "if (hash_file('sha384', 'composer-setup.php') === 'c31c1e292ad7be5f49291169c0ac8f683499edddcfd4e42232982d0fd193004208a58ff6f353fde0012d35fdd72bc394') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
../php-inst-$PV/bin/php -c ./php.ini composer-setup.php
../php-inst-$PV/bin/php -c ./php.ini -r "unlink('composer-setup.php');"
../php-inst-$PV/bin/php -c ./php.ini ./composer.phar create-project drupal/recommended-project

No problem reported:

FPM configuration

ln -s php-fpm.conf.default /$WD/php-inst-$PV/etc/php-fpm.conf

vim /$WD/php-inst-$PV/etc/php-fpm.d/www.conf

listen = 127.0.0.1:8888
user = www-data
group = www-data

Start FPM daemon

sudo /$WD/php-inst-$PV/sbin/php-fpm -y /$WD/php-inst-$PV/etc/php-fpm.conf -c /$WD/test_project/php.ini

Apache configuration

<VirtualHost...>
ProxyPassMatch ^/dr/(.*\.php(/.*)?)$ fcgi://127.0.0.1:8888/$WD/test_project/recommended-project/web/$1
</VirtualHost>

It seems to work! Web page does not work properly. I guess this is because the location of test_project is not accessible by the web server. Notice that php runs as an independent scripting language, not as part of the web server. So, it processes any file it is given, but front-end files must be accessible by web server.

Anyway, drupal mechanism with custom php with fastcgi process manager, seems to work fine through apache.

2020-11-4 13:19

It works, but it doesn’t:

Error message
Notice: Undefined variable: finished in _batch_process() (line 355 of core/includes/batch.inc).

_batch_process(Array) (Line: 186)
_batch_progress_page() (Line: 86)
_batch_page(Object) (Line: 663)
install_run_task(Array, Array) (Line: 568)
install_run_tasks(Array, NULL) (Line: 118)
install_drupal(Object) (Line: 44)

100%
Initializing.

And yet it works!
The message above seems to be due to apache misconfiguration.

I got drupal default site.
Now i get some “Not Found” messages on some links (e.g. logout) but that’s a drupal thing.

Before getting inside drupal, I will try to make apache communicate to php-fpm with sockets instead of local (ip,port).

2020-11-4 17:42

Two things for the “Not found” links:

  1. .htaccess must be enabled to work for the site

  2. In case drupal is located in a subdirectory. the RewriteBase rule in the .htaccess must be the directory of the drupal location.

For the .htacces to work, the configuration of the directory in the Apache Virtual Host must be like this:

<Directory /var/www/html/>
AllowOverride All
</Directory>

Also rewrite module must be enabled in the apache

cd /etc/apache/mods-enabled
ln -s ../mods-available/rewrite.load .