When I first met Solaris, the only drawback for me was the fact that the packages that can be installed are rather obsolete, but fortunately you can build the current versions from the source code. This publication will discuss the assembly of apache and php from the 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 build will be 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 ​​need to be re-added (if you have not finished collecting the necessary packages).
')
Download the necessary archives with the source code (all actions occur 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 mysql directories and 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 apache to build correctly, you also need to build two additional packages apr and apr-util, you can of course use those that are included with Solaris, but in this case you need to make significant changes to the libtool script. First of all, we will build apr, go to the / apr directory and execute the commands for configuration, build, and installation (build and install must be done with gnu version of make). The installation will be made to the / opt directory, if you are used to installing to the / usr / local directory, in this case, you need to edit the --prefix parameter, and also specify the correct path during the subsequent assembly of apache and php:
cd /apr ./configure --prefix=/opt/apr gmake gmake install
Next, you need to collect apr-util, and also specify 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 the 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 needs to be changed as indicated below (delete \ $ global_symbol_pipe):
export_symbols_cmds="\$NM \$libobjs \$convenience | \$SED 's/.* //' | sort | uniq > \$export_symbols"
After these manipulations, apache will assemble without problems (the main thing is to specify the directory with apr and apr-util). A
“multithreaded” version of apache will be built:
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 collect 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 assembling not in the global zone, then you need to copy some dependencies to correctly start the php module, in the example below are the files that need to be copied (the path to the zone indicate the one 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 extra, in this case you can view all the parameters of the assembly with the command:
./configure
The final touch is to install mysql:
pkgadd -d /mysql.pkg
Configuration
It remains only to add mysql and apache to autorun, configure apache to handle php, and also 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 line AddHandler application / x-httpd-php .php to httpd.conf:
echo "AddHandler application/x-httpd-php .php" >> /opt/apache24/conf/httpd.conf
And also change the parameter:
DirectoryIndex index.html
on
DirectoryIndex index.php
or at
DirectoryIndex index.html index.php
The next step is to activate the extension to optimize the "opcodes" (this extension can increase the speed of page generation several times), for this you need to create a file:
touch /opt/php/ext-10-opcache.ini
And 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 a php.ini file in the / opt / php directory, since php searches for configuration files in this particular directory.
To start mysql correctly, you must create the mysql directory in the / etc folder, copy the my.cnf file to this folder, and add a line that indicates the name of the user from whom you want to start 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 need to start mysql with the command:
/etc/init.d/mysql start
After installing mysql, a file (.mysql_secret) with the default password is created in the root of the file system, 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 has not created a link to the client version of mysql in the / usr / bin folder (you can run “mysql-client” from any place (mysql -p -r)), then you need to do it manually:
ln -s /opt/mysql/mysql/bin/mysql /usr/bin/mysql
It remains only to add mysql and apache to autorun (level 3), and also to configure automatic shutdown of services to 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 is shut down. To 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 more convenience, you can create a symbolic link to apchectl in the / usr / bin directory:
ln -s /opt/apache24/bin/apachectl /usr/bin/apachectl
Run apache:
apachectl start
Conclusion
As you can see from this publication, the lack of actual software versions on Solaris is not a sentence, since you can always collect the necessary software from the source code, and if necessary, make some changes to get the maximum efficiency of the software.