启动 nginx -c /etc/nginx/nginx.conf
停止 nginx -s stop
一、安装nginx
1、在nginx官方网站下载一个包,下载地址是:http://nginx.org/en/download.html
2、WinSCP(ftp上传工具).exe FTP 上传工具上传达到CentOS中
3、我是先建一个目录,把要用的到的安装包放到一起.
#mkdir /home/
#tar zxf nginx-1.4.1.tar.gz
#cd nginx-1.4.1
4、安装pcre开发包
#yum install -y pcre-devel
5、如果安装出现在下面的错误是缺少编译环境。安装编译源码所需的工具和库
./configure: error: C compiler cc is not found
#yum install gcc gcc-c++ ncurses-devel perl
6、安装cmake,从http://www.cmake.org下载源码并编译安装
#yum -y install make gcc gcc-c++ ncurses-devel
#yum -y install zlib zlib-devel
7、如果需要ssl功能需要openssl库
#yum -y install openssl openssl--devel
8、安装nginx
#cd nginx-1.4.1
#./configure --prefix=/etc/nginx/nginx.conf
#make && make install
9、启动服务
#/etc/nginx/sbin/nginx -c /etc/nginx/conf/nginx.conf
10、停止服务
#/etc/nginx/sbin/nginx -s stop
11、查看端口占用情况
#netstat -tunlp
12、如果其它机器无法访问,解决方法如下:
#/sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT
然后保存:
#/etc/rc.d/init.d/iptables save
重启防火墙
#/etc/init.d/iptables restart
[root@server ~]# yum install nginx
[root@server ~]# service nginx start
Starting nginx: [ OK ]
4,然后进入浏览器,输入http://192.168.0.161/测试,如果看到
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 to nginx.org.
Commercial support is available at nginx.com.
Thank you for using nginx.
恭喜你,你成功了!
如果不能连接到nginx,原因很多,但是可以先检查 1,nginx服务是否真的起来了;2,linux服务器防火墙是否打开
重启
service iptables restart
linux安装nginx
最新推荐文章于 2022-10-26 15:25:48 发布