Hey,
Starting with 5.7, OpenBSD have their own httpd replacing nginx in base. This httpd is fairly new and un/fortunately I'm trying to learn Drupal nowadays. Sure I can install Apache or nginx from port but I want to test the new httpd.
Take note!
1) I'm currently on -CURRENT using snapshot.
2) I never installed drupal or any web app before.
3) This is a Work In Progress and will be updated until it's done.
So I guess that's quite a warning for you guys. My installation might not be the correct one or might not even install correctly but I will try to make sure I find out how to make this work. Googling for info on the new httpd with Drupal only return less than handful of info. But as always, web searching is needed. So without any delays, here I go.
SETTING UP HTTPD.
As I'm going Openbsd's own (and new) httpd, the program has been already installed. To enable it, I just need to edit /etc/httpd.conf. I commented all the entries in that file except for this few lines (mostly the "A minimal default server" entries).
---- /etc/httpd.conf start ----
# Macros
ext_addr="*"
# A minimal default server
server "default" {
listen on $ext_addr port 80
location "*.php" {
fastcgi socket "/run/php-fpm.sock"
}
root "/htdocs"
}
# Include MIME types instead of the built-in ones
types {
include "/usr/share/misc/mime.types"
}
---- /etc/httpd.conf end ----
As a simple rule-of-a-thumb, start with the minimum configuration then adjust from there. It's easier to check for error/mistakes. As Drupal is a PHP program, I need to install PHP. I also will be using PostgreSQL for the database. What I've installed is:
php-5.6.11
php-fpm.5.6.11p0
php-gd-5.6.11 (this might be dependency, I can't recall right now)
php-pdo_pgsql-5.6.11 (I'll be using PostgreSQL instead of MySQL)
postgresql-client-9.4.4
postgresql-contrib-9.4.4
postgresql-docs-9.4.4 (optional, but I want it)
postgresql-server-9.4.4
As we can see in the /etc/httpd.conf, there's "php-fpm" entry. As the package has been installed, I need to make it start at boot along with httpd by editing /etc/rc.conf.local.
---- /etc/rc.conf.local start ----
httpd_flags=
slowcgi=
pkg_scripts=php_fpm postgresql
---- /etc/rc.conf.local end ----
The "slowcgi" came with httpd, so I add it in /etc/rc.conf.local. Now we can either start httpd, slowcgi & php-fpm manually now or reboot. Unlike Apache, there's no template webpage that you can see after your httpd has started. So I created a Hello World-like index.html file inside the webserver's root directory which is /var/www/htdocs/. So now I open up my web browser and insert the URL as either "localhost" or "127.0.0.1" (without quotes), I can see the Hello World page. Httpd is running fine. To test the PHP function, I created a phpinfo.php file inside the same directory with this value:
---- /var/www/htdocs/phpinfo.php start ----
<?php phpinfo(); ?>
---- /var/www/htdocs/phpinfo.php end ----
I open the URL "localhost/phpinfo.php" in my browser, the PHP Version page is displayed and I know PHP is working fine.
INSTALLING DRUPAL.
I just pkg_add drupal-7.32.p1. Then I read the info in /usr/local/share/doc/pkg-readmes/drupal-7.32p1 telling me to symlink (symbolic link) the drupal7.conf and follow the database setup for PostgreSQL which is:
ln -sf /var/www/conf/modules.sample/drupal7.conf /var/www/conf/modules
createuser -U postgres --pwprompt --no-superuser --createdb --no-createrole drupal
createdb -U drupal -E UTF8 drupal
The "postgres" name is my PostgreSQL's admin name. There will be input request for password so I create a password, verify it and make sure I don't forget it. For drupal7.conf, I haven't touch anything, yet.
SETTING UP DRUPAL.
Webserver running? Check. PostgreSQL running? Check. Drupal running? Not yet. I tried putting "localhost/drupal7" and "127.0.0.1/drupal7" in the browser but both didn't work. I got Error 403 Forbidden. Ouch. I'm seriously lack of experience for this httpd and drupal stuff so I thought that maybe I need to install either Apache or Nginx (assuming that nobody done drupal with httpd yet). That's until I read a hint in www.drupal.org. So, I insert this in my browser:
http://localhost/drupal7/install.php
And wallah!, the Drupal installation page appears!. Yes! It's making progress. So I proceed with the installation as below:
Choose profile = Standard > Save and continue
Choose language = English (built-in) > Sane and continue
Verify requirements = all is ok except for "Unicode library = Error"
7th August: Ok. The error is about a deprecated function in PHP which must be disabled for Drupal's installation to continue. Yeah quite confusing. The exact error is:
Unicode library | Error |
Multibyte string input conversion in PHP is active and must be disabled. Check the php.ini mbstring.http_input setting. Please refer to the PHP mbstring documentationfor more information. |
I opened the PHP mbstring documentation but nothing can help me on this. So I google for tips and found that there's 2 ways to resolve this.
1) Add this lines in .htaccess in Drupal's web root (/var/www/htdocs/drupal7)
---- .htacces start ----
php_value mbstring.http_input pass
php_value mbstring.http_output pass
---- .htaccess end ----
I checked the Drupal's web root, but there's no .htacces file inside. I think this is related to Apache but just to make sure, I downloaded a sample .htacces file from www.drupal.org . Restarted the httpd, open the installation page and still have that error. So this is not working for me.
2) Add this line in ../drupal7/sites/default/setting.php
---- setting.php start ----
ini_set('mbstring.http_input', 'pass');
ini_set('mbstring.http_output', 'pass');
---- setting.php end ----
Restarted the httpd. And open the installation page and greeted by this warning message:
- Deprecated function: ini_set(): Use of mbstring.http_input is deprecated in include_once() (line 318 of /htdocs/drupal7/sites/default/settings.php).
- Deprecated function: ini_set(): Use of mbstring.http_output is deprecated in include_once() (line 319 of /htdocs/drupal7/sites/default/settings.php).
When I click Save and continue, this message appears in every page. But then the Verify requirement page passed successfully (although the warning is still there). So I'm now at the Set up database page.
Set up database:
Database = PostgreSQL
Database name* = drupal (the one I set before in PostgreSQL)
Database username* = drupal
Database password* = (the password I entered back then in PostgreSQL)
But now I'm in dilemma. I don't know if that "Deprecated function:" warning is harmless or not. I think I will search for more clue before I click on that "Save and continue" button.
Update 9th August: Searching on the net point me out to the most relevant issue stated in drupal's site at:
https://www.drupal.org/node/2332295
There's patch files listed on the top of that page and the most relevant one is the file:
drupal7-unicode_requirements-2332295-23.patch
That file will be patching /includes/unicode.inc file in the root Drupal's folder. I read the patch file, and compared with the current unicode.inc file and found that this is the correct patch. Now to patch it.
PATCHING DRUPAL
I downloaded the patch file, and move it to Drupal's root folder at /var/www/htdocs/drupal7 . Patching is something I rarely do so I refresh what I can by using
man patch.
I need to test the patch first, to see if it's working as it's supposed to be. So I proceed with the testing command:
# sudo patch -C includes/unicode.inc drupal7-unicode_requirements-2332295-23.patch
Then the result came:
---- message snipped ----
Patching file includes/unicode.inc using Plan A...
Hunk #1 succeeded at 116.
done
Looks fine to me. So then I proceed with the actual patching:
# sudo patch includes/unicode.inc drupal7-unicode_requirements-2332295-23.patch
Done. Now to test the Drupal's installation. Just remember to delete/comment back both the "ini_set" lines I added in sites/default/settings.php. Restarted httpd and proceed with installation again.
INSTALLATION.
- Get browser to open http://127.0.0.1/drupal7/install.php
- Choose profile > Standard > Save and continue = passed
- Choose language > English (built-in) > Save and continue = passed
- Verify requirements = passed
- Set up database
> Database name = drupal
> Database username = drupal
> Database password = (same as when I set in PostgreSQL)
> Save and continue
Got this error:
In order for Drupal to work, and to continue with the installation process, you must resolve all issues reported below. For more help with configuring your database server, see the
installation handbook. If you are unsure what any of this means you should probably contact your hosting provider.
Failed to connect to your database server. The server reports the following message: SQLSTATE[08006] [7] could not translate host name "localhost" to address: no address associated with name.
- Is the database server running?
- Does the database exist, and have you entered the correct database name?
- Have you entered the correct username and password?
- Have you entered the correct database hostname?
Ok. I read that because httpd in OpenBSD is chrooted, I need to copy /etc/hosts and put it in /var/www/etc/. By default there's no etc/ folder in www so I need to mkdir it. Make sure that "hosts" file at least have this line:
127.0.0.1 localhost www.example.com
Now that should be it. Restarted httpd again and run throught the installation again.
- Set up database
> blablabla
> Save and continue = passed
- Install profile (it will take a moment = passed
- Configure site
> Site name* = default
> Site e-mail address* = noreply@example.com (can be changed)
> Username = karl
> E-mail address = (real email address)
> Password* = *********
> Confirm password* = *********
> Default country = Malaysia
> Default time zone = Asia/Kuala Lumpur
> Check for updates automatically = checked
> Received e-mail notifications = checked
> Save and continue = FINISHED!
Congratulations, I installed Drupal. Now to visit my local site.
Unfortunately, currently I can't use http://127.0.0.1/drupal7/ to visit my site (which if my httpd configured correctly, should be the correct address) but I can visit the site by using complete URL instead.
http://127.0.0.1/drupal7/index.html
For Drupal, all seems ok. I need to further test out and start exploring. For httpd issue above, I will also do the same. I will update on these issues when I found any tips. Enjoy the screenshot. Later.
UPDATE!: Bah although Drupal has been installed successfully, it's not functioning as it should. I have a feeling it's related to OpenBSD's httpd's setting. I would be grateful if someone can point me to relevant setting for this issue. Thanks in advance.
Update 10th August: Ok I have configured the /etc/httpd.conf file and now Drupal is working fine. Here's my configuration:
---- /etc/httpd.conf start ----
ext_addr="*"
server "default" {
listen on $ext_addr port 80
directory {
index "index.php"
}
location "*.php" {
fastcgi socket "/run/php-fpm.sock"
}
location "/cgi-bin/*" {
fastcgi
root "/"
}
root "/htdocs/drupal7"
}
---- /etc/httpd.conf end ----
Restarted the httpd server. Now when I type www.example.com or 127.0.0.1 or localhost in my browser, I can see the Drupal start page. I typed my Username and Password then I can see the site correctly. No more errors.
I've also posted a Hello World! entry to test it out. Enjoy the screenshot. Later.