Hello everyone !
The configuration of a CMS like WordPress can sometimes present a challenge on certain systems.
On OmniOSCE, the communication between Apache and PHP differs from OpenIndiana.
While OpenIndiana has an apache-php8X package, things need to be done manually on OmniOS.
This can pose a challenge for administrators who are not accustomed to handling php-fpm.
Here is how to do.
And it's not so hard !
The following procedure is designed to be fully copied/pasted directly into a terminal (via SSH for example) for the purpose of quickly testing WordPress on OmniOS.
Naturally, much more work will be needed for a production deployment !
You need to be root all the time for this tutorial
First, update your system
#####################################################
# 0) PREPARE YOUR SYSTEM
#
# Update
#---------------------------------------------------#
pkg update
# If you are french, then you need to set time !
# pkg install ntpsec && /usr/bin/ntpdate 0.fr.pool.ntp.org && date && svcadm enable svc:/network/ntp:default
# Reboot if necessary
#---------------------------------------------------#
reboot
Then we start :
#####################################################
# 1) OAMP STACK (OmniOS Apache MariaDB PHP)
#
# APACHE
#---------------------------------------------------#
pkg install pkg:/ooce/server/apache-24
# MariaDB 10.11
#---------------------------------------------------#
pkg install pkg:/ooce/database/mariadb-1011
# Start MariaDB service
svcadm enable svc:/ooce/database/mariadb1011:default && sleep 5
# Check if MariaDB has correctly started
svcs svc:/ooce/database/mariadb1011:default
# Create a SQL base for wordpress
mysqladmin -uroot create wordpressdb
# Check if wordpressdb has been created
mysql -uroot -e"show schemas;"
# Create the privileged user for wordpressdb
mysql -uroot -e"CREATE USER 'adminwp'@'localhost' IDENTIFIED BY 'password'"
# Check if the user has been created
mysql -uroot -e"select user, host from mysql.user;"
# Grand all privileges for adminwp on wordpressdb base :
mysql -uroot -e"GRANT ALL ON wordpressdb.* TO 'adminwp'@'localhost'"
# PHP 8.3
#---------------------------------------------------#
pkg install pkg:/ooce/application/php-83
# Activate extensions required for wordpress
sed -i 's/;extension=curl/extension=curl/' /etc/opt/ooce/php-8.3/php.ini
sed -i 's/;extension=gd/extension=gd/' /etc/opt/ooce/php-8.3/php.ini
sed -i 's/;extension=mbstring/extension=mbstring/' /etc/opt/ooce/php-8.3/php.ini
sed -i 's/;extension=zip/extension=zip/' /etc/opt/ooce/php-8.3/php.ini
sed -i 's/;extension=exif/extension=exif/' /etc/opt/ooce/php-8.3/php.ini
sed -i 's/;extension=openssl/extension=openssl/' /etc/opt/ooce/php-8.3/php.ini
sed -i 's/;extension=fileinfo/extension=fileinfo/' /etc/opt/ooce/php-8.3/php.ini
sed -i 's/;zend_extension=opcache/zend_extension=opcache/' /etc/opt/ooce/php-8.3/php.ini
sed -i 's/;extension=mysqli/extension=mysqli/' /etc/opt/ooce/php-8.3/php.ini
# Add php user to webservd group (for php-fpm)
usermod -G webservd php
# Start PHP :
svcadm disable svc:/application/php83:default && sleep 5 && svcadm enable svc:/application/php83:default
# Check if PHP has started :
svcs svc:/application/php83:default
# WORDPRESS
#---------------------------------------------------#
# Download wordpress latest version and install it
mkdir /var/www && wget http://wordpress.org/latest.tar.gz -P /var/www/ && tar -xvzf /var/www/latest.tar.gz -C /var/www/ && rm /var/www/latest.tar.gz
# Configure wp-config.php with SQL informations
cp /var/www/wordpress/wp-config-sample.php /var/www/wordpress/wp-config.php
sed -i 's/database_name_here/wordpressdb/' /var/www/wordpress/wp-config.php
sed -i 's/username_here/adminwp/' /var/www/wordpress/wp-config.php
sed -i 's/password_here/password/' /var/www/wordpress/wp-config.php
sed -i 's/localhost/127.0.0.1/' /var/www/wordpress/wp-config.php
# Configure permissions
find /var/www/wordpress -type d -exec chmod 755 {} \;
find /var/www/wordpress -type f -exec chmod 644 {} \;
chmod 640 /var/www/wordpress/wp-config.php
chown -R webservd:webservd /var/www/wordpress
# APACHE CONFIGURATION
#---------------------------------------------------#
# Create logs folder
mkdir -p /opt/ooce/apache-2.4/logs/
chown webservd:webservd /opt/ooce/apache-2.4/logs/
chmod 755 /opt/ooce/apache-2.4/logs/
# Create a VirtualHost configuration for wordpress
echo '<VirtualHost *:80>' > /etc/opt/ooce/apache-2.4/extra/wordpress.conf
echo ' ' >> /etc/opt/ooce/apache-2.4/extra/wordpress.conf
echo ' ServerAdmin admin@wordpress.lan' >> /etc/opt/ooce/apache-2.4/extra/wordpress.conf
echo ' DocumentRoot "/var/www/wordpress"' >> /etc/opt/ooce/apache-2.4/extra/wordpress.conf
echo ' ServerName wordpress.lan' >> /etc/opt/ooce/apache-2.4/extra/wordpress.conf
echo ' ServerAlias www.wordpress.lan' >> /etc/opt/ooce/apache-2.4/extra/wordpress.conf
echo ' ErrorLog "/opt/ooce/apache-2.4/logs/wordpress-error_log"' >> /etc/opt/ooce/apache-2.4/extra/wordpress.conf
echo ' CustomLog "/opt/ooce/apache-2.4/logs/wordpress-access_log" common' >> /etc/opt/ooce/apache-2.4/extra/wordpress.conf
echo ' ' >> /etc/opt/ooce/apache-2.4/extra/wordpress.conf
echo ' <Directory "/var/www/wordpress">' >> /etc/opt/ooce/apache-2.4/extra/wordpress.conf
echo ' AllowOverride All' >> /etc/opt/ooce/apache-2.4/extra/wordpress.conf
echo ' Require all granted' >> /etc/opt/ooce/apache-2.4/extra/wordpress.conf
echo ' DirectoryIndex index.php index.html index.htm' >> /etc/opt/ooce/apache-2.4/extra/wordpress.conf
echo ' </Directory>' >> /etc/opt/ooce/apache-2.4/extra/wordpress.conf
echo ' ' >> /etc/opt/ooce/apache-2.4/extra/wordpress.conf
echo ' <FilesMatch \.php$>' >> /etc/opt/ooce/apache-2.4/extra/wordpress.conf
echo ' SetHandler "proxy:unix:/var/opt/ooce/php/run/www-8.3.sock|fcgi://localhost/"' >> /etc/opt/ooce/apache-2.4/extra/wordpress.conf
echo ' </FilesMatch>' >> /etc/opt/ooce/apache-2.4/extra/wordpress.conf
echo ' ' >> /etc/opt/ooce/apache-2.4/extra/wordpress.conf
echo '</VirtualHost>' >> /etc/opt/ooce/apache-2.4/extra/wordpress.conf
# Include our wordpress.conf in httpd.conf
echo ' ' >> /etc/opt/ooce/apache-2.4/httpd.conf
echo '#-------------------------#' >> /etc/opt/ooce/apache-2.4/httpd.conf
echo '# Wordpress VirtualHost' >> /etc/opt/ooce/apache-2.4/httpd.conf
echo 'Include /etc/opt/ooce/apache-2.4/extra/wordpress.conf' >> /etc/opt/ooce/apache-2.4/httpd.conf
# Configure Apache to communicate with PHP
sed -i 's/#LoadModule proxy_module libexec\/mod_proxy.so/LoadModule proxy_module libexec\/mod_proxy.so/' /etc/opt/ooce/apache-2.4/httpd.conf
sed -i 's/#LoadModule proxy_fcgi_module libexec\/mod_proxy_fcgi.so/LoadModule proxy_fcgi_module libexec\/mod_proxy_fcgi.so/' /etc/opt/ooce/apache-2.4/httpd.conf
# Start Apache
svcadm enable svc:/network/http:apache24 && sleep 5
From another computer on the same network, you can now access the wordpress site.
Don't forget to add a mapping between your server's IP and the site name we just created (wordpress.lan) in your hosts file on your client computer before attempting to access the site via your web browser (http : / / wordpress . lan).
A few other commands to know :
Check is Apache is running :
svcs svc:/network/http:apache24
Restart Apache :
(I suggest you not to you use svcadm restart option.. it sometimes restart badly with apache whereas the configuration is perfect.. I don't know why).
svcadm disable svc:/network/http:apache24 && sleep 5 && svcadm enable svc:/network/http:apache24
Get the apache service log location :
svcs -xv
Look into the log
cat /var/svc/log/network-http:apache24.log
Check the log of our wordpress site :
cat /opt/ooce/apache-2.4/logs/wordpress-error_log
Find the complete name of each service
svcs -a | grep php
svcs -a | grep apache
Check the syntax of your apache configuration
/opt/ooce/apache-2.4/bin/apachectl configtest
Good Luck Everyone !