下载地址: http://nginx.org/download/nginx-1.4.2.tar.gz 安装准备: nginx依赖于pcre库,要先安装pcre
yum install pcre pcre-devel
cd /usr/local/src/
wget http://nginx.org/download/nginx-1.4.2.tar.gz
tar zxvf nginx-1.4.2.tar.gz
cd nginx-1.4.2
./configure --prefix=/usr/local/nginx
make && make install
执行 命令
root@# yum install pcre #先安装pcre,正则表达式的库
root@# ./configure --prefix=/usr/local/nginx
root@# make && make install
root@# cp /usr/local/nginx/conf/nginx.conf.default /usr/local/conf/nginx.conf
编译PHP
./configure --prefix=/usr/local/php --enable-fpm
cp /source-path/php.ini-development /usr/local/php/lib/php.ini
启动:
cd /ulsr/local/nginx
, 看到如下4个目录
./
…conf 配置文件
… html 网页文件
…logs 日志文件
…sbin 主要二进制程序
[root@localhost nginx]# ./sbin/nginx
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
....
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] still could not bind()
不能绑定80端口,80端口已经被占用
(有时是自己装了apache,nginx等,还有更多情况是操作系统自带了apache并作为服务启动)
解决: 把占用80端口的软件或服务关闭即可.
编译安装Nginx笔记
1 下载源码包
http://nginx.org/download/nginx-1.17.3.tar.gz
下载依赖的软件包
openssl
pcre
zlib
2 解压
3 ./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-openssl=/home/szw/soft/openssl-1.0.2r --with-http_sub_module --with-http_stub_status_module --with-pcre-jit --with-pcre --with-pcre=/home/szw/soft/pcre-8.43 --with-zlib=/home/szw/soft/zlib-1.2.11 --with-http_secure_link_module --with-http_v2_module
4 make && make install
5 配置环境变量PATH