ubuntu安装nginx详细步骤
1.安装依赖包
//⼀键安装上⾯四个依赖
不同类型的intsudo apt-get install gcc zlib zlib-devel pcre-devel openssl openssl-devel
2.下载并解压安装包
3.安装nginx
//进⼊nginx⽬录
cd /usr/local/nginx
//进⼊⽬录
cd nginx-1.13.7
//执⾏带参数命令
.
/configure --prefix=/usr/local/soft/nginx --with-http_stub_status_module --with-http_ssl_module
//执⾏make命令
sudo make
报错
linux@linux:/usr/local/nginx/nginx-1.13.7$ sudo make
make -f objs/Makefile
make[1]: 进⼊⽬录“/usr/local/nginx/nginx-1.13.7”
cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \ -o objs/src/os/unix/ngx_user.o \
src/os/unix/ngx_user.c
src/os/unix/ngx_user.c: In function ‘ngx_libc_crypt’:
src/os/unix/ngx_user.c:26:7: error: ‘struct crypt_data’ has no member named ‘current_salt’
26 | cd.current_salt[0] = ~salt[0];
| ^
make[1]: *** [objs/Makefile:781:objs/src/os/unix/ngx_user.o] 错误 1
make[1]: 离开⽬录“/usr/local/nginx/nginx-1.13.7”
make: *** [Makefile:8:build] 错误 2
//到对应⽂件
sudo vim objs/src/os/unix/ngx_user.c
//注释
/* cd.current_salt[0] = ~salt[0]; */
sudo make
报错
c语言一对一家教src/http/ngx_http_script.c: In function ‘ngx_http_script_add_copy_code’:
src/http/ngx_http_script.c:698:18: error: cast between incompatible function types from ‘size_t (*)(ngx_http_script_engine_t *)’ {aka ‘long unsigned int (*)(str uct <anonymous> *)’} to ‘void (*)(ngx_http_script_engine_t *)’ {aka ‘void (*)(struct <anonymous> *)’} [-Werror=cast-function-type]
698 | code->code = (ngx_http_script_code_pt) ngx_http_script_copy_len_code;
| ^
src/http/ngx_http_script.c: In function ‘ngx_http_script_add_var_code’:
src/http/ngx_http_script.c:787:18: error: cast between incompatible function types from ‘size_t (*)(ngx_http_script_engine_t *)’ {aka ‘long unsigned int (*)(str uct <anonymous> *)’} to ‘void (*)(ngx_http_script_engine_t *)’ {aka ‘void (*)(struct <anonymous> *)’} [-Werror=cast-function-type]
787 | code->code = (ngx_http_script_code_pt) ngx_http_script_copy_var_len_code;
| ^
hashmap的keysrc/http/ngx_http_script.c: In function ‘ngx_http_script_add_capture_code’:
src/http/ngx_http_script.c:1181:18: error: cast between incompatible function types from ‘size_t (*)(ngx_http_script_engine_t *)’ {aka ‘long unsigned int (*)(s truct <anonymous> *)’} to ‘void (*)(ngx_http_script_engine_t *)’ {aka ‘void (*)(struct <anonymous> *)’} [-Werror=cast-function-type]
1181 | code->code = (ngx_http_script_code_pt)
| ^
src/http/ngx_http_script.c: In function ‘ngx_http_script_add_full_name_code’:
src/http/ngx_http_script.c:1296:18: error: cast between incompatible function types from ‘size_t (*)(ngx_http_script_engine_t *)’ {aka ‘long unsigned int (*)(s truct <anonymous> *)’} to ‘void (*)(ngx_http_script_engine_t *)’ {aka ‘void (*)(struct <anonymous> *)’} [-Werror=cast-function-type]
1296 | code->code = (ngx_http_script_code_pt) ngx_http_script_full_name_len_code;
| ^
cc1: all warnings being treated as errors
make[1]: *** [objs/Makefile:886:objs/src/http/ngx_http_script.o] 错误 1
make[1]: 离开⽬录“/usr/local/nginx/nginx-1.13.7”
make: *** [Makefile:8:build] 错误 2
//将对应⽂件 /nginx-1.10.3/objs/Makefile 中的 -Werrori 去掉 重新make
sudo vim objs/Makefile
去掉 -Werrori
4.配置f
//打开配置⽂件
vim /usr/local/nginx/f
具体位置不同
centos和ubuntulocalhost修改为你服务器ip地址。
5.启动nginx
cd obj
./nginx
//查看nginx进程是否启动:
ps -ef | grep nginx
linux@linux:/usr/local/nginx/nginx-1.13.7/objs$ ps -ef|grep nginx
root 18366 1662 0 16:59 ? 00:00:00 nginx: master process ./nginx
nobody 18367 18366 0 16:59 ? 00:00:00 nginx: worker process
visible的所有形式linux 18369 4559 0 16:59 pts/2 00:00:00 grep --color=auto nginx
6.外部主机连接关闭虚拟机的防⽕墙
centOS6使⽤命令: systemctl stop iptables.service
centOS7使⽤命令: systemctl stop firewalld.service
Ubuntu16使⽤命令: ufw disable
随后同⼀⽹络下任意浏览器输⼊ip即可看到nginx界⾯
Welcome to nginx!
If you see this page, the nginx web server is successfully installed and working. Further configuration is required.
For online documentation and support please refer
Commercial support is available at nginx.
Thank you for using nginx.
7.访问服务器ip查看
安装完成⼀般常⽤命令
//进⼊安装⽬录中
cd /usr/local/nginx/obj
不同版本位置不同但都在安装⽬录下
//启动,关闭,重启,命令:
./nginx 启动
./nginx -s stop 关闭
c语言入门自学难吗./nginx -s reload 重启
————————————————
8.测试
将indelx.html复制到nginx 的html下查看效果
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论