Monthly filing: April 2017

Production of compiling and installing source code of Centos 7 php7.2

Introduction:

I have heard for a long time that the speed and performance of PHP 7 is faster than that of any version of the PHP 5 series. How good is the specific performance? I suggest you try it first. If you are upgrading or installing, you need to first consider whether PHP 7 is compatible with the program. If the program is developed based on PHP 5, you need to consider whether PHP 7 is suitable for your current production environment. Today I will practice and install it for production.

Install the PHP dependency package first, or various errors will appear during the compilation and installation of PHP 7. After the installation is completed, you can move on to the next step.

Install the expansion pack and update the system kernel:

 $ yum install epel-release -y $ yum update

Install php dependency components (including Nginx dependency):

 $ yum -y install wget vim pcre pcre-devel openssl openssl-devel libicu-devel gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel ncurses ncurses-devel curl curl-devel krb5-devel libidn libidn-devel openldap openldap-devel nss_ldap jemalloc- devel cmake boost-devel bison automake libevent libevent-devel gd gd-devel libtool* libmcrypt libmcrypt-devel mcrypt mhash libxslt libxslt-devel readline readline-devel gmp gmp-devel libcurl libcurl-devel openjpeg-devel

Create users and groups, and download the php installation package to unzip:

 $ cd /tmp $ groupadd www $ useradd -g www www $ wget //am1.php.net/distributions/php-7.2.1.tar.gz $ tar xvf php-7.2.1.tar.gz $ cd php-7.2.1

Set variables and start source code compilation:

 $ cp -frp /usr/lib64/libldap* /usr/lib/ $ ./ configure --prefix=/usr/local/php \ --with-config-file-path=/usr/local/php/etc \ --enable-fpm \ --with-fpm-user=www \ --with-fpm-group=www \ --enable-mysqlnd \ --with-mysqli=mysqlnd \ --with-pdo-mysql=mysqlnd \ --enable-mysqlnd-compression-support \ --with-iconv-dir \ --with-freetype-dir \ --with-jpeg-dir \ --with-png-dir \ --with-zlib \ --with-libxml-dir \ --enable-xml \ --disable-rpath \ --enable-bcmath \ --enable-shmop \ --enable-sysvsem \ --enable-inline-optimization \ --with-curl \ --enable-mbregex \ --enable-mbstring \ --enable-intl \ --with-mcrypt \ --with-libmbfl \ --enable-ftp \ --with-gd \ --enable-gd-jis-conv \ --enable-gd-native-ttf \ --with-openssl \ --with-mhash \ --enable-pcntl \ --enable-sockets \ --with-xmlrpc \ --enable-zip \ --enable-soap \ --with-gettext \ --disable-fileinfo \ --enable-opcache \ --with-pear \ --enable-maintainer-zts \ --with-ldap=shared \ --without-gdbm \ --enable-fileinfo \

If there is no error report, execute the next step of installation. If there is an error in the compilation process, install the dependent package according to the error report. This problem usually does not occur.

be careful: – enable gd jis conv This parameter will cause Zabbix Chinese characters to be garbled. It is recommended to cancel it.

Start installation:

 $ make -j 4 && make install

After installation, configure the php.ini file:

 $ cp php.ini-development /usr/local/php/etc/php.ini $ cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf $ cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf

Modify php.ini related parameters:

 $ vim /usr/local/php/etc/php.ini expose_php = Off short_open_tag = ON max_execution_time = 300 max_input_time = 300 memory_limit = 128M post_max_size = 32M date.timezone = Asia/Shanghai mbstring.func_overload=2 extension = "/usr/local/php/lib/php/extensions/no-debug-zts-20160303/ldap.so"

Set OPcache cache:

 [opcache] zend_extension=/usr/local/php/lib/php/extensions/no-debug-zts-20160303/opcache.so opcache.memory_consumption=128 opcache.interned_strings_buffer=8 opcache.max_accelerated_files=4000 opcache.revalidate_freq=60 opcache.fast_shutdown=1 opcache.enable_cli=1

Set the php security function:

 $ vim /usr/local/php/etc/php.ini

Default value:

 disable_functions =

Revised as:

 disable_functions = passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,escapeshellcmd,dll,popen,disk_free_space,checkdnsrr,checkdnsrr,getservbyname,getservbyport,disk_total_space,posix_ctermid,posix_get_last_error, posix_getcwd, posix_getegid,posix_geteuid,posix_getgid, posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid, posix_getppid,posix_getpwnam,posix_getpwuid, posix_getrlimit, posix_getsid,posix_getuid,posix_isatty, posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid, posix_setpgid, posix_setsid,posix_setuid,posix_strerror,posix_times,posix_ttyname,posix_uname

Or general configuration:

 disable_functions = passthru,exec,system,chroot,chgrp,chown,shell_exec,proc_open,proc_get_status,popen,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru

Configure www.conf

Uncomment the following and modify and optimize its parameters:

 listen = /var/run/www/php-cgi.sock listen.owner = www listen.group = www listen.mode = 0660 listen.allowed_clients = 127.0.0.1 pm = dynamic listen.backlog = -1 pm.max_children = 180 pm.start_servers = 50 pm.min_spare_servers = 50 pm.max_spare_servers = 180 request_terminate_timeout = 120 request_slowlog_timeout = 50 slowlog = var/log/slow.log

Create php-cgi.sock storage directory

 $ mkdir /var/run/www/ $ chown -R www:www /var/run/www

Configure php fpm. conf

Remove the following notes and complete the path:

 pid = /usr/local/php/var/run/php-fpm.pid

So far, php7 has been installed.

explain: Disable php functions. If the program needs these functions, you can cancel the prohibition. Novice recommends ignoring this step.

Create a php fpm startup script for the system unit file:

 $ vim /usr/lib/systemd/system/php-fpm.service

Add the following variable contents:

 [Unit] Description=The PHP FastCGI Process Manager After=syslog.target network.target [Service] Type=simple PIDFile=/usr/local/php/var/run/php-fpm.pid ExecStart=/usr/local/php/sbin/php-fpm --nodaemonize --fpm-config /usr/local/php/etc/php-fpm.conf ExecReload=/bin/kill -USR2 $MAINPID [Install] WantedBy=multi-user.target

Start the php fpm service and join the startup auto start:

 $ systemctl enable php-fpm.service $ systemctl restart php-fpm.service

The entire PHP installation process has been completed. If you failed to install according to this article, I hope you can leave a message explaining the reason for the error, and I will help you configure for free.

If you have good suggestions to improve this article, you are welcome to put forward and improve it. We will learn and progress together.

Centos 7 binary installation configuration MariaDB (MySQL) database

preface:

The database server has not been installed for a long time. I remember that the last time MySQL was installed and configured, the system was Cenots 6.5. Now the Centos system version is updated too fast, and can't keep up with the pace. Recently, the company needs several Mariadb servers to practice.

Since the database server version of each company is different, I still recommend that you use the Mariadb database. At least at present, the community and the product are very stable. As for the new functions, I suggest you go to its official office to learn more about the features.

View System Version Command

 $ cat /etc/redhat-release CentOS Linux release 7.4.1708 (Core) x64

1. Install MariaDB (MySQL)

Download the MariaDB binary installation package:

 //downloads.mariadb.org

Unzip and install the Mariadb devel static library:

 $ yum install mariadb-devel numactl -y $ mkdir /renwole $ cd /renwole $ tar zxvf mariadb-10.2.8-linux-glibc_214-x86_64.tar.gz

Move directory and create soft connection:

 $ mv mariadb-10.2.8-linux-glibc_214-x86_64 /usr/local $ cd /usr/local $ ln -s mariadb-10.2.8-linux-glibc_214-x86_64 mysql

Create MariaDB (MySQL) users and groups

 $ groupadd mysql $ useradd -g mysql mysql

Give MariaDB (MySQL) directory permissions:

 $ cd /usr/local/mysql $ chown -R root . $ chown -R mysql data

2. Configure MariaDB (MySQL)

Delete the my.cnf configuration file and create a new one:

 $ rm -rf /etc/my.cnf $ cp /usr/local/mysql/support-files/my-large.cnf /etc/my.cnf

Note: There are five configuration files under/usr/local/mysql/support files. Please select the configuration file according to the memory size of the server (you can also customize and optimize the my.cnf configuration file. If you have one before, it can be used normally as long as it is of the same version, so you don't need to create it again. When MariaDB (MySQL) starts, it will automatically search for the my.cnf file under/etc).

The documents are:

 My small.ini (memory<=64M) My-medium. ini (memory 128M) My-large.ini (512M memory) My-huge.ini (1G-2G memory) My inodb heavy-4G.ini (memory 4GB)

Add the database path in the mysqld field of the my.cnf file:

 $ vim /etc/my.cnf datadir = /usr/local/mysql/data

Note: This path is used to initialize the database. In the future, your database will exist in this directory. This storage path can be changed to another path to avoid unnecessary losses caused by system downtime in the future. Therefore, please change the relative path according to your own needs, and don't forget to give permissions.

3. Initialize the database

 $ cd /usr/local/mysql/scripts $ ./ mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data

4. Set startup script

 $ cd /usr/local/mysql/support-files $ cp mysql.server /etc/init.d/mysql $ chmod +x /etc/init.d/mysql $ systemctl enable mysql

4. Set variables

Add system variables. For example, if you enter mysql - uroot - p directly, you will be prompted that there is no such command:

 $ vim /etc/profile

Add the following at the end of the file:

 PATH=$PATH:/usr/local/mysql/bin export PATH

Make the variable take effect immediately and start the MySQL database:

 $ source /etc/profile $ systemctl restart mysql $ ss -antp

5. Initialize the MariaDB (MySQL) security account

 $ /usr/local/mysql/bin/mysql_secure_installation

Note: Enter the prompt to enter the password of MariaDB (MySQL). The password of newly installed MySQL is blank by default, so enter the prompt directly, and then enter Y to set the MySQL password. Enter Enter twice, and then press Y for all (roughly, delete the test database, anonymous account, and finally Y configuration takes effect.

So far, the installation is complete. If you deploy step by step according to this tutorial, you will succeed. If you fail, you can leave a message and I can help you for free.