Apache PHP MySQL Bundle in Solaris 11.3

    When I first became acquainted with Solaris, the only drawback for me was the fact that the packages that can be installed are quite outdated, but fortunately the current versions can be compiled from the source code. This publication will discuss the assembly of apache and php from source code (mysql can be downloaded as a ready-made package from mysql.com). At the time of this writing, the current version of apache was 2.4.29, and php 7.2.3.

    Assembly


    The first step is to install the gcc-48 package :

    pkg install gcc-48
    

    It is also necessary to define some variables for further compilation (the assembly will occur in 64-bit versions):

    export CPP="/usr/gcc/4.8/bin/gcc -E"
    export CC="/usr/gcc/4.8/bin/gcc"
    export CFLAGS="-m64 -std=gnu99 -fPIC -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
    export LDFLAGS="-m64 -L/usr/lib -R/usr/lib"
    export CXXFLAGS="-m64"
    

    After rebooting the system, these values ​​must be re-added (if you have not finished collecting the necessary packages).

    Download the necessary archives with source code (all actions take place in the root of the file system):

    wget http://php.net/distributions/php-7.2.3.tar.bz2
    wget http://apache-mirror.rbc.ru/pub/apache//httpd/httpd-2.4.29.tar.bz2
    wget http://mirror.linux-ia64.org/apache//apr/apr-1.6.3.tar.bz2
    wget http://mirror.linux-ia64.org/apache//apr/apr-util-1.6.1.tar.bz2
    wget https://cdn.mysql.com//Downloads/MySQL-5.6/mysql-5.6.39-solaris11-x86_64.pkg.gz
    

    Unpack:

    tar -xvf apr-1.6.3.tar.bz2
    tar -xvf apr-util-1.6.1.tar.bz2
    tar -xvf httpd-2.4.29.tar.bz2
    tar -xvf php-7.2.3.tar.bz2
    gzip -d mysql-5.6.39-solaris11-x86_64.pkg.gz
    

    Rename the directories and mysql package for more convenience:

    mv mysql-5.6.39-solaris11-x86_64.pkg mysql.pkg
    mv apr-1.6.3 apr
    mv apr-util-1.6.1 apr-util
    mv httpd-2.4.29 apache
    mv php-7.2.3 php
    

    For the correct build of apache, you also need to build two additional packages apr and apr-util, of course you can use the ones that are part of Solaris, but in this case you need to make significant changes to the libtool script. First, let's build apr, go to the / apr directory and execute the commands for configuration, assembly, and installation in sequence (assembly and installation must be done with gnu version of make). The installation will be performed in the / opt directory, if you are more familiar with the installation in the / usr / local directory, in this case you need to edit the --prefix parameter, as well as specify the correct paths during the subsequent assembly of apache and php:

    cd /apr
    ./configure --prefix=/opt/apr
    gmake
    gmake install
    

    Next, you need to build apr-util, and also indicate in which folder apr is installed:

    cd /apr-util
    ./configure  --prefix=/opt/apr-util --with-apr=/opt/apr
    gmake
    gmake install
    

    The final touch in apr installation will be a little editing of libtool, which is located in the / opt / apr / build-1 directory, in this script you need to edit one line:

    export_symbols_cmds="\$NM \$libobjs \$convenience | \$global_symbol_pipe | \$SED 's/.* //' | sort | uniq > \$export_symbols"
    

    This line must be changed as follows (delete \ $ global_symbol_pipe):

    export_symbols_cmds="\$NM \$libobjs \$convenience | \$SED 's/.* //' | sort | uniq > \$export_symbols"
    

    After these manipulations, apache will compile without problems (the main thing is to specify the directory with apr and apr-util). A multi-threaded version of apache will be compiled :

    cd /apache
    ./configure --prefix=/opt/apache24 --with-apr=/opt/apr --with-apr-util=/opt/apr-util --with-mpm=worker
    gmake
    gmake install
    

    It remains only to build php:

    cd /php
    ./configure   --prefix=/opt/php \
                  --with-config-file-path=/opt/php/lib \
                  --with-apxs2=/opt/apache24/bin/apxs  \
    	      --with-config-file-scan-dir=/opt/php \
                  --without-pgsql \
                  --with-zlib \
                  --with-zlib-dir=/usr/include \
                  --with-iconv-dir=/usr/include \
                  --with-pcre-dir=/usr/include \
                  --with-gettext=/usr/include \
                  --with-libxml-dir=/usr/include/libxml2/libxml \
                  --with-curl \
                  --with-openssl \
                  --with-openssl-dir=/usr/include \
                  --with-gd \
                  --with-freetype-dir=/usr/include \
                  --with-xpm-dir=/usr/include \
                  --with-jpeg-dir=/usr/include \
                  --with-png-dir=/usr/include \
                  --with-gnu-ld \
    	      --with-mhash \
                  --enable-shared \
    	      --with-mysqli=mysqlnd \
                  --enable-zip \
                  --enable-ftp \
                  --enable-mysqlnd \
    	      --enable-opcache \
    	      --disable-cli \
    	      --disable-ipv6
    gmake 
    gmake install
    

    If you are building in a non-global zone, you need to copy some dependencies for the php module to start correctly, the example below shows the files you need to copy (specify the path to the zone that you are using):

    cp /usr/lib/amd64/libX11.so.4 /zones/zone1/root/usr/lib/amd64/libX11.so.4
    cp /usr/lib/amd64/libXpm.so.4 /zones/zone1/root/usr/lib/amd64/libXpm.so.4
    cp /usr/lib/amd64/libjpeg.so.62 /zones/zone1/root/usr/lib/amd64/libjpeg.so.62
    cp /usr/lib/amd64/libXext.so.0 /zones/zone1/root/usr/lib/amd64/libXext.so.0
    cp /usr/lib/amd64/libxcb.so.1 /zones/zone1/root/usr/lib/amd64/libxcb.so.1
    cp /usr/lib/amd64/libXau.so.6 /zones/zone1/root/usr/lib/amd64/libXau.so.6
    cp /usr/lib/amd64/libXevie.so.1 /zones/zone1/root/usr/lib/amd64/libXevie.so.1
    cp /usr/lib/amd64/libXss.so.1 /zones/zone1/root/usr/lib/amd64/libXss.so.1
    cp /usr/lib/amd64/libXdmcp.so.6 /zones/zone1/root/usr/lib/amd64/libXdmcp.so.6
    

    If you need to add something additionally, then in this case you can see all the assembly parameters using the command:

    ./configure --help
    

    The final touch will be the installation of mysql:

    pkgadd -d /mysql.pkg
    

    Configuration


    It remains only to add mysql and apache to autorun, configure apache to handle php, and configure mysql to start correctly. In order for apache to correctly handle php scripts, you need to run the following command, this command will add the AddHandler application / x-httpd-php .php line to httpd.conf:

    echo "AddHandler application/x-httpd-php .php" >> /opt/apache24/conf/httpd.conf
    

    And also change the parameter:

    DirectoryIndex index.html
    

    on the

    DirectoryIndex index.php
    

    or at

    DirectoryIndex index.html index.php
    

    As the next step, activate the extension to optimize the “opcodes” (this extension can increase the speed of page generation by several times), for this you need to create a file:

    touch /opt/php/ext-10-opcache.ini
    

    And also add the line zend_extension = opcache.so to this file:

    echo "zend_extension=opcache.so" >> /opt/php/ext-10-opcache.ini
    

    Also, if necessary, you can create the php.ini file in the / opt / php directory, since php looks for configuration files in this directory.

    To start mysql correctly, you need to create the mysql directory in the / etc folder, and copy the my.cnf file to this folder, and also add a line that indicates the username from which you want to run mysql (root):

    mkdir /etc/mysql
    cp /opt/mysql/mysql/my.cnf /etc/mysql/my.cnf
    echo "user = root" >> /etc/mysql/my.cnf
    

    After these manipulations, you must start mysql with the command:

    /etc/init.d/mysql start
    

    After installing mysql, a file (.mysql_secret) is created in the root of the file system with the default password, we use this password to execute the mysql_secure_installation script, in which you can change this password, delete the test databases, delete the test user:

    /opt/mysql/mysql/bin/mysql_secure_installation
    

    If for some reason the installer did not create a link to the client version of mysql in the / usr / bin folder (you can run “mysql-client” from anywhere (mysql -p -r)), you must do this manually:

    ln -s /opt/mysql/mysql/bin/mysql /usr/bin/mysql
    

    It remains only to add mysql and apache to autorun (level 3), as well as configure automatic shutdown of services at level 0. To do this, create links in two directories:

    ln /etc/init.d/mysql /etc/rc0.d/Kmysql
    ln /opt/apache24/bin/apachectl /etc/rc0.d/Kapache
    

    These links will automatically stop services when the system shuts down. For autorun in a multi-user environment (level 3), create the following links:

    ln /etc/init.d/mysql /etc/rc3.d/Smysql
    ln /opt/apache24/bin/apachectl /etc/rc3.d/Sapache
    

    For your convenience, you can create a symlink to apchectl in the / usr / bin directory:

    ln -s /opt/apache24/bin/apachectl /usr/bin/apachectl
    

    Launch apache:

    apachectl start
    

    Conclusion


    As you can see from this publication, the lack of up-to-date versions of software on the Solaris OS is not a sentence, since you can always compile the necessary software from the source code, and if necessary, make some changes to obtain maximum software efficiency.

    Also popular now: