• 周六. 10 月 5th, 2024

5G编程聚合网

5G时代下一个聚合的编程学习网

热门标签

[nginx] install nginx on Linux, open ports and deploy static web pages

King Wang

1 月 3, 2022

Installation environment

 install gcc, There are hints , Choose all y
[root@james nginx]#yum install gcc-c++
 install Nginx Depend on the environment ,-y Indicates the default selection of all prompts y
[root@james nginx]#yum -y install pcre pcre-devel 
[root@james nginx]#yum -y install zlib zlib-devel 
[root@james nginx]#yum -y install openssl openssl-devel

install nginx Running environment

[root@james ~]# mkdir /usr/local/nginx
[root@james ~]# tar -zxvf nginx-1.13.9.tar.gz -C /usr/local/nginx
 Compile and install
[root@james nginx]# cd nginx-1.13.9/
[root@james nginx]#./configure
// If there is error, Execute it again [root@james nginx]#yum -y install pcre pcre-devel 
[root@james ~]# make
[root@james ~]# make install

Open the firewall 80 port

[root@james nginx]# vim /etc/sysconfig/iptables

Insert
-I INPUT -p tcp --dport 80 -j ACCEPT
Reload firewall profile

[root@james nginx]# service iptables reload

Observe index The root of the file directory

[root@james nginx]# vim /usr/local/nginx/conf/nginx.conf
 server {

listen 80; // monitor 80 port
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {

root /ly; // Project and path , Change to your own project path (Linux)
index index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {

root html;
}

The idea of deploying static web pages

  1. Upload your own project PS ftp Upload in a compressed package , Re decompress , Remember the decompression path

  2. modify nginx Configuration of , Configure the extraction path

 location / {

root /ly; // Project and path , Change to your own project path (Linux)
index index.html index.htm;
}

restart nginx

[root@james ~]# cd /usr/local/nginx/
[root@james nginx]# ls
client_body_temp fastcgi_temp logs proxy_temp scgi_temp
conf html nginx-1.13.9 sbin uwsgi_temp
[root@james nginx]# cd sbin
stop it Nginx
[root@james sbin]# ./nginx -s stop
Exhortation Nginx
[root@james sbin]# ./nginx

[ . and ./ The difference is reproduced in ]:https://blog.csdn.net/u014471752/article/details/84565908
linux In the shell Use in ” . ” and ” ./ ” The difference in execution
At present, the difference is mainly in the scope of environment variables :

  1. If you use ” ./ ” perform , It can be understood that the program runs in a new shell in , Do not inherit the present shell The value of the environment variable , At the same time, if the program changes the current shell Environment variables in ( Don’t use export), Is the current shell The value of the environment variable does not change .

  2. If you use ” . ” perform , Then the program inherits the current shell Environment variables in , meanwhile , If the current is changed in the program shell Environment variables in ( Don’t use export), Is the current shell The value of this environment variable will also change

Another difference is , “ ./ ” It can only be used for files with execution permission , and ” . ” You can temporarily improve

发表回复