Linux环境搭建
Posted 江鸟
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Linux环境搭建相关的知识,希望对你有一定的参考价值。
基础环境搭建:yum环境
一:安装wget
[[email protected] ~]# yum install -y wget
二:备份yum配置文件
[[email protected] yum.repos.d]# cd /etc/yum.repos.d/ && mv CentOS-Base.repo CentOS-Base.repo.bak
三:下载Centos-6.repo文件
[[email protected] yum.repos.d]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
[[email protected] yum.repos.d]# wget -O /etc/yum.repos.d/epel.repo
http://mirrors.aliyun.com/repo/epel-6.repo
[[email protected] yum.repos.d]#
ll
total 24
-rw-r--r--. 1 root root 2523 Jun 16 2018
CentOS-Base.repo
-rw-r--r--. 1 root root 1926 Nov 27 2013
CentOS-Base.repo.bak1
-rw-r--r--. 1 root root 638 Nov 27 2013 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root 630 Nov 27 2013 CentOS-Media.repo
-rw-r--r--. 1 root root 3664 Nov 27 2013
CentOS-Vault.repo
-rw-r--r--. 1 root root 664 May 11 2018 epel.repo
四:安装补全软件
[[email protected] yum.repos.d]# yum -y install bash-completion
[[email protected] ~]# yum makecache fast
编译安装Ngnix
1.1 检查软件安装的系统环境
[[email protected]
/]# cat /etc/redhat-release
CentOS release 6.5 (Final)
[[email protected] /]# uname -r
2.6.32-431.el6.x86_64
1.2 安装nginx的依赖包(pcre-devel
openssl-devel)(一)
yum install -y pcre-devel openssl-devel
说明:pcre-devel(支持perl nginx 定义了rewrite正则匹配语法是Perl正则语法)
openssl-devel(支持nginx服务访问,以https方式访问)
注:要统一安装路径:/home/data/tools/ 下面
1.3 创建一个虚拟用户来管理nginx进程(二)
[[email protected]
/]# useradd -M -s /sbin/nologin nginxuser
1.4 下载nginx软件(三)
[[email protected] /]# mkdir -p /home/data/tools && cd
/home/data/tools
[[email protected]
tools]# wget http://nginx.org/download/nginx-1.15.6.tar.gz
1.4.1 解压要编译安装的软件(四)
(解压软件---配置(./configure)---做菜(编译 make)---上菜(安装 make install))
[[email protected]ihong tools]# tar xf nginx-1.15.6.tar.gz [[email protected] tools]# cd nginx-1.15.6/ [[email protected] tools]# ll total 1005 drwxr-xr-x. 8 1001 1001 1024 Nov 6 21:32 nginx-1.15.6
-rw-r--r--. 1 root root 1025761 Nov 6 23:26 nginx-1.15.6.tar.gz
1.4.2 编译配置(五)
[[email protected] nginx-1.15.6]# ./configure --prefix=/application/nginx-1.15.6 --user=nginxuser --group=nginxuser --with-http_stub_status_module --with-http_ssl_module
--prefix=PATH 指定安装路径
--user=user 指定软件启动后以什么什么身份运行(属主运行)
--group=group 指定软件启动后以什么什么身份(属组)运行,前提是用户必须存在。
--with-http_stub_status_module nginx的激活状态信息
若报错./configure: error: C compiler cc is not found 则安装gcc
[[email protected] nginx-1.15.6]# yum -y install gcc
[[email protected] ~]# whereis gcc
1.4.3 编译安装(五)
[[email protected] nginx-1.15.6]# make
[[email protected] nginx-1.15.6]# make install
1.4.4 安装完成一个软件要做一个软链接(六)
[[email protected]
tools]# ln -s /application/nginx-1.15.6 /application/nginx
1.4.5 启动nginx软件程序进行测试
[[email protected]
nginx]# /application/nginx/sbin/nginx -t
nginx: the configuration file /application/nginx-1.15.6/conf/nginx.conf syntax
is ok
nginx: configuration file /application/nginx-1.15.6/conf/nginx.conf test is
successful
[[email protected]
nginx]# /application/nginx/sbin/nginx
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] still could not bind()
[[email protected] ~]# ps -e | grep nginx 查看进程是否启动
[[email protected] ~]# netstat -ltunp 查看活动端口
关闭防火墙[[email protected] nginx-1.15.6]# service iptables
stop
以上是关于Linux环境搭建的主要内容,如果未能解决你的问题,请参考以下文章