チュートリアル8:Linux(centos7.7)にnginxをインストールする

Centos7.7インストールnginx1.8チュートリアル

1.プラグインをインストールします。

查看gcc:gcc -v
    [root@yu /]# gcc -v
    -bash: gcc: command not found
    [root@yu /]#
yum -y install gcc
yum install -y pcre pcre-devel
yum install -y zlib zlib-devel
yum install -y openssl openssl-devel
------------------------------------------
[root@yu /]# gcc -v
.........
Thread model: posix
gcc version 4.8.5 20150623 (Red Hat 4.8.5-39)

2.nginxをダウンロードしてインストールします

インストール方法:http://nginx.org/en/download.html
(1.公式サイトへのリンク:URLを開始するには、以下の第二のステップに進んで、tar.gzファイルをダウンロードのLinuxにアップロードします。

(2.wgetを直接ダウンロードしてインストール:次のように

1.nginxインストールパッケージをダウンロードします

安定版:

wget http://nginx.org/download/nginx-1.18.0.tar.gz  

2.解凍します

# tar -zxvf   源文件  -C  目标路劲
tar -zxvf  nginx-1.18.0.tar.gz -C /opt/

3. nginx-1.18.0 /に切り替えます:コンパイルしてインストールします

1、yum -y install pcre-devel openssl openssl-devel
2、./configure --prefix=/usr/local/nginx118
3、make
4、make install

5. / usr / local / nginxインストールディレクトリに切り替えます

[root@yu nginx-1.18.0]# cd /usr/local/nginx/
[root@yu nginx]# ll
total 4
drwxr-xr-x. 2 root root 4096 Mar  3 19:26 conf
drwxr-xr-x. 2 root root   40 Mar  3 19:26 html
drwxr-xr-x. 2 root root    6 Mar  3 19:26 logs
drwxr-xr-x. 2 root root   19 Mar  3 19:26 sbin
[root@yu nginx]# pwd
/usr/local/nginx

6.ポートを確認します

[root@yu nginx]# pwd
/usr/local/nginx
[root@yu nginx]# cat conf/nginx.conf
---------------------------------
#keepalive_timeout  0;
    keepalive_timeout  65;
    #gzip  on;
    server {
    
    
        listen       80;
        server_name  localhost;
        #charset koi8-r;
        #access_log  logs/host.access.log  main;
        location / {
    
    
            root   html;
            index  index.html index.htm;
        }

7.nginxサービスを開始します

参考資料:[Ahaoが乾物について話します] https://www.cnblogs.com/hafiz/p/6891458.html
nginxコマンドを開始します

[root@yu /]# cd /usr/local/nginx/sbin
[root@yu nginx]# cd sbin/
[root@yu sbin]# ll
total 3240
-rwxr-xr-x. 1 root root 3313712 Mar  3 19:26 nginx
[root@yu sbin]# ./nginx

やめる:

1).暴利kill(不推荐使用)
  kill -9 processId
2).快速停止
  cd /usr/local/nginx/sbin && ./nginx -s stop
  此方式相当于先查出nginx进程id再使用kill命令强制杀掉进程
3).完整停止(建议使用)
  cd /usr/local/nginx/sbin && ./nginx -s quit
  此方式停止步骤是待nginx进程处理任务完毕进行停止

再起動:

1.先停止再启动
  ./nginx -s quit && ./nginx
2.重新加载配置文件
  ./nginx -s reload

8.nginxサービスを表示する

[root@yu sbin]# ps -ef | grep nginx
root       4037      1  0 19:28 ?        00:00:00 nginx: master process ./nginx
nobody     4038   4037  0 19:28 ?        00:00:00 nginx: worker process
root       4040   1623  0 19:29 pts/0    00:00:00 grep --color=auto nginx

9.風側でのテスト:IPマッピングが風側で構成されていることが前提です

http:// localhost:80

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.

おすすめ

転載: blog.csdn.net/qq_42476834/article/details/106033364