Centos 6.4 系统下安装nginx及简单配置

系统配置及安装:
LInux系统:Centos 6.4
nginx 版本 1.14 ( 官网目前最新)
使用wget直接下载最新的源码自己编译。
wget http://nginx.org/download/nginx-1.14.0.tar.gz
需要root权限进行安装
./configure
make && make install

安装完毕后,程序及配置文件会保存到/usr/local/nginx目录下。
运行及配置
修改服务器的端口及ip


server {
listen 1122; #修改端口
server_name 192.168.1.12;#修改IP
[root@localhost nginx]./sbin/nginx

IE中输入 http://192.168.1.12:1122/ 就可以访问了。

常见命令

[root@localhost sbin]# ./nginx -t  #测试配置文件
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
[root@localhost sbin]# ./nginx # 启动
[root@localhost sbin]# ps -ef | grep nginx
root     13006     1  0 19:29 ?        00:00:00 nginx: master process ./nginx
nobody   13007 13006  0 19:29 ?        00:00:00 nginx: worker process
root     13009  5632  0 19:29 pts/2    00:00:00 grep nginx
[root@localhost sbin]# ./nginx -s stop # 停止启动
[root@localhost sbin]# ps -ef | grep nginx
root     13012  5632  0 19:29 pts/2    00:00:00 grep nginx
[root@localhost sbin]# ./nginx -v #显示版本
nginx version: nginx/1.14.0
[root@localhost sbin]# ./nginx -c /usr/local/nginx/conf/nginx.conf
#指定配置文件启动nginx,必须是绝对路径

猜你喜欢

转载自blog.csdn.net/jsh13417/article/details/80639549