1、源码编译安装LNMP架构环境;
yum groupinstall -y ‘Development Tools’ ‘Server Platform Development’
- 编译nginx
~]# yum install -y openssl-devel pcre-devel ~]# useradd nginx ~]# ./configure --prefix=/usr/local/nginx \ --with-http_stub_status_module \ --with-http_ssl_module \ --user=nginx \ --group=nginx ~]# make && make install
- 编译mariadb
(1) cmake-2.8.8 ./configure && make && make install (2) mariadb useradd mysql cmake . -LH 预编译下 cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \ -DMYSQL_DATADIR=/data/mysql \ -DSYSCONFIGDIR=/etc \ -DWITH_INNOBASE_STORAGE_ENGINE=1 \ -DWITH_ARCHIVE_STORAGE_ENGINE=1 \ -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \ -DWITH_READLINE=1 \ -DWITH_SSL=system \ -DWITH_ZLIB=system \ -DWITH_LIBWRAP=0 \ -DMYSQL_UNIX_ADDR=/tmp/mysql.sock \ -DDEFAULT_CHARSET=utf8 \ -DDEFAULT_COLLATION=utf8_general_ci make && make install 初始化数据 ./mysql_db_install --basedir=/usr/local/mysql --datadir=/data/mysql --user=mysql 加载库和头文件 vim /etc/ld.so.conf.d/mariadb.conf ldconfig ln -s /usr/local/mariadb/include /usr/include/mysql
- 编译php
3、php-7.1.3 useradd www ./configure --prefix=/usr/local/php \ --sysconfdir=/usr/local/php/etc \ --with-curl \ --with-freetype-dir \ --with-gd \ --with-gettext \ --with-iconv-dir \ --with-kerberos \ --with-libdir=lib64 \ --with-libxml-dir \ --with-mysqli \ --with-openssl \ --with-pcre-regex \ --with-pdo-mysql=/usr/local/mariadb \ --with-pdo-sqlite \ --with-pear \ --with-png-dir \ --with-xmlrpc \ --with-xsl \ --with-zlib \ --enable-fpm \ --enable-bcmath \ --enable-libxml \ --enable-inline-optimization \ --enable-gd-native-ttf \ --enable-mbregex \ --enable-mbstring \ --enable-opcache \ --enable-pcntl \ --enable-shmop \ --enable-soap \ --enable-sockets \ --enable-sysvsem \ --enable-xml \ --enable-zip make && make install
2、编写一个脚本完成以下功能:
- (1)、一键搭建LNMP源码编译环境;
- (2)、可通过在脚本后面跟上一些参数来自定义安装目录等其他选项
#!/bin/bash
#install pre packages
yum groupinstall -y 'Development Tools' 'Server Platform Development' openssl-devel pcre-devel
echo "Usage: $0 [nginx_install] [mariadb_install] [php_install]"
nginx_install=${1:-/usr/local/nginx}
mariadb_install=${2:-/usr/local/mariadb}
php_install=${3:-/usr/local/php}
#install nginx
useradd nginx
tar xf nginx.tar.gz
cd nginx
./configure --prefix=${nginx_install} \
--with-http_stub_status_module \
--with-http_ssl_module \
--user=nginx \
--group=nginx
make && make install
cd $nginx_install/sbin
./nginx
#install mariadb
useradd mariadb
tar xf cmake.tar.gz
cd cmake
./configure && make && make install
tar ../mariadb.tar.gz
cd ../mariadb
cmake . -LH
cmake .
-DCMAKE_INSTALL_PREFIX=${mariadb_install} \
-DMYSQL_DATADIR=/data/mysql \
-DSYSCONFIGDIR=/etc \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DWITH_SSL=system \
-DWITH_ZLIB=system \
-DWITH_LIBWRAP=0 \
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci
make && make install
cd $mariadb_install/scripts
./mysql_db_install --basedir=/usr/local/mysql --datadir=/data/mysql --user=mariadb
echo $mariadb_install > /etc/ld.so.conf.d/mariadb.conf
ldconfig
ln -s $mariadb_install/include /usr/include/mysql
#install php
useradd www
tar xf php.tar.gz
./configure --prefix=${php_install} \
--sysconfdir=/usr/local/php/etc \
--with-curl \
--with-freetype-dir \
--with-gd \
--with-gettext \
--with-iconv-dir \
--with-kerberos \
--with-libdir=lib64 \
--with-libxml-dir \
--with-mysqli \
--with-openssl \
--with-pcre-regex \
--with-pdo-mysql=${mariadb_install} \
--with-pdo-sqlite \
--with-pear \
--with-png-dir \
--with-xmlrpc \
--with-xsl \
--with-zlib \
--enable-fpm \
--enable-bcmath \
--enable-libxml \
--enable-inline-optimization \
--enable-gd-native-ttf \
--enable-mbregex \
--enable-mbstring \
--enable-opcache \
--enable-pcntl \
--enable-shmop \
--enable-soap \
--enable-sockets \
--enable-sysvsem \
--enable-xml \
--enable-zip
make && make install
原创文章,作者:N25_随心,如若转载,请注明出处:http://www.178linux.com/74806


评论列表(1条)
写的很好,如果可以把参数解释一下的话会更好