前言系统环境[root@lnmp mysql]# cat /etc/redhat-release CentOS Linux release 7.3.1611 (Core) [root@lnmp mysql]# uname -r3.10.0-514.el7.x86_64官方下载地址mariadb数据库phpngixn安装mariadb10.3.131. 下载mariadb二进制包由于源码包编译时间过长就不选用了,而选用已经编译过的二进制包$ wget https://mirrors.shu.edu.cn/mariadb//mariadb-10.3.13/bintar-linux-x86_64/mariadb-10.3.13-linux-x86_64.tar.gz2. 解压$ tar -zxvf mariadb-10.3.13-linux-x86_64.tar.gz3. 将解压后的二进制包放置软件目录这里我习惯放置在/usr/local下,并改名mysql$ mv mariadb-10.3.13-linux-x86_64 /usr/local/mysql4. 创建数据存储目录与管理用户mysql$ groupadd mysql$ useradd -s /sbin/nologin -M mysql$ cd /usr/local/mysql$ chown -R mysql:mysql .5.初始化$ ./scripts/mysql_install_db –user=mysql –basedir=/usr/local/mysql –datadir=/usr/local/mysql/data这一步如果报错:/usr/local/mariadb/bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory 解决:yum install -y libaio-devel6.检查是否安装成功在初始化命令之后使用$ ech $?,查看返回结果是否为0,为0表示成功,不为0表示失败。 7.拷贝启动脚本,并用chkconfig工具管理$ cd /usr/local/mysql$ cp support-files/mysql.server /etc/init.d/mysqld# 定义启动脚本内容,修改datadir和basedir$ vim /etc/init.d/mysqld# 修改basedir=/usr/local/mysql # 软件的目录datadir==/usr/local/mysql/data # 存放数据目录# 修改完,设置开机自启动$ chkconfig –add mysqld$ chkconfig mysqld on8.设置mariadb配置文件/etc/my.cnf$ vim /etc/my.cnf# 修改配置内容为datadir=/usr/local/mysql/datasocket=/tmp/mysql.socklog-error=/usr/local/mysql/data/mariadb.logpid-file=/usr/local/mysql/data/mariadb.pid保存退出。9. 启动mariadb服务$ /etc/init.d/mysqld start #启动mariadb10. 查看端口进程[root@lnmp mysql]$ netstat -lntp | grep mysqltcp6 0 0 :::3306 :::* LISTEN 4225/mysqld [root@lnmp mysql]$ ps aux | grep mysqlroot 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.pidmysql 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.sockroot 4280 0.0 0.0 112728 964 pts/1 S+ 13:43 0:00 grep –color=auto mysql 11. 进入mariadb数据库 $ /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. 设置软连接$ ln -s /usr/local/mysql/bin/mysql /usr/bin $ ln -s /usr/local/mysql/bin/mysqladmin /usr/bin13. 设置root密码$ mysqladmin -u root -p ‘!@#123qwe'14. root用户登录mysql[root@lnmp mysql]# mysql -u root -pEnter password: Welcome to the MariaDB monitor. Commands end with ; or \g.Your MariaDB connection id is 16Server version: 10.3.13-MariaDB MariaDB ServerCopyright (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)]> 至此mariadb安装完毕。安装php7.3.31. 下载软件包下载地址:http://php.net/get/php-7.3.3.tar.bz2/from/a/mirror选择中国镜像站点下载,或者复制链接地址wget下载也可以。这里我是先下载到我的window再上传到linux。2. 解压$ tar -jxvf php-7.3.3.tar.bz2 # 如果没有安装bzip2工具会报错$ yum install -y bzip23. 安装依赖包$ yum install -y gcc libxml2-devel zlib-devel openssl-devel bzip2-devel libjpeg-devel libpng-devel epel-release libmcrypt-devel curl-devel freetype-devel4. 编译参数$ ./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-openssl5. 安装make && make install6. 拷贝配置文件$ 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.conf7. 配置启动脚本设置开机启动$ 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 on8. 创建用户,配置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.conf9.启动服务,查看进程[root@lnmp ~]$ service php-fpm startStarting php-fpm done[root@lnmp ~]$ ps aux | grep php-fpmroot 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 wwwphp-fpm 18749 0.0 0.3 115992 5836 ? S 13:27 0:00 php-fpm: pool wwwroot 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-fpmtcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 18747/php-fpm: mast php安装完毕。编译安装nginx1.14.21. 下载软件包$ cd /usr/local/src$ wget http://nginx.org/download/nginx-1.14.2.tar.gz2. 解压$ tar -zxvf nginx-1.14.2.tar.gz 3. 编译安装$ cd nginx-1.14.2$ ./configure –prefix=/usr/local/nginx –with-http_stub_status_module –with-http_ssl_module$ make && make install4. 添加nginx启动脚本$ vim /etc/init.d/nginx内容如下:#!/bin/bash# chkconfig: - 30 21# description: http service.# Source Function Library. /etc/init.d/functions# Nginx SettingsNGINX_SBIN="/usr/local/nginx/sbin/nginx"NGINX_CONF="/usr/local/nginx/conf/nginx.conf"NGINX_PID="/usr/local/nginx/logs/nginx.pid"RETVAL=0prog=“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=1esacexit $RETVAL5. 设置nginx开机启动$ chmod +x /etc/init.d/nginx$ chkconfig –add nginx$ chkconfig nginx on6. 启动nignx,查看进程端口[root@lnmp nginx-1.14.2]$ /etc/init.d/nginx startStarting nginx (via systemctl): [ 确定 ][root@lnmp nginx-1.14.2]$ ps aux | grep nginxroot 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.confnobody 21487 0.0 0.1 46384 1900 ? S 13:50 0:00 nginx: worker processroot 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 nginxtcp 0 0 0.0.0.0:80 0.0.0.0: LISTEN 21486/nginx: master 至此nginx安装完毕。