Nginx源码安装
0.安装Nginx依赖包
yum install -y pcre-devel zlib-devel openssl-devel wget gcc tree vim
|
1.从Nginx官网下载并解压源码包
wget https://nginx.org/download/nginx-1.16.1.tar.gz tar -zxvf nginx-1.16.1.tar.gz
|
2.Nginx编译前配置
cd nginx-1.16.1 ./configure --prefix=/usr/local/nginx --with-http_ssl_module
--prefix:配置configure脚本,软件的安装位置
|
3.进行安装编译
4.检查安装情况
进入安装目录进行检查
![image-20200212154141915](/Users/at0m/Library/Application Support/typora-user-images/image-20200212154141915.png)
运行nginx
cd sbin ./nginx ps aux | grep nains netstat -pantu
|
![image-20200212154333051](/Users/at0m/Library/Application Support/typora-user-images/image-20200212154333051.png)
![image-20200212154529972](/Users/at0m/Library/Application Support/typora-user-images/image-20200212154529972.png)
5.停止Nginx
/usr/local/nginx/sbin/nginx -s stop
/usr/local/nginx/sbin/nginx -s quit
killall nginx
|
6.Nginx添加到环境变量
使用软连接将nginx
链接到/usr/local/sbin
ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin ll /usr/local/sbin/ | grep "nginx"
|
![image-20200212155159180](/Users/at0m/Library/Application Support/typora-user-images/image-20200212155159180.png)
echo $PATH
vim ~/.bashrc
export PATH=$PATH:/usr/local/nginx/sbin
source ~/.bashrc
|