文章目录
参考文档: https://blog.csdn.net/qq_39387856/article/details/88951699
系统环境
[root@nginx ~]# cat /etc/redhat-release
CentOS Linux release 7.0.1406 (Core)
1 安装make及编译环境
[root@nginx ~]# yum -y install gcc gcc-c++ automake autoconf libtool make
2 安装OpenSSL
[root@nginx ~]# cd /usr/local/src/
[root@nginx src]# wget https://www.openssl.org/source/openssl-1.1.1b.tar.gz # 下载包
[root@nginx src]# tar -zxvf openssl-1.1.1b.tar.gz # 解压包
[root@nginx openssl-1.1.1b]# ./Configure && make && make install #编译
3 安装PCRE库
[root@nginx src]# wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.40.tar.gz
[root@nginx src]# cd pcre-8.40/
[root@nginx pcre-8.40]# ./configure && make && make install
4 安装zlib库
[root@nginx src]# wget http://zlib.net/zlib-1.2.11.tar.gz
[root@nginx src]# cd zlib-1.2.11/
[root@nginx zlib-1.2.11]# ./configure && make && make install
5 安装Nginx
官网下载,上传并解压安装包
[root@nginx src]# cd nginx-1.8.1/
[root@nginx nginx-1.8.1]# ./configure && make && make install
6 修改监听端口
默认80端口,可能会与apache冲突
[root@nginx ~]# vim /usr/local/nginx/conf/nginx.conf
server {
listen 8899;
server_name localhost;
7 启动Nginx
7.1 查看Nginx安装路径
[root@nginx nginx-1.8.1]# whereis nginx
nginx: /usr/local/nginx
7.2 启动服务
[root@nginx ~]# cd /usr/local/nginx/sbin/
[root@nginx sbin]# ls
nginx nginx.old
[root@nginx sbin]# ./nginx
7.3 查看端口是否启用
[root@nginx sbin]# ps -ef | grep nginx
avahi 915 1 0 11:53 ? 00:00:00 avahi-daemon: running [nginx.local]
root 15032 1 0 13:10 ? 00:00:00 nginx: master process ./nginx
nobody 15033 15032 0 13:10 ? 00:00:00 nginx: worker process
root 15043 2878 0 13:10 pts/0 00:00:00 grep --color=auto nginx
[root@nginx sbin]# netstat -alntup | grep nginx
tcp 0 0 0.0.0.0:8899 0.0.0.0:* LISTEN 15032/nginx: master
8 防火墙放行端口
[root@nginx ~]# firewall-cmd --zone=public --add-port=8899/tcp --permanent
success
[root@nginx ~]# firewall-cmd --reload
success