###centos 7.4 安装nginx-1.10.3###
2018-01-24 09:38
267 查看
###centos 7.4 安装nginx-1.10.3###
$ yum install gcc-c++
$ yum install pcre pcre-devel
$ yum install zlib zlib-devel
$ yum install openssl openssl--devel
mkdir -p /usr/local/nginx #创建一个安装目录
cd /usr/local/nginx #切换到创建好的目录
wget http://nginx.org/download/nginx-1.10.3.tar.gz #下载安装包
tar -zxvf nginx-1.10.3.tar.gz #解压
cd nginx-1.10.3 #到解压目录下编译
./configure --prefix=/usr/local/nginx --with-pcre --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --with-http_realip_module
#在编译的时候可能遇到以下报错:
/configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option. #没有安装pcre-devel
./configure: error: SSL modules require the OpenSSL library.
You can either do not enable the modules, or install the OpenSSL library
into the system, or build the OpenSSL library statically from the source
with nginx by using --with-openssl=<path> option #没有安装openssl-devel
#针对上诉的报错情况,执行下面的安装命令,然后就可以正常编译
yum -y install pcre-devel openssl openssl-devel
make && make install #安装
安装完成之后把Nginx添加成系统服务
#! /bin/bash
PATH=/usr/local/nginx #Nginx的安装路径
chmod a+x /etc/init.d/nginx #给执行权限
chkconfig --add nginx #注册成服务
chkconfig nginx on #设置开机启动
添加成系统服务之后可以使用以下命令控制Nginx服务
systemctl start nginx.service #启动nginx服务
systemctl stop nginx.service #停止nginx服务
systemctl restart nginx.service #重启nginx服务
systemctl reload nginx.service #重新读取nginx配置(这个最常用, 不用停止nginx服务就能使修改的配置生效)
$ yum install gcc-c++
$ yum install pcre pcre-devel
$ yum install zlib zlib-devel
$ yum install openssl openssl--devel
mkdir -p /usr/local/nginx #创建一个安装目录
cd /usr/local/nginx #切换到创建好的目录
wget http://nginx.org/download/nginx-1.10.3.tar.gz #下载安装包
tar -zxvf nginx-1.10.3.tar.gz #解压
cd nginx-1.10.3 #到解压目录下编译
./configure --prefix=/usr/local/nginx --with-pcre --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --with-http_realip_module
#在编译的时候可能遇到以下报错:
/configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option. #没有安装pcre-devel
./configure: error: SSL modules require the OpenSSL library.
You can either do not enable the modules, or install the OpenSSL library
into the system, or build the OpenSSL library statically from the source
with nginx by using --with-openssl=<path> option #没有安装openssl-devel
#针对上诉的报错情况,执行下面的安装命令,然后就可以正常编译
yum -y install pcre-devel openssl openssl-devel
make && make install #安装
安装完成之后把Nginx添加成系统服务
vim /etc/init.d/nginx #在 /etc/init.d下创建一个nginx文件,并输入以下代码
#! /bin/bashchkconfig: - 85 15
PATH=/usr/local/nginx #Nginx的安装路径
DESC="nginx daemon"
NAME=nginx
DAEMON=$PATH/sbin/$NAME
CONFIGFILE=$PATH/conf/$NAME.conf
PIDFILE=$PATH/logs/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME
set -e
[ -x "$DAEMON" ] || exit 0
do_start() {
$DAEMON -c $CONFIGFILE || echo -n "nginx already running"
}
do_stop() {
$DAEMON -s stop || echo -n "nginx not running"
}
do_reload() {
$DAEMON -s reload || echo -n "nginx can't reload"
}
case "$1" in
start)
echo -n "Starting $DESC: $NAME"
do_start
echo "."
;;
stop)
echo -n "Stopping $DESC: $NAME"
do_stop
echo "."
;;
reload|graceful)
echo -n "Reloading $DESC configuration..."
do_reload
echo "."
;;
restart)
echo -n "Restarting $DESC: $NAME"
do_stop
do_start
echo "."
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|reload|restart}" >&2
exit 3
;;
esac
exit 0
chmod a+x /etc/init.d/nginx #给执行权限chkconfig --add nginx #注册成服务
chkconfig nginx on #设置开机启动
添加成系统服务之后可以使用以下命令控制Nginx服务
systemctl start nginx.service #启动nginx服务
systemctl stop nginx.service #停止nginx服务
systemctl restart nginx.service #重启nginx服务
systemctl reload nginx.service #重新读取nginx配置(这个最常用, 不用停止nginx服务就能使修改的配置生效)
相关文章推荐
- centos7.4搭建lnmp ###编译安装 nginx1.12 php7.2 ###
- [macOS] macOS下,VirtualBox安装CentOS7.4, 搭建nginx, mysql, PHP5.6&PHP7.1
- centos 7.4 yum 安装 nginx
- Centos7.4安装Nginx1.14.0
- Centos7.4安装Nginx及优化(一)
- Centos7.4 安装java开发环境(lnmt)Linux + Nginx+ MySQL+ Tomcat
- CentOS 7.4 下安装Epel源和Nginx
- centos7.4 源码安装 nginx
- CentOS 7.4 安装mysql5.6
- linux/centos安装nginx常见错误及解决办法
- CentOS 6.5 安装Nginx 1.7.4
- 三、CentOS下安装nginx、php和mysql
- CentOS7.4安装Redis4.0.7
- centos7 安装nginx
- CentOS 6.5 安装Nginx1.7.8
- CentOS7下PHP7,MySQL5.7,Nginx1.10以及对应的redis,swoole扩展的安装与配置
- CentOS下安装Nginx教程
- CentOS虚拟机的linux下安装nginx报错问题
- centos 6.5安装快速安装部署nginx-1.9.4
- centos6.5下安装lnmp环境(nginx+linux+mysql+php)[yum安装]