nginx安装启动步骤(centos7环境)

nginx安装启动步骤(centos7环境):

1.需要安装gcc环境,编译c、c++代码 yum -y install gcc gcc-c++ autoconf automake make

2.第三方的开发包 1 PERE PCRE(Perl Compatible Regular Expressions)是一个Perl库,包括 perl 兼容的正则表达式库。 nginx的http模块使用pcre来解析正则表达式,所以需要在linux上安装pcre库。 注:pcre-devel是使用pcre开发的一个二次开发库。nginx也需要此库。 # yum install -y pcre pcre-devel

2 zlib
	zlib库提供了很多种压缩和解压缩的方式,nginx使用zlib对http包的内容进行gzip,所以需要在linux上安装zlib库。
	# yum install -y zlib zlib-devel

3 openssl
	OpenSSL 是一个强大的安全套接字层密码库,囊括主要的密码算法、常用的密钥和证书封装管理功能及SSL协议,
	并提供丰富的应用程序供测试或其它目的使用。
	nginx不仅支持http协议,还支持https(即在ssl协议上传输http),所以需要在linux安装openssl库。
	# yum -y install pcre  pcre-devel zlib  zlib-devel openssl openssl-devel

3.安装nginx 1.下载nginx最新包nginx-1.18.0.tar.gz 2.解压nginx-1.18.0.tar.gz tar -zxvf nginx-1.18.0.tar.gz 3.进入nginx-1.18.0目录 cd nginx-1.18.0 4.使用cofigure命令创建一个makeFile文件 ################################################################ ################################################################ ./configure
--prefix=/usr/local/nginx
--pid-path=/var/run/nginx/nginx.pid
--lock-path=/var/lock/nginx.lock
--error-log-path=/var/log/nginx/error.log
--http-log-path=/var/log/nginx/access.log
--with-http_gzip_static_module
--http-client-body-temp-path=/var/temp/nginx/client
--http-proxy-temp-path=/var/temp/nginx/proxy
--http-fastcgi-temp-path=/var/temp/nginx/fastcgi
--http-uwsgi-temp-path=/var/temp/nginx/uwsgi
--http-scgi-temp-path=/var/temp/nginx/scgi --with-http_stub_status_module --with-http_ssl_module --with-file-aio --with-http_realip_module ################################################################ ################################################################ 5.编译和安装nginx make && make install 6.启动nginx cd /usr/local/nginx ./sbin/nginx

	启动报错:
	nginx: [emerg] mkdir() "/var/temp/nginx/client" failed (2: No such file or directory)
	解决:
	mkdir -p /var/temp/nginx
7.查看nginx是否启动
	ps -aux | grep nginx
8.重新加载nginx
	./sbin/nginx -s reload
9.关闭nginx
	./sbin/nginx -s stop
	./sbin/nginx -s quit
10.访问nginx
	开放80端口
	firewall-cmd --add-port=80/tcp --permanent
	firewall-cmd --reload
	firewall-cmd --list-all
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章