In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
What is LNMP?
LNMP (alias LEMP) refers to the dynamic Web applications and servers composed of Linux, Nginx, MySQL/MariaDB and PHP/Perl/Python. It is the basic software package of a group of Web applications. In this basic environment, we can build any dynamic websites using PHP/Perl/Python and other languages, such as business websites, blogs, forums and open source Web application software. It is one of the widely used Web website architectures on the Internet.
Deployment mode
From the point of view of the size of the website (visit traffic, registered users, etc.), the LNMP architecture can use stand-alone deployment and cluster deployment. Stand-alone deployment means that all software is deployed on a Linux server; cluster deployment can install Nginx network server, MySQL/MariaDB database and PHP software on different servers separately, and they communicate with each other through TCP network protocol to assist each other, as well as provide Web application access services. Therefore, when a single server cannot meet the performance requirements, it can be deployed in a clustered manner.
This tutorial will show you how to install the LNMP application server environment using Nginx 1.10, MariaDB 10, and PHP 6 in RHEL 7/CentOS 7 and derivative versions of Fedora 23-24-25. (you can also refer to this tutorial for compiling and installing LNMP in other systems such as SUSE and Ubuntu.)
Prerequisite requirement
Prepare two RHEL 7 or CentOS 7 servers, one for installing MariaDB and the other for installing Nginx and PHP. Of course, you can also deploy LNMP using only one server to verify LNMP experimentally.
HOSTNAMEIPOSNODE
Hming-server217-mdb
10.0.6.217CentOS 7.2 x86_64MariaDBhming-server218-web10.0.6.218CentOS 7.2 x86_64MariaDB,Nginx,PHP
Main package (source package)
DB mariadb-10.1.20.tar.gz
PHP php-5.6.30.tar.bz2
Nginx nginx-1.10.2.tar.gz
Note: I have downloaded the main package in advance, it may not be the latest and stable version, you can also choose other versions according to your needs.
Dependent software
Source code compilation installation LNMP there are many dependent software (such as gcc, make) is necessary, generally can be installed through the YUM software manager, and a small part of the need for source code compilation installation.
Install gcc, gcc-c++, make and other necessary software packages through yum
# yum install-y gcc gcc-c++ make automake
Install MariaDB
1. Use yum to install dependent software packages such as gcc, make, bison, ncurses-devel, etc.
# yum install zlib-devel ncurses ncurses-devel bison
two。 Installing cmake,cmake is a necessary tool for compiling MySQL/MariaDB (MySQL5.6/MariaDB 10 and later) you can download the cmake package from the website https://cmake.org/
Upload the package to the / usr/local/src directory, then extract the cmake package, cd to the cmake directory to execute the. / bootstrap script to install, and you can use the-- prefix= option to specify the installation directory.
# tar-zxf cmake-3.7.2.tar.gz# cd cmake-3.7.2/#. / bootstrap-- prefix=/usr/local/cmake# make & & make install
After the installation, you can use / usr/local/cmake/bin/cmake-- version to view the installed version of cmake
[root@hming-server217-mdb] # / usr/local/cmake/bin/cmake-- versioncmake version 3.7.2 CMake suite maintained and supported by Kitware (kitware.com/cmake).
3. After installing the cmake compilation tool, let's install MariaDB (you can visit https://mariadb.org/ to download MariaDB), first create the MariaDB installation directory / usr/local/mysql and the database server's data directory / data/mysql/webdata, create the MySQL user, and change the primary permissions of the / data/mysql/webdata directory to the mysql user
Create installation directory and data directory
# mkdir / usr/local/mysql# mkdir / data/mysql/webdata-p
Create a mysql user and modify the permissions of the data directory
# groupadd mysql# useradd-r-g mysql-s / sbin/nologin mysql-M # chown-R mysql:mysql / data/mysql/
4. Compile and install MariaDB, decompress the MariaDB package and compile it with cmake, and select the appropriate compilation parameters according to the requirements (check the compilation option / usr/local/cmake/bin/cmake. -LH. (or visit the MariaDB compilation and installation help document https://mariadb.com/kb/en/mariadb/compiling-mariadb-from-source/)
[root@hming-server217-mdb / usr/local/src] # tar-zxf mariadb-10.1.20.tar.gz [root@hming-server217-mdb / usr/local/src] # cd mariadb-10.1.20/ [root@hming-server217-mdb / usr/local/src/mariadb-10.1.20] # / usr/local/cmake/bin/cmake. -DCMAKE_INSTALL_PREFIX=/usr/local/mysql-DMYSQL_DATADIR=/data/mysql/webdata-DSYSCONFDIR=/etc-DMYSQL_TCP_PORT=3306-DMYSQL_USER=mysql-DDEFAULT_CHARSET=utf8-DEXTRA_CHARSETS=all-DDEFAULT_COLLATION=utf8_general_ci-DMYSQL_UNIX_ADDR=/data/mysql/webdata/mysql.sock-DWITH_INNOBASE_STORAGE_ENGINE=1-DWITH_MYISAM_STORAGE_ENGINE=1-DWITH_MEMORY_STORAGE_ENGINE=1-DWITH_PARTITION_STORAGE_ENGINE=1-DWITH_ARCHIVE_STORAGE_ENGINE=1-DENABLED_LOCAL_INFILE=1-DWITH_EMBEDDED_SERVER=1-DWITH_READLINE=1-DWITH_DEBUG=0
Execute gmake and gmake install for final installation
[root@hming-server217-mdb / usr/local/src/mariadb-10.1.20] # gmake [root@hming-server217-mdb / usr/local/src/mariadb-10.1.20] # gmake install
5. Configure mysql environment variables, if you do not configure the default system can not find mysql executable programs and commands, otherwise you must use the full path to execute any commands related to mysql, check the system default environment variables
To add a mysql environment variable using the export command
[root@hming-server217-mdb ~] # export PATH=$PATH:/usr/local/mysql/bin [root@hming-server217-mdb ~] # echo $PATH/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/usr/local/mysql/bin
Finally, add the mysql environment configuration to the customization file of / etc/profile or / etc/profile.d/
[root@hming-server217-mdb ~] # echo "export PATH=$PATH:/usr/local/mysql/bin" > / etc/profile.d/mysql.sh [root@hming-server217-mdb ~] # source / etc/profile.d/mysql.sh
With the environment variable configured, we can execute the mysql command directly under the shell terminal and use mysql-V to view the mysql version
[root@hming-server217-mdb] # mysql-Vmysql Ver 15.1 Distrib 10.1.20-MariaDB, for Linux (x86 / 64) using readline 5.1
6. Add MariaDB Library Fil
[root@hming-server217-mdb ~] # echo "/ usr/local/mysql/lib" > > / etc/ld.so.conf.d/mariadb-x86_64.conf
7. Copy the MariaDB service startup script to the / etc/init.d/ directory
[root@hming-server217-mdb ~] # cp / usr/local/mysql/support-files/mysql.server / etc/init.d/mysqld [root@hming-server217-mdb ~] # chmod 755 / etc/init.d/mysqld [root@hming-server217-mdb ~] # chkconfig-- add mysqld [root@hming-server217-mdb] # chkconfig mysqld on [root@hming-server217-mdb ~] # systemctl daemon-reload
8. Execute the initialization database script and install the MariaDB base database (execute. / mysql_install_db-- basedir=/usr/local/mysql-- datadir=/data/mysql/webdata-- user=mysql-- no-defaults)
[root@hming-server217-mdb] # cd / usr/local/mysql/scripts/ [root@hming-server217-mdb / usr/local/mysql/scripts] #. / mysql_install_db-- basedir=/usr/local/mysql-- datadir=/data/mysql/webdata-- user=mysql-- no-defaults [root@hming-server217-mdb / usr/local/mysql/scripts] # ls / data/mysql/webdata/aria_log.00000001 ibdata1 ib_logfile1 performance_schemaaria_log_control ib_logfile0 mysql test
9. Configuration / etc/my.cnf, which is the main configuration file for the mysql service
[root@hming-server217-mdb ~] # cp / etc/my.cnf / etc/my.cnf.save [root@hming-server217-mdb ~] # cat / etc/ my.cnf [client] port=3306socket=/data/mysql/webdata/mysql.sockdefault-character-set=utf8 [mysqld] port=3306user=mysqlbasedir=/usr/local/mysqldatadir=/data/mysql/webdatasocket=/data/mysql/webdata/mysql.sockcharacter-set-server=utf8external-locking=FALSEskip-name-resolvdefault-storage-engine=InnoDBback_log=1024transaction_isolation=REPEATABLE-READmax_connections=5000max_connect_errors=6000open_files_limit=65535table_open _ cache=512 [mysqldump] quickmax_allowed_packet=32M [mysql] no-auto-rehashdefault-character-set=utf8 [mysqld_safe] open-files-limit=8192log-error=/var/log/mariadb/mariadb.logpid-file=/var/run/mariadb/mariadb.pid
Create / var/log/mariadb and / var/run/mariadb directories
[root@hming-server217-mdb ~] # mkdir / var/log/mariadb [root@hming-server217-mdb ~] # mkdir / var/run/mariadb [root@hming-server217-mdb ~] # chown mysql:mysql / var/log/mariadb [root@hming-server217-mdb ~] # chown mysql:mysql / var/run/mariadb
10. Start the MariaDB service
[root@hming-server217-mdb ~] # systemctl start mysqld [root@hming-server217-mdb ~] # systemctl status mysqld [root@hming-server217-mdb ~] # systemctl status mysqld ● mysqld.service-LSB: start and stop MySQL Loaded: loaded (/ etc/rc.d/init.d/mysqld) Active: active (running) since Fri 2017-06-02 23:53:09 CST 3 days ago Docs: man:systemd-sysv-generator (8) Process: 27419 ExecStop=/etc/rc.d/init.d/mysqld stop (code=exited, status=0/SUCCESS) Process: 27449 ExecStart=/etc/rc.d/init.d/mysqld start (code=exited, status=0/SUCCESS) CGroup: / system.slice/mysqld.service ├─ 27460 / bin/sh / usr/local/mysql/bin/mysqld_safe-- datadir=/data/mysql/webdata-- pid-file=/data/mysq... └─ 27595 / usr/local/mysql/bin/mysqld-- basedir=/usr/local/mysql-- datadir=/data/mysql/webdata-- plugi...Jun 02 23:53:08 hming-server217-mdb systemd [1]: Starting LSB: start and stop MySQL...Jun 02 23:53:08 hming-server217-mdb mysqld [27449]: Starting MySQL.170602 23:53:08 mysqld_safe Logging to'/... og'.Jun 02 23:53:09 hming-server217-mdb mysqld [27449]: SUCCESS!Jun 02 23:53:09 hming-server217-mdb systemd [1]: Started LSB: start and stop MySQL.Hint: Some lines were ellipsized Use-l to show in full.
View MariaDB service processes
[root@hming-server217-mdb ~] # ps aux | grep mysqlroot 27460 0.0 115380 1744? S 23:53 0:00 / bin/sh / usr/local/mysql/bin/mysqld_safe-- datadir=/data/mysql/webdata-- pid-file=/data/mysql/webdata/hming-server217-mdb.pidmysql 27595 1.05.2 1209380 99428? Sl 23:53 0:00 / usr/local/mysql/bin/mysqld-- basedir=/usr/local/mysql-- datadir=/data/mysql/webdata-- plugin-dir=/usr/local/mysql/lib/plugin-- user=mysql-- log-error=/var/log/mariadb/mariadb.log-- open-files-limit=8192-- pid-file=/data/mysql/webdata/hming-server217-mdb.pid-- socket=/data/mysql/webdata/mysql.sock-- port=3306root 27627. 0 112644 952 pts/2 S + 23:53 0:00 grep-color=auto mysql
11. Execute mysql_secure_installation to initialize the database and set the mysql user root password
[root@hming-server217-mdb ~] # mysql_secure_installation NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY! In order to log into MariaDB to secure it, we'll need the currentpassword for the root user. If you've just installed MariaDB, andyou haven't set the root password yet, the password will be blank,so you should just press enter here. Enter current password for root (enter for none): OK, successfully used password, moving on... Setting the root password ensures that nobody can log into the MariaDBroot user without the proper authorisation. Set root password? [Y/n] yNew password:Re-enter new password:Password updated successfully!Reloading privilege tables.. ... Success! By default, a MariaDB installation has an anonymous user, allowing anyoneto log into MariaDB without having to have a user account created forthem. This is intended only for testing, and to make the installationgo a bit smoother. You should remove them before moving into aproduction environment. Remove anonymous users? [Y/n] y... Success! Normally, root should only be allowed to connect from 'localhost'. Thisensures that someone cannot guess at the root password from the network. Disallow root login remotely? [Y/n] y... Success! By default, MariaDB comes with a database named 'test' that anyone canaccess. This is also intended only for testing, and should be removedbefore moving into a production environment. Remove test database and access to it? [YBO] y-Dropping test database... ... Success!-Removing privileges on test database... ... Success! Reloading the privilege tables will ensure that all changes made so farwill take effect immediately. Reload privilege tables now? [Y/n] y... Success! Cleaning up... All done! If you've completed all of the above steps, your MariaDBinstallation should now be secure. Thanks for using MariaDB!
twelve。 Log in to the MariaDB database
[root@hming-server217-mdb] # mysql-uroot-pEnter password:Welcome to the MariaDB monitor. Commands end with; or\ g.Your MariaDB connection id is 353Server version: 10.1.20-MariaDB Source distribution Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others. Type 'help;' or'\ h' for help. Type'\ c'to clear the current input statement. MariaDB [(none)] > select version (); +-+ | version () | +-+ | 10.1.20-MariaDB | +-+ 1 row in set (0.00 sec) MariaDB [(none)] >
Install Nginx
1. Install dependent packages
[root@hming-server218-web ~] # yum install gcc gcc-c++ zlib zlib-devel pcre pcre-devel openssl-devel gd gd-devel perl-devel perl-ExtUtils-Embed
two。 Create a nginx user
[root@hming-server218-web] # groupadd nginx [root@hming-server218-web] # useradd-g nginx-s / sbin/nologin nginx-M
3. Compile and install Nginx
[root@hming-server218-web / usr/local/src] # tar-zxf nginx-1.10.2.tar.gz [root@hming-server218-web / usr/local/src] # cd nginx-1.10.2/ [root@hming-server218-web / usr/local/src/nginx-1.10.2] #. / configure\-- user=nginx\-- group=nginx\-- prefix=/usr/local/nginx\-- pid-path=/var/run/nginx/nginx.pid\- Lock-path=/var/lock/subsys/nginx\-- with-http_stub_status_module\-- with-pcre\-- with-http_ssl_module\-- with-mail_ssl_module\-- with-http_gzip_static_module\-- http-log-path=/var/log/nginx/access.log\-- error-log-path=/var/log/nginx/error.log\-- http-client-body-temp-path=/tmp/nginx/client_body\- Http-proxy-temp-path=/tmp/nginx/proxy\-http-fastcgi-temp-path=/tmp/nginx/fastcgi\-- http-uwsgi-temp-path=/tmp/nginx/uwsgi\-- with-http_degradation_module\-- with-http_realip_module\-- with-http_addition_module\-- with-http_sub_module\-- with-http_perl_module\-- with-http_p_w_picpath_filter_module=dynamic\-- with-http_flv_ Module [root@hming-server218-web / usr/local/src/nginx-1.10.2] # make & & make install
4. Start the Nginx service
[root@hming-server218-web ~] # ln-s / usr/local/nginx/sbin/nginx / usr/local/sbin/ [root@hming-server218-web ~] # mkdir / tmp/nginx [root@hming-server218-web ~] # nginx [root@hming-server218-web ~] # ps-ef | grep nginxroot 27913 10 00:49? 00:00:00 nginx: master process nginxnginx 27914 27913 0 00:49? 00:00:00 nginx: Worker processroot 27923 22381 0 00:49 pts/1 00:00:00 grep-color=auto nginx
5. Add Firewall
[root@hming-server218-web] # firewall-cmd-- permanent-- add-port=80/tcpsuccess [root@hming-server218-web] # firewall-cmd-- reloadsuccess
6. Access http://10.0.6.218 through the client
Install PHP
Install dependent packages
[root@hming-server218-web ~] # yum install gcc gcc-c++ libtool libxslt-devel libpng libpng-devel bzip2 bzip2-devel libxml2-devel libXpm-devel libcurl-devel curl libmcrypt expat libxslt freetype freetype-devel libmcrypt-devel autoconf libpng zlib-devel zlib net-snmp net-snmp-devel
two。 Install libiconv
[root@hming-server218-web ~] # tar-zxf libiconv-1.15.tar.gz [root@hming-server218-web ~] # cd libiconv-1.15/ [root@hming-server218-web ~ / libiconv-1.15] #. / configure-- prefix=/usr/local/libiconv [root@hming-server218-web ~ / libiconv-1.15] # make & & make install [root@hming-server218-web ~] # echo "/ usr/local/libiconv/lib" > > / etc/ Ld.so.conf [root@hming-server218-web ~] # ldconfig
3. Install libmcrypt
[root@hming-server218-web ~] # tar-jxf libmcrypt-2.5.8.tar.bz2 [root@hming-server218-web ~] # cd libmcrypt-2.5.8/ [root@hming-server218-web ~ / libmcrypt-2.5.8] #. / configure-- prefix=/usr/local/libmcrypt [root@hming-server218-web ~ / libmcrypt-2.5.8] # make & & make install
4. Install jpeg
# tar-zxf jpegsrc.v9b.tar.gz# cd jpeg-9b/# mkdir / usr/local/jpeg9 & & mkdir / usr/local/jpeg9/ {bin,lib,include} # mkdir / usr/local/jpeg9/man/man1-p # cp-rf / usr/share/libtool/config/config.sub. & & cp-rf / usr/share/libtool/config/config.guess .cp: overwrite\ u2018./config.sub\ u2019? Ycp: overwrite\ u2018./config.guess\ u2019? Y #. / configure-- prefix=/usr/local/jpeg9-- enable-shared-- enable-static# make & & make install
5. Install libgd
[root@hming-server218-web] # tar-zxf libgd-2.2.3.tar.gz [root@hming-server218-web ~] # cd libgd-2.2.3/ [root@hming-server218-web ~ / libgd-2.2.3] #. / configure-- prefix=/usr/local/libgd2-- with-zlib-- with-jpeg=/usr/local/jpeg9-- with-png-- with-freetype [root@hming-server218-web ~ / libgd-2.2.3] # make & & make install
6. Compile and install PHP
[root@hming-server218-web ~] # groupadd php-fpm [root@hming-server218-web ~] # useradd-g php-fpm-s / sbin/nologin php-fpm-M [root@hming-server218-web ~] # tar-jxf php-5.6.30.tar.bz2 [root@hming-server218-web ~] # cd php-5.6.30/ [root@hming-server218-web] #. / configure\-- prefix=/usr/local/php\-- with-config- File-path=/usr/local/php/etc\-enable-fpm\-- with-fpm-user=php-fpm\-- with-fpm-group=php-fpm\-- with-mysql=/usr/local/mysql\-- with-mysqli=/usr/local/mysql/bin/mysql_config\-- with-jpeg-dir=/usr/local/jpeg9\-- with-mcrypt=/usr/local/libmcrypt\-- with-gd=/usr/local/libgd2\-- with-iconv-dir=/usr/local/libiconv\ -- with-openssl-dir\-- with-freetype-dir\-- with-libxml-dir\-- with-png-dir\-- with-zlib\-- with-curl\-- with-mhash\-- with-pear\-- with-pcre-dir\-- with-gettext\-- enable-soap\-- enable-gd-native-ttf\-- enable-mbstring\-enable-exif\-enable-sockets\-enable-ftp\-disable-ipv6\-enable- Bcmath\-- enable-shmop\-- with-snmp\-- enable-sysvsem [root@hming-server218-web ~ / php-5.6.30] # make [root@hming-server218-web ~ / php-5.6.30] # make test [root@hming-server218-web ~ / php-5.6.30] # make install
7. Copy the php.ini configuration file
[root@hming-server218-web ~ / php-5.6.30] # cp php.ini-production / usr/local/php/etc/php.ini
8. Modify php-fpm.conf configuration file
[root@hming-server218-web ~] # vim / usr/local/php/etc/php- fpm.confession [global] pid = / usr/local/php/var/run/php-fpm.piderror_log = / usr/local/php/var/log/php- fpm.log [www] listen = / var/lib/php/php-fcgi.sockuser = php-fpmgroup = php-fpmlisten.owner = nginxlisten.group = nginxpm = dynamicpm.max_children = 100pm.start_servers = 20pm.min_spare_servers = 5pm.max_spare_servers = 35pm.max_requests = 500rlimit_files = 1024
9. Check configuration
[root@hming-server218-web] # / usr/local/php/sbin/php-fpm-t [05-Jun-2017 20:23:27] NOTICE: configuration file / usr/local/php/etc/php-fpm.conf test is successful
10. Copy the startup script
[root@hming-server218-web ~] # cp php-5.6.30/sapi/fpm/init.d.php-fpm / etc/init.d/php-fpm [root@hming-server218-web ~] # chmod 755 / etc/init.d/php-fpm [root@hming-server218-web ~] # / etc/init.d/php-fpm startStarting php-fpm done
Test whether nginx parses the PHP script properly
1. Modify nginx.conf configuration file
User nginx nginx;worker_processes 4 errorists log / var/log/nginx/error.log notice;pid / var/run/nginx/nginx.pid;worker_rlimit_nofile 65535; events {use epoll; worker_connections 65535;} http {include mime.types; default_type application/octet-stream; server_names_hash_bucket_size 2048; server_names_hash_max_size 4096 Log_format main'$remote_addr-$remote_user [$time_local] "$request"'$status $body_bytes_sent "$http_referer"'"$http_user_agent"$http_x_forwarded_for"; access_log / var/log/nginx/access.log main; sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65 Client_header_timeout 30; client_body_timeout 3m; client_max_body_size 10m; client_body_buffer_size 256k; send_timeout 3m; connection_pool_size 256; client_header_buffer_size 32k; large_client_header_buffers 464k; request_pool_size 4k; output_buffers 432k; postpone_output 1460; client_body_temp_path / tmp/nginx/client_body Proxy_temp_path / tmp/nginx/proxy;fastcgi_temp_path / tmp/nginx/fastcgi; gzip on; gzip_min_length 1k; gzip_buffers 4 16k; gzip_comp_level 3; gzip_http_version 1.1; gzip_types text/plain application/x-javascript text/css text/htm application/xml; gzip_vary on; fastcgi_connect_timeout 300; fastcgi_send_timeout 300; fastcgi_read_timeout 300 Fastcgi_buffer_size 64k; fastcgi_buffers 4 64k; fastcgi_busy_buffers_size 128k; fastcgi_temp_file_write_size 128k; fastcgi_intercept_errors on; server {listen 80; server_name 10.0.6.218; charset UTF8; index index.html index.htm index.php index.jsp; root / usr/local/nginx/html # access_log logs/host.access.log main; location / {root html; index index.html index.htm;} # redirect server error pages to the static page / 50x.html error_page 502 503 504 / 50x.html; location = / 50x.html {root html } # pass the PHP scripts to FastCGI server listening on 127.0.0.1 root html; fastcgi_pass unix:/var/lib/php/php-fcgi.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME 9000 location ~\ .php$ {root html; fastcgi_pass unix:/var/lib/php/php-fcgi.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME / usr/local/nginx/html$fastcgi_script_name; include fastcgi_params }
two。 Test for errors in the syntax of the nginx configuration file
[root@hming-server218-web ~] # nginx-tnginx: the configuration file / usr/local/nginx/conf/nginx.conf syntax is oknginx: configuration file / usr/local/nginx/conf/nginx.conf test is successful
3. Create a test parsing php script
[root@hming-server218-web ~] # vim / usr/local/nginx/html/info.php [root@hming-server218-web ~] # nginx-s reload
4. Visit http://10.0.6.218/info.php
Note: this test script is only used for us to view the module information supported by the currently installed php. It should be deleted immediately after testing.
Install phpMyAdmin
PhpMyAdmin is a free software written in PHP language that aims to manage MySQL databases through the Web interface. PhpMyAdmin supports various operations on MySQL and MariaDB. Users can perform common database operations (database management, tables, fields, indexes, users, permissions, views, functions, etc.) through the Web interface, as well as directly execute any SQL statements.
1. Create a phpMyAdmin Web directory
[root@hming-server218-web ~] # mkdir / app/data/phpMyAdmin-p
two。 Extract the phpMyAdmin package to the / app/data/phpMyAdmin directory
# tar-zxf phpMyAdmin-4.7.1-all-languages.tar.gz# cp-ar phpMyAdmin-4.7.1-all-languages/* / app/data/phpMyAdmin/# chown-R nginx:nginx / app/data/phpMyAdmin# chown-R php-fpm:php-fpm / app/data/phpMyAdmin
3. Modify the nginx configuration to create a server virtual machine configuration file
Http {. # phpMyAdmin server {listen 8000; server_name 10.0.6.218; charset UTF8; index index.html index.htm index.php index.jsp; root / app/data; access_log / var/log/nginx/phpMyAdmin.log main; location / phpMyAdmin/ {index index.html index.htm index.php } location ~\ .php$ {fastcgi_pass unix:/var/lib/php/php-fcgi.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME / app/data$fastcgi_script_name; include fastcgi_params;}
4. Create database root user rights to allow php servers to use root users to manage data servers
[root@hming-server217-mdb] # mysql-uroot-pEnter password:Welcome to the MariaDB monitor. Commands end with; or\ g.Your MariaDB connection id is 13Server version: 10.1.20-MariaDB Source distribution Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others. Type 'help;' or'\ h' for help. Type'\ c'to clear the current input statement. MariaDB [(none)] > select user,host,password from mysql.user +-+ | user | host | password | +- -- + | root | localhost | * 84BB5DF4823DA319BBF86C99624479A198E6EEE9 | | root | 127.0.0.1 | * 84BB5DF4823DA319BBF86C99624479A198E6EEE9 | | root |:: 1 | * 84BB5DF4823DA319BBF86C99624479A198E6EEE9 | +-- -+ 3 rows in set (0.00 sec) MariaDB [(none)] > grant all privileges on *. * to 'root'@'10.0.6.218' identified by' phpMyAdmin_123' Query OK, 0 rows affected (0.00 sec) MariaDB [(none)] > flush privileges;Query OK, 0 rows affected (0.00 sec)
5. Configure firewall rules
# iptables-I INPUT-p tcp-- dport 3306-s 10.0.6.0 add-rich-rule 24-j ACCEPT or # firewall-cmd-- permanent-- add-rich-rule 'rule family=ipv4 source address=10.0.6.0/24 port port=3306 protocol=tcp accept'
6. Modify phpMyAdmin configuration file
# cp/app/data/phpMyAdmin/libraries/config.default.php / app/data/phpMyAdmin/libraries/config.default.php.save# vim / app/data/phpMyAdmin/libraries/config.default.php/** * The 'cookie' auth_type uses AES algorithm to encrypt the password. If * at least one server configuration uses' cookie' auth_type, enter here a * pass phrase that will be used by AES. The maximum length seems to be 46 * characters. * * @ global string $cfg ['blowfish_secret'] * / $cfg [' blowfish_secret'] = '123456mm; / * MySQL hostname or IP address * * @ global string $cfg [' Servers'] [$I] ['host'] * / $cfg [' Servers'] [$I] ['host'] =' 10.0.6.217' / * MySQL port-leave blank for default port * * @ global string $cfg ['Servers'] [$I] [' port'] * / $cfg ['Servers'] [$I] [' port'] = '3306; / * * Path to the socket-leave blank for default socket * * @ global string $cfg [' Servers'] [$I] ['socket'] * / $cfg [' Servers'] [$I] ['socket'] ='' / * Authentication method (valid choices: config, http, signon or cookie) * * @ global string $cfg ['Servers'] [$] [' auth_type'] * / $cfg ['Servers'] [$I] [' auth_type'] = 'cookie' / * HTTP Basic Auth Realm name to display (only used with 'HTTP' auth_type) * * @ global string $cfg [' Servers'] [$I] ['auth_http_realm'] * / $cfg [' Servers'] [$I] ['auth_http_realm'] ='; / * MySQL user * * @ global string $cfg ['Servers'] [$I] [' user'] * / $cfg ['Servers'] [$I] [' user'] = 'root' / * MySQL password (only needed with 'config' auth_type) * * @ global string $cfg [' Servers'] [$I] ['password'] * / $cfg [' Servers'] [$I] ['password'] =' phpMyAdmin_123'
7. Log in to the phpMyAdmin Web management interface and open http://10.0.6.218:8000/phpMyAdmin/
Enter the database user and password
Test create database
Configure phpMyAdmin to add Nginx login authentication function
1. Modify the Nginx configuration file to add the allow access rules and auth_basic authentication configuration at / phpMyAdmin/
# phpMyAdmin server {listen 8000; server_name 10.0.6.218; charset UTF8; index index.html index.htm index.php index.jsp; root / app/data; access_log / var/log/nginx/phpMyAdmin.log main; location / phpMyAdmin/ {allow 10.0.6.0Comp24; deny all Auth_basic "Auth"; auth_basic_user_file / usr/local/nginx/.htpassword; index index.html index.htm index.php;} location ~\ .php$ {fastcgi_pass unix:/var/lib/php/php-fcgi.sock; fastcgi_index index.php Fastcgi_param SCRIPT_FILENAME / app/data$fastcgi_script_name; include fastcgi_params;}}
two。 Use htpasswd to create a user (HM) and password
[root@hming-server218-web ~] # yum install httpd [root@hming-server218-web ~] # htpasswd-c / usr/local/nginx/.htpassword HMNew password: Re-type new password: Adding password for user HM [root@hming-server218-web ~] # ls-1 / usr/local/nginx/.htpassword-rw-r--r-- 1 root root 41 Jun 6 18:04 / usr/local/nginx/.htpassword
3. Re-access phpMyAdmin, login again requires authentication, which will be required for every subsequent login
Enter user and password
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.