CentOS7安装配置Nginx服务器

nginx服务器:

(1)通过xftp工具从本地(Win10)上传到服务器(Centos7);
        本地目录下的nginx文件传到CentOS7下的/home/water/nginx/目录
        su root
        cd /home/water/nginx/
        ls

(2)解压文件
        tar -xvf nginx-1.10.3.tar.gz

(3)安装nginx
        cd /home/water/nginx/nginx-1.10.3
        ls
        // 执行命令
        ./configure
        // 执行make命令
        make
        // 执行make install命令
        make install

 (4)配置nginx.conf
        // 查看配置文件nginx.conf
        cat /usr/local/nginx/conf/nginx.conf
        // 修改配置文件nginx.conf
        vim /usr/local/nginx/conf/nginx.conf

        server {
        #监听端口
            listen       80;
        #指定网站域名
            server_name  localhost;

            #charset koi8-r;

            #access_log  logs/host.access.log  main;

            location / {
                root   html;
                index  index.html index.htm;
            }

(5)查看nginx进程是否启动:
        ps -ef | grep nginx

(6)启动nginx服务器
        // 进入目录
        cd /usr/local/nginx/sbin

        ./nginx 启动
        ./nginx -s stop 关闭
        ./nginx -s reload 重启 

 (7)再查看nginx进程是否启动:
        ps -ef | grep nginx
        
        root     10097     1  0 12:54 ?        00:00:00 nginx: master process ./nginx
        nobody   10098 10097  0 12:54 ?        00:00:00 nginx: worker process
        root     11117  9652  0 14:35 pts/1    00:00:00 grep --color=auto nginx

 (8)关闭CentOS7防火墙
        systemctl stop firewalld.service

 (9)访问服务器ip查看
        192.168.2.6
        
        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.
    成功

     
  

发布了149 篇原创文章 · 获赞 37 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/frdevolcqzyxynjds/article/details/103162803