Nginx入门使用
安装Nginx(一)
安装依赖
nginx依赖
pcre-devel、openssl-devel、zlib-devel
yum install -y pcre pcre-devel openssl openssl-devel zlib zlib-devel
yum -y install patch
安装命令
yum install -y nginx
等待安装
等待安装后执行
yum install -y nginx
查询进程
ps -ef | grep nginx
启动
nginx
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
nginx -c /usr/local/nginx/conf/nginx.conf
安装Nginx(二)
1、更新yum
yum update -y
2、安装epel-release源
yum install -y epel-release
等待
3、安装nginx依赖
[root@rzk opt]# tar -zxf openssl-1.0.1t.tar.gz
[root@rzk opt]# tar -zxf pcre-8.40.tar.gz
[root@rzk opt]# cd pcre-8.40
[root@rzk pcre-8.40]# ./configure
[root@rzk pcre-8.40]# make
[root@rzk pcre-8.40]# make install
[root@rzk opt]# tar -zxf zlib-1.2.11.tar.gz
[root@rzk opt]# cd zlib-1.2.11
[root@rzk zlib-1.2.11]# ./configure
[root@rzk zlib-1.2.11]# make
[root@rzk zlib-1.2.11]# make install
4、安装nginx
5、解压
tar -zxvf nginx-1.16.1.tar.gz
6、进入
cd nginx-1.16.1
7、编译
编译一(推荐)
如果安装两个Nginx,这里可以指定要安装的目录,启动也是在你安装的目录下启动
mkdir /usr/local/pcre-8.38
mkdir /usr/local/zlib-1.2.11
mkdir /usr/local/openssl-1.0.1t
[root@rzk nginx-1.16.1]# ./configure \
--prefix=/opt/Nginx/nginx/ \
--sbin-path=/opt/Nginx/nginx/nginx \
--conf-path=/opt/Nginx/nginx/nginx.conf \
--pid-path=/opt/Nginx/nginx/nginx.pid \
--with-http_ssl_module \
--with-pcre=/opt/Nginx/pcre-8.38 \
--with-zlib=/opt/Nginx/zlib-1.2.11 \
--with-openssl=/opt/Nginx/openssl-1.0.1t
[root@rzk nginx-1.16.1]# make
[root@rzk nginx-1.16.1]# make install
[root@rzk nginx-1.16.1]# /opt/nginx-1.16.1/nginx
[root@rzk nginx-1.16.1]# ps -ef | grep nginx
root 30847 1 0 10:46 ? 00:00:00 nginx: master process /opt/nginx-1.16.1/nginx
nobody 30848 30847 0 10:46 ? 00:00:00 nginx: worker process
root 30855 1245 0 10:46 pts/0 00:00:00 grep --color=auto nginx
https://blog.csdn.net/qq_44877496/article/details/107165255
编译二
下面默认安装指定usr/local/nginx 目录下
./configure
make
make install
这一步如果报错
make: *** No rule to make target build', needed by
default'. Stop.
8、解决办法
yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5-devel libidn libidn-devel openssl openssl-devel nss_ldap openldap openldap-devel openldap-clients openldap-servers libxslt-devel libevent-devel ntp libtool-ltdl bison libtool vim-enhanced
9、阿里云开启安全组
开启80端口 访问
Nginx的基本使用
关于要启动nginx,先运行可执行文件。一旦启动nginx,就可以通过使用-s参数调用可执行文件来对其进行控制。使用以下语法:
nginx -s 信号
看看端口分配情况:netstat -ntlp
- stop —快速关机
- quit —正常关机
- reload —重新加载配置文件 可快速对配置文件进行修改
- reopen —重新打开日志文件