LNMP架构搭建编译安装详细部署
环境准备
关闭防火墙和SElinux
[root@yxr ~]# systemctl stop firewalld
[root@yxr ~]# systemctl disable firewalld
[root@yxr ~]# sed -ri 's/(SELINUX=).*/\1disabled/g' /etc/selinux/config
[root@yxr ~]# setenforce 0
安装nginx
创建系统用户nginx
[root@yxr ~]# useradd -r -M -s /sbin/nologin nginx
安装依赖环境
[root@yxr ~]# yum -y install pcre-devel openssl openssl-devel gd-devel
[root@yxr ~]# yum -y groups mark install 'Development Tools'
创建日志存放目录
[root@yxr ~]# mkdir -p /var/log/nginx
[root@yxr ~]# chown -R nginx.nginx /var/log/nginx
下载nginx
[root@yxr ~]# cd /usr/src/
[root@yxr src]# yum -y install wget
[root@yxr src]# wget http://nginx.org/download/nginx-1.12.0.tar.gz
[root@yxr src]# ls
debug kernels nginx-1.12.0.tar.gz
[root@yxr src]# tar xf nginx-1.12.0.tar.gz
[root@yxr src]# cd nginx-1.12.0/
[root@yxr nginx-1.12.0]# ./configure \
--prefix=/usr/local/nginx \
--user=nginx \
--group=nginx \
--with-debug \
--with-http_ssl_module \
--with-http_realip_module \
--with-http_image_filter_module \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_stub_status_module \
--http-log-path=/var/log/nginx/access.log \
--error-log-path=/var/log/nginx/error.log
[root@yxr nginx-1.12.0]# make -j $(grep 'processor' /proc/cpuinfo | wc -l) && make install
nginx安装后配置环境变量
[root@yxr nginx-1.12.0]# echo 'export PATH=/usr/local/nginx/sbin:$PATH' > /etc/profile.d/nginx.sh
[root@yxr nginx-1.12.0]# . /etc/profile.d/nginx.sh
启动nginx
[root@yxr nginx-1.12.0]# nginx
[root@yxr nginx-1.12.0]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 *:80 *:*
LISTEN 0 128 *:22 *:*
LISTEN 0 100 127.0.0.1:25 *:*
LISTEN 0 128 :::22 :::*
LISTEN 0 100 ::1:25 :::*
安装mysql
安装依赖包
[root@yxr nginx-1.12.0]# yum -y install ncurses-devel openssl-devel openssl cmake mariadb-devel
创建用户和组
[root@yxr nginx-1.12.0]# groupadd -r -g 306 mysql
[root@yxr nginx-1.12.0]