Preface
System environment
[root@lnmp mysql]# cat /etc/redhat-release CentOS Linux release 7.3.1611 (Core) [root@lnmp mysql]# uname -r 3.10.0-514.el7.x86_64
Official Download Address
Install MariaDB 10.3.13
1. Download mariadb binary package
Because the compilation time of source packages is too long, the binary packages that have been compiled are not selected.
$ wget https://mirrors.shu.edu.cn/mariadb//mariadb-10.3.13/bintar-linux-x86_64/mariadb-10.3.13-linux-x86_64.tar.gz
2. decompression
$ tar -zxvf mariadb-10.3.13-linux-x86_64.tar.gz
3. Place the decompressed binary package in the software directory
Here I'm used to placing it under / usr/local and renaming it mysql
$ mv mariadb-10.3.13-linux-x86_64 /usr/local/mysql
4. Create a Data Storage Directory and Manage User mysql
$ groupadd mysql $ useradd -s /sbin/nologin -M mysql $ cd /usr/local/mysql $ chown -R mysql:mysql .
5. initialization
$ ./scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
If this step is wrong:
/usr/local/mariadb/bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
Solution: Yum install-y libaio-devel
6. Check if the installation is successful
Use $ech $?, after initializing the command, to see if the return result is 0, 0 for success, not 0 for failure.
7. Copy startup script and manage it with chkconfig tool
$ cd /usr/local/mysql $ cp support-files/mysql.server /etc/init.d/mysqld # Define startup script content, modify datadir and basedir $ vim /etc/init.d/mysqld # modify basedir=/usr/local/mysql # Catalogue of Software datadir==/usr/local/mysql/data # Storage data catalogue # After modification, set boot self-start $ chkconfig --add mysqld $ chkconfig mysqld on
8. Set mariadb configuration file / etc/my.cnf
$ vim /etc/my.cnf # Modify the configuration to datadir=/usr/local/mysql/data socket=/tmp/mysql.sock log-error=/usr/local/mysql/data/mariadb.log pid-file=/usr/local/mysql/data/mariadb.pid
Save Exit.
9. Start mariadb Service
$ /etc/init.d/mysqld start #Start mariadb
10. View port processes
[root@lnmp mysql]$ netstat -lntp | grep mysql tcp6 0 0 :::3306 :::* LISTEN 4225/mysqld [root@lnmp mysql]$ ps aux | grep mysql root 4140 0.0 0.0 115436 1756 ? S 13:31 0:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/usr/local/mysql/data --pid-file=/usr/local/mysql/data/lnmp.pid mysql 4225 0.0 4.8 1713716 90736 ? Sl 13:31 0:00 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/usr/local/mysql/data/mariadb.log --pid-file=/usr/local/mysql/data/lnmp.pid --socket=/tmp/mysql.sock root 4280 0.0 0.0 112728 964 pts/1 S+ 13:43 0:00 grep --color=auto mysql
11. Enter mariadb database
$ /usr/local/mysql/bin/mysql Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 10 Server version: 10.3.13-MariaDB MariaDB Server Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]>
12. Setting up Soft Connections
$ ln -s /usr/local/mysql/bin/mysql /usr/bin $ ln -s /usr/local/mysql/bin/mysqladmin /usr/bin
13. Set the root password
$ mysqladmin -u root -p '!@#123qwe'
14. root user logs in to mysql
[root@lnmp mysql]# mysql -u root -p Enter password: Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 16 Server version: 10.3.13-MariaDB MariaDB Server Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]>
So far mariadb has been installed.
Install php7.3.3
1. Download the package
Download address: http://php.net/get/php-7.3.3.tar.bz2/from/a/mirror
Choose the Chinese mirror site to download, or copy the link address wget to download.
Here I download to my window and upload to linux.
2. decompression
$ tar -jxvf php-7.3.3.tar.bz2 # Failure to install the bzip2 tool will result in an error $ yum install -y bzip2
3. Installation dependency packages
$ yum install -y gcc libxml2-devel zlib-devel openssl-devel bzip2-devel libjpeg-devel libpng-devel epel-release libmcrypt-devel curl-devel freetype-devel
4. Compilation parameters
$ ./configure --prefix=/usr/local/php-fpm --with-config-file-path=/usr/local/php/etc --enable-fpm --with-fpm-user=php-fpm --with-fpm-group=php-fpm --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-mysql-sock=/tmp/mysql.sock --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-ftp --enable-mbstring --enable-exif --with-pear --with-curl --with-openssl
5. installation
make && make install
6. Copy configuration files
$ cp /usr/local/src/php-7.3.3/php.ini-development /usr/local/php-fpm/etc/php.ini $ cp /usr/local/php-fpm/etc/php-fpm.conf.default /usr/local/php-fpm/etc/php-fpm.conf
7. Configure startup script to set startup
$ cp /usr/local/src/php-7.3.3/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm $ chmod +x php-fpm $ chkconfig --add php-fpm $ chkconfig php-fom on
8. Create users and configure pool
$ useradd php-fpm $ cp /usr/local/php-fpm/etc/php-fpm.d/www.conf.default /usr/local/php-fpm/etc/php-fpm.d/www.conf
9. Start the service and view the process
[root@lnmp ~]$ service php-fpm start Starting php-fpm done [root@lnmp ~]$ ps aux | grep php-fpm root 18747 0.0 0.3 115992 6284 ? Ss 13:27 0:00 php-fpm: master process (/usr/local/php-fpm/etc/php-fpm.conf) php-fpm 18748 0.0 0.3 115992 5836 ? S 13:27 0:00 php-fpm: pool www php-fpm 18749 0.0 0.3 115992 5836 ? S 13:27 0:00 php-fpm: pool www root 18751 0.0 0.0 112724 988 pts/0 S+ 13:27 0:00 grep --color=auto php-fpm [root@lnmp ~]$ netstat -lntp | grep php-fpm tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 18747/php-fpm: mast
php is installed.
Compile and install nginx1.14.2
1. Download the package
$ cd /usr/local/src $ wget http://nginx.org/download/nginx-1.14.2.tar.gz
2. decompression
$ tar -zxvf nginx-1.14.2.tar.gz
3. Compile and install
$ cd nginx-1.14.2 $ ./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module $ make && make install
4. Add nginx startup script
$ vim /etc/init.d/nginx
The contents are as follows:
#!/bin/bash # chkconfig: - 30 21 # description: http service. # Source Function Library . /etc/init.d/functions # Nginx Settings NGINX_SBIN="/usr/local/nginx/sbin/nginx" NGINX_CONF="/usr/local/nginx/conf/nginx.conf" NGINX_PID="/usr/local/nginx/logs/nginx.pid" RETVAL=0 prog="Nginx" start() { echo -n $"Starting $prog: " mkdir -p /dev/shm/nginx_temp daemon $NGINX_SBIN -c $NGINX_CONF RETVAL=$? echo return $RETVAL } stop() { echo -n $"Stopping $prog: " killproc -p $NGINX_PID $NGINX_SBIN -TERM rm -rf /dev/shm/nginx_temp RETVAL=$? echo return $RETVAL } reload() { echo -n $"Reloading $prog: " killproc -p $NGINX_PID $NGINX_SBIN -HUP RETVAL=$? echo return $RETVAL } restart() { stop start } configtest() { $NGINX_SBIN -c $NGINX_CONF -t return 0 } case "$1" in start) start ;; stop) stop ;; reload) reload ;; restart) restart ;; configtest) configtest ;; *) echo $"Usage: $0 {start|stop|reload|restart|configtest}" RETVAL=1 esac exit $RETVAL
5. Setting nginx boot-up
$ chmod +x /etc/init.d/nginx $ chkconfig --add nginx $ chkconfig nginx on
6. Start nignx and view process ports
[root@lnmp nginx-1.14.2]$ /etc/init.d/nginx start Starting nginx (via systemctl): [ Sure? ] [root@lnmp nginx-1.14.2]$ ps aux | grep nginx root 21486 0.0 0.0 45948 1120 ? Ss 13:50 0:00 nginx: master process /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf nobody 21487 0.0 0.1 46384 1900 ? S 13:50 0:00 nginx: worker process root 21489 0.0 0.0 112724 988 pts/0 S+ 13:50 0:00 grep --color=auto nginx [root@lnmp nginx-1.14.2]$ netstat -lntp | grep nginx tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 21486/nginx: master
So far, nginx has been installed.