CentOS 7.4 source code installation PHP, spool, nginx, redis, MariaDB

Time:2021-1-25

Source code installation

1. File download

1.1 download PHP source code

  • php.net
    Download php-7.2.7 tar.gz

1.2 download the source code of spool

1.3 download redis source code

1.4 download the hirodis source code

1.5 download nginx source code

1.6 download MariaDB source code

1.7 zip package decompression command

unzip packagename.zip -d ./dir 

one point eight tar.gz Package decompression command

tar -zxvf packagename.tar.gz

2. Installation

2.1 preparation before installation

  • Installing GCC
yum install gcc
  • Install Autoconf
yum install -y autoconf
  • Installing PCRE
yum install -y pcre pcre-devel
  • Install zlib
yum install -y zlib zlib-devel
  • Install the required extensions
yum install libxml2 libxml2-devel openssl openssl-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libmcrypt libmcrypt-devel -y
  • Install the extensions required for the spool installation
yum install glibc-headers
yum install gcc-c++ 

2.2 installing PHP

Do the following in the PHP source directory

  • Execute the. / configure command
./configure --prefix=/usr/local/php72 --with-mysqli --with-pdo-mysql --with-jpeg-dir --with-png-dir  --with-iconv-dir --with-freetype-dir --with-zlib --with-libxml-dir --with-gd --with-openssl --with-mhash --with-curl --with-pear --with-fpm-user=nobody --with-fpm-group=nobody --enable-bcmath --enable-soap --enable-zip --enable-fpm --enable-mbstring --enable-sockets --enable-opcache --enable-pcntl --enable-simplexml --enable-xml --disable-fileinfo --disable-rpath 

–With FPM user = Nobody — with FPM group = nobody can also be set as WWW user

  • Compile and install
make && make install
cp php.ini-development /usr/local/php72/lib/php.ini

Pay attention to the corresponding directory, the production environment is php.ini -production

2.3 install spool

In the swoole source directory

  • Execute phpize
/usr/local/php72/bin/phpize 
  • Execute. / configure
 ./configure 

If prompt: cannot find PHP config. Please use — with PHP config = path
Then use:. / configure — with PHP config = / usr / local / php72 / bin / PHP config

  • Compile and install
make && make install

PHP to open swoole extension

vim /usr/local/php72/lib/php.ini

Search for “; extension =”, and add the extension in the last searched place= swoole.so

  • Check whether the spool extension is installed
/usr/local/php72/bin/php -ir | grep swoole

Output the following contents as normal:
swoole
swoole support => enabled
swoole.aio_thread_num => 2 => 2
swoole.display_errors => On => On
swoole.fast_serialize => Off => Off
swoole.unixsock_buffer_size => 8388608 => 8388608
swoole.use_namespace => On => On
swoole.use_shortname => On => On
PWD => /root/swoole-src-4.0.1
$_SERVER[‘PWD’] => /root/swoole-src-4.0.1

2.4 installing redis

In the redis source directory

  • Install to the specified directory
make PREFIX=/usr/local/redis install

2.5 A to hirredis

In the hirredis source directory

  • Compile and install
 make && make install

2.6 installing nginx

  • Create www groups and users

    groupadd -r www && useradd -r -g www -s /bin/false -M www
  • Create cache directory

    mkdir /var/tmp/nginx
  • to configure

    ./configure --prefix=/usr/local/nginx --conf-path=/usr/local/nginx/conf/nginx.conf --pid-path=/usr/local/nginx/conf/nginx.pid --lock-path=/var/lock/nginx.lock --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --with-http_gzip_static_module --http-client-body-temp-path=/var/tmp/nginx/client --http-proxy-temp-path=/var/tmp/nginx/proxy --http-fastcgi-temp-path=/var/tmp/nginx/fastcgi --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi --http-scgi-temp-path=/var/tmp/nginx/scgi --with-http_stub_status_module --with-http_ssl_module --user=www --group=www

    New SSL support for installation on January 25, 2019

  • Compile and install

    make && make install

2.7 installation of MariaDB

  • Installation dependency
yum install -y libaio  libaio-devel  bison  bison-devel  zlib-devel  openssl openssl-devel  ncurses  ncurses-devel libcurl-devel libarchive-devel  boost  boost-devel  lsof  wget gcc  gcc-c++ make cmake perl kernel-headers kernel-devel  pcre-devel
  • Creating MySQL groups and users
groupadd -r mysql
useradd -r -g mysql -s /sbin/nologin -d /usr/local/mysql -M mysql
  • Create installation directory
mkdir -p /usr/local/mysql
  • Create data storage directory
mkdir -p /data/mysql
  • Modify the ownership of the data storage directory
chown -R mysql:mysql /data/mysql

In the MariaDB source directory

  • cmake
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
 -DMYSQL_DATADIR=/data/mysql \
 -DSYSCONFDIR=/etc \
 -DWITHOUT_TOKUDB=1 \
 -DWITH_INNOBASE_STORAGE_ENGINE=1 \
 -DWITH_ARCHIVE_STPRAGE_ENGINE=1 \
 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
 -DWIYH_READLINE=1 \
 -DWIYH_SSL=system \
 -DVITH_ZLIB=system \
 -DWITH_LOBWRAP=0 \
 -DMYSQL_UNIX_ADDR=/tmp/mysql.sock \
 -DDEFAULT_CHARSET=utf8 \
 -DDEFAULT_COLLATION=utf8_general_ci

To re execute the cmake command, you need to execute: RM – F CMakeCache.txt

  • Compile and install
make && make install

In the installation directory of MariaDB (CD / usr / local / MySQL /)

  • usemysqlThe user executes the script and installs the database to the database directory
scripts/mysql_install_db --user=mysql --datadir=/data/mysql

Output the following

Installing MariaDB/MySQL system tables in ‘/data/mysql’ …
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MariaDB root USER !

To do so, start the server, then issue the following commands:
‘./bin/mysqladmin’ -u root password ‘new-password’
‘./bin/mysqladmin’ -u root -h VM_0_4_centos password ‘new-password’

Alternatively you can run:
‘./bin/mysql_secure_installation’

which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.

See the MariaDB Knowledgebase at http://mariadb.com/kb or the
MySQL manual for more instructions.

You can start the MariaDB daemon with:
cd ‘.’ ; ./bin/mysqld_safe –datadir=’/data/mysql’

You can test the MariaDB daemon with mysql-test-run.pl
cd ‘./mysql-test’ ; perl mysql-test-run.pl

Please report any problems at http://mariadb.org/jira

The latest information about MariaDB is available at http://mariadb.org/.
You can find additional information about the MySQL part at:
http://dev.mysql.com
Consider joining MariaDB’s strong and vibrant community:
https://mariadb.org/get-invol…

  • Initialize MySQL
./bin/mysql_secure_installation
  • View command help
/usr/local/mysql/bin/mysqld --verbose --help
/usr/local/mysql/bin/mysql --help
  • Not solved yet my.cnf The default configuration file for cannot be found
  • Magic support file
support-files/

You can use the files in this folder to manage mysql

Installing php7 in 2.8 Debian distribution

  • Installation dependency
sudo apt-get install -y libxml2-dev build-essential openssl libssl-dev libcurl4-gnutls-dev libjpeg-dev libpng-dev libmcrypt-dev libreadline6 libreadline6-dev curl libfreetype6-dev
  • configure
./configure --prefix=/usr/local/php7.2 --with-mysqli --with-pdo-mysql --with-jpeg-dir --with-png-dir --with-iconv-dir --with-freetype-dir --with-zlib --with-libxml-dir --with-gd --with-openssl --with-mhash --with-curl --with-pear --with-fpm-user=nobody --with-fpm-group=nobody --enable-bcmath --enable-soap --enable-zip --enable-fpm --enable-mbstring --enable-sockets --enable-opcache --enable-pcntl --enable-simplexml --enable-xml --disable-fileinfo --disable-rpath
  • Compile and install
sudo make && sudo make install