Install Drupal 8 with phpng (php next generation) on FreeBSD 10.1

After get success with php next generation (phpng) installation I decide to test it with real php script. Drupal came to my attention and I came with a plan of recipe 🙂

  • Drupal 8 (at the moment its 8.0.0-beta4)
  • PHP 7.0.0-dev
  • Lighttpd
  • MariaDB 10

I still use Vultr as Vps provider since my adsl connection is sucks at the moment.

Lets get start

Install MariaDB 10

I use pkg approach than using source way that I did before.

Delete previous installed mysql client

# pkg info | grep mysql
mysql56-client-5.6.22 Multithreaded SQL database (client)
# pkg delete mysql56-client
Checking integrity… done (0 conflicting)
Deinstallation has been requested for the following 1 packages (of 0 packages in the universe):

Installed packages to be REMOVED:
mysql56-client-5.6.22

The operation will free 45 MB.

Proceed with deinstalling packages? [y/N]: y
[1/1] Deinstalling mysql56-client-5.6.22…
[1/1] Deleting files for mysql56-client-5.6.22: 100%

Install MariaDB 10 server and Client

# pkg install -y mariadb100-server mariadb100-client

Enable MariaDB from rc.conf

# echo 'mysql_enable=YES' >> /etc/rc.conf

Start MariaDB Service

# /usr/local/etc/rc.d/mysql-server start

Change MariaDB root password

# /usr/local/bin/mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we’ll need the current
password for the root user. If you’ve just installed MariaDB, and
you haven’t set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none):
OK, successfully used password, moving on…

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n] y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
… Success!
By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] y
… Success!

Normally, root should only be allowed to connect from ‘localhost’. This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] y
… Success!

By default, MariaDB comes with a database named ‘test’ that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] y
– Dropping test database…
… Success!
– Removing privileges on test database…
… Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] y
… Success!

Cleaning up…

All done! If you’ve completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

Add new user for upcoming drupal installation

# mysql -uroot -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 10
Server version: 10.0.15-MariaDB FreeBSD Ports

Copyright (c) 2000, 2014, Oracle, SkySQL Ab and others.

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.

MariaDB [(none)]> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
MariaDB [mysql]> create database drupal;
Query OK, 1 row affected (0.00 sec)

MariaDB [mysql]> grant all privileges on drupal.* to drupal@localhost identified by ‘123456’ with grant option;
Query OK, 0 rows affected (0.00 sec)

MariaDB [mysql]> flush privileges;
Query OK, 0 rows affected (0.01 sec)

MariaDB [mysql]> exit
Bye
#

Compile phpng

I compile phpng using last post.

# mkdir $HOME/tmp/usr/etc

# /root/tmp/usr/etc/php.ini

add these lines

max_execution_time=600
memory_limit=128M
error_reporting=0
display_errors=0
log_errors=0
user_ini.filename=
realpath_cache_size=2M
cgi.check_shebang_line=0

zend_extension=opcache.so.0.0
opcache.enable_cli=1
opcache.save_comments=0
opcache.fast_shutdown=1
opcache.validate_timestamps=1
opcache.revalidate_freq=60
opcache.use_cwd=1
opcache.max_accelerated_files=100000
opcache.max_wasted_percentage=5
opcache.memory_consumption=128
opcache.consistency_checks=0

Install Lighttpd

# pkg install -y lighttpd
Updating FreeBSD repository catalogue…
FreeBSD repository is up-to-date.
All repositories are up-to-date.
The following 2 packages will be affected (of 0 checked):

New packages to be INSTALLED:
lighttpd: 1.4.35_5
pcre: 8.35_2

The process will require 6 MB more space.
1 MB to be downloaded.
Fetching lighttpd-1.4.35_5.txz: 100% 215 KB 219.8k/s 00:01
Fetching pcre-8.35_2.txz: 100% 1 MB 1.1M/s 00:01
Checking integrity… done (0 conflicting)
[1/2] Installing pcre-8.35_2…
[1/2] Extracting pcre-8.35_2: 100%
[2/2] Installing lighttpd-1.4.35_5…
[2/2] Extracting lighttpd-1.4.35_5: 100%

Set Lighttpd run on boot

# echo 'lighttpd_enable=YES' >> /etc/rc.conf

Create document root

# mkdir -p /usr/local/www/data

# touch /usr/local/www/data/index.html

# echo 'tes' > /usr/local/www/data/index.html

Lighttpd Configuration

modules.conf

# ee /usr/local/etc/lighttpd/modules.conf

remove # sign in front of this line:

##
## FastCGI (mod_fastcgi)
##
include “conf.d/fastcgi.conf”

save the file.

# ee /usr/local/etc/lighttpd/conf.d/fastcgi.conf

Add these lines under “server.modules += ( “mod_fastcgi” ) ” : source.

fastcgi.server = ( “.php” => ((
“bin-path” => “/root/tmp/usr/bin/php-cgi”,
“socket” => “/tmp/php.socket”,
“max-procs” => 2,
“bin-environment” => (
“PHP_FCGI_CHILDREN” => “16”,
“PHP_FCGI_MAX_REQUESTS” => “10000”
),
“bin-copy-environment” => (
“PATH”, “SHELL”, “USER”
),
“broken-scriptfilename” => “enable”
)))

Enable fastcgi

Make sure output of

# /root/tmp/usr/bin/php-cgi -v

PHP 7.0.0-dev (cgi-fcgi) (built: Jan 23 2015 04:55:05)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.8.0-dev, Copyright (c) 1998-2014 Zend Technologies

cgi-fcgi means fast cgi enabled.

Testing phpinfo()

# echo "<?php phpinfo();?>" > /usr/local/www/data/info.php

See it from browser.

freebsd_vps_europe_7

 

Fix Lighttpd error message

(network.c.283) warning: please use server.use-ipv6 only for hostnames, not without server.bind / empty address; your config will break if the kernel default for IPV6_V6ONLY changes

That message show up when lighttpd restart.

 

Install Drupal 8

I’ll continue it next time 🙂