CentOS 7.4 64位安装Nginx

https://www.cnblogs.com/ghzjm/p/10677599.html

CentOS 7.4 64位安装Nginx

Xshell 链接好服务器

yum install -y pcre pcre-devel

CentOS 7.4 64位安装Nginx

yum install -y zlib zlib-devel

CentOS 7.4 64位安装Nginx

yum install gcc-c++   (y)
yum install -y openssl openssl-devel

安装nginx,1.14.0

wget -c https://nginx.org/download/nginx-1.14.0.tar.gz

CentOS 7.4 64位安装Nginx

 解压并进入nginx目录

tar -zxvf nginx-1.14.0.tar.gz
cd nginx-1.14.0

使用nginx的默认配置

./configure

CentOS 7.4 64位安装Nginx

编译安装

make
make install

CentOS 7.4 64位安装Nginx

 查找安装路径:

whereis nginx

CentOS 7.4 64位安装Nginx

 CentOS 7.4 64位安装Nginx

 原

server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

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

改为

server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   /usr/local/nginx/html;
            index  index.html index.htm;
        }

进入sbin目录,可以看到有一个可执行文件nginx,直接./执行就OK了。

cd /usr/local/nginx/sbin/

CentOS 7.4 64位安装Nginx

cd nginx/
cd sbin/
./nginx

运行起来之后访问服务器ip,可以看到nginx的欢迎页面

CentOS 7.4 64位安装Nginx

ps -ef|grep nginx

CentOS 7.4 64位安装Nginx

kill -QUIT 6052
ps -ef|grep nginx

CentOS 7.4 64位安装Nginx

kill -QUIT 6068

CentOS 7.4 64位安装Nginx

 解决办法

/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

然后再

./nginx -s reload

 如果如上图有nginx的进程说明启动好了这个时候如果无法访问nginx页面可以先查看一下你服务器的安全组策略是否有启用80端口

 CentOS 7.4 64位安装Nginx

 然后再去访问    正常的域名访问就行

CentOS 7.4 64位安装Nginx

相关推荐