系统版本:CentOS7软件版本:nginx-1.14.2 mariadb10.2.22php7.3.2环境准备:更换yum源的repo源为阿里云wget -O /etc/yum.repos.d/epel-7.repo http://mirrors.aliyun.com/repo/epel-7.repo #更换repo源yum install -y lrzsz gcc wget cmake #安装编译器等##本次用的是centos7的系统,对于其他版本的centos请注意repo源的对应版本安装nginx-1.14.2cd #回到家目录yum -y install pcre-devel openssl-devel #环境准备useradd -s /sbin/nologin -M www #创建www用户wget http://nginx.org/download/nginx-1.14.2.tar.gz #下载nginxtar zxvf nginx-1.14.2.tar.gz #解压cd nginx-1.14.2 #进入已解压文件./configure –user=www –group=www –with-http_ssl_module –with-http_stub_status_module –prefix=/usr/local/nginx1.14.2/ #编译检查,开启ssl模块,status模块make && make install #执行编译并安装ln -s /usr/local/nginx1.14.2 /opt/nginx #创建软连接/opt/nginx/sbin/nginx #启动nginx并用浏览器打开检查##上面的命令可以全部复制到shell里面执行安装mariadb-10.2.22cd #回到家目录find -H /etc/ | grep my.c #查看系统默认数据库配置文件rm -rf /etc/my.cnf /etc/my.cnf.d/ #删除默认数据库配置文件rpm -qa|grep mariadb-libs #查询系统自带mariadb-lib软件rpm -e rpm -qa|grep mariadb-libs
–nodeps #删除系统自带的mariadb-libsyum -y install 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 #安装相关依赖软件useradd -s /sbin/login -M -d /usr/local/mysql mysql #创建mysql用户并指定家目录mkdir /usr/local/mysql #创建安装目录mkdir -p /data/mysql #创建数据库存放目录chown mysql:mysql /usr/local/mysql/ #权限设置chown -R mysql:mysql /data/mysql #数据库目录所属设置wget http://mirrors.tuna.tsinghua.edu.cn/mariadb//mariadb-10.2.22/source/mariadb-10.2.22.tar.gz #下载安装包并解压tar zxvf mariadb-10.2.22.tar.gz && cd mariadb-10.2.22 #解压并进入#####执行编译######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#######如果编译失败删除CMakeCache.txt############make && make install #执行安装###安装完成后进行配置###cd /usr/local/mysql #切换目录./scripts/mysql_install_db –user=mysql –datadir=/data/mysql #执行脚本cp support-files/my-large.cnf /etc/my.cnf #复制MariaDB配置文件到/etc目录echo “export PATH=$PATH:/usr/local/mysql/bin/” >> /etc/profile #配置环境变量source /etc/profile #变量更新./support-files/mysql.server start #启动mysql./bin/mysql_secure_installation #初始化mariadb##安装mariadb,时间比较慢安装php7.3.2cd #回到家目录yum -y install zlib-devel libxml2-devel libjpeg-devel libjepg-turbo-devel libiconv-devel freetype-devel libpng-devel gd-devel libcurl-devel libxslt-devel libmcrpt-devel mhash bzip2-devel postgresql-devel libzip-devel #安装依赖软件yum -y remove libzip #删除旧版本包wget https://nih.at/libzip/libzip-1.2.0.tar.gz #下载安装包tar -zxvf libzip-1.2.0.tar.gz && cd libzip-1.2.0 #解压安装包./configure #编译检查make && make install #编译安装cd #返回家目录cp /usr/local/lib/libzip/include/zipconf.h /usr/local/include/zipconf.h wget http://cn2.php.net/distributions/php-7.3.2.tar.bz2 #下载php tar jxvf php-7.3.2.tar.bz2 #下载并解压cd php-7.3.2 #进入安装文件##########编译检查######################################################################## 添加搜索路径到配置文件echo ‘/usr/local/lib64/usr/local/lib/usr/lib/usr/lib64’>>/etc/ld.so.conf#更新配置ldconfig -v’./configure’ ‘–prefix=/usr/local/php’ ‘–with-pdo-pgsql’ ‘–with-zlib-dir=/usr/local/lib/libzip’ ‘–with-freetype-dir=/usr/include/freetype2/freetype’ ‘–enable-mbstring’ ‘–with-libxml-dir=/usr’ ‘–enable-soap’ ‘–enable-calendar’ ‘–with-curl’ ‘–with-gd’ ‘–with-pgsql’ ‘–disable-rpath’ ‘–enable-inline-optimization’ ‘–with-bz2’ ‘–with-zlib’ ‘–enable-sockets’ ‘–enable-sysvsem’ ‘–enable-sysvshm’ ‘–enable-pcntl’ ‘–enable-mbregex’ ‘–enable-exif’ ‘–enable-bcmath’ ‘–with-mhash’ ‘–enable-zip’ ‘–with-pcre-regex’ ‘–with-pdo-mysql’ ‘–with-mysqli’ ‘–with-jpeg-dir=/usr’ ‘–with-png-dir=/usr’ ‘–with-openssl’ ‘–with-fpm-user=www’ ‘–with-fpm-group=www’ ‘–with-libdir=/lib/x86_64-linux-gnu/’ ‘–enable-ftp’ ‘–with-gettext’ ‘–with-xmlrpc’ ‘–with-xsl’ ‘–enable-opcache’ ‘–enable-fpm’ ‘–with-iconv’ ‘–with-xpm-dir=/usr’make #编译make install #安装sed -i ’s#/usr/lib64##g’ /etc/ld.so.conf && sed -i ’s#/usr/local/lib64##g’ /etc/ld.so.conf #恢复配置ldconfig -v##拷贝配置文件###cp php.ini-development /usr/local/php/etc/php.inicp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.confcp sapi/fpm/php-fpm /usr/local/bin##至此安装完成本人在云主机和虚拟机上用以上方法安装都是没有问题的,其中安装路径已经启动软连接的设置可以自己更改。