nginx installation configuration
1. Check whether nginx is installed on this machine, use the following command:
#service nginx status
#which nginx
#whereis nginx
#find / -name "*nginx*"
#rpm -qa | grep nginx
2. Generally use yum to install, the command is as follows:
#yum install nginx
If successful, proceed to the next step to configure. If not successful, it may be that our nginx warehouse source address cannot be successfully linked. The solution is as follows:
Create a new file nginx.repo under /etc/yum.repos.d with the following content:
[nginx]
name=nginx repo
baseurl=http://nginx.org /packages/centos/$releasever/$basearch/
gpgcheck=0
enabled=1
Use yum to install again. The specific steps are as follows:#yum install nginx -y
yumThe default nginx installation address is :/etc/nginx
3. Configure the nginx file
a. Modify the /etc/nginx/nginx.conf file
Add content in the last line of http{} include /etc/ nginx/conf.d/demo_nginx.cnf;
b. Create a new file demo_nginx.cnf under /etc/nginx/conf.d/. The file content is as follows:
If it does not start successfully, please check the error log for analysis. Generally, there is a problem with the configuration file!# Load balancing
upstream demoApp{
server 10.10.10.40:8001;
server 10.10.10.40:8011;
}
#Set virtual host
server {
listen 80;
server_name 1 0.10.10.40;
root html;
location / {
proxy_redirect off;
’ proxy_pass http://demoApp;
}
#Dynamic requests must go through tomcat
location ~ .*.(jsp|action)$ {
proxy_set_header Host $host; proxy_set_header .(gif|jpg| jpeg|png|bmp|js|css|html)$ {
Deny all;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
access_log /var/log/ nginx/app.demo.com_access.log ;
}
4. Start nginx, the command is as follows:
#service nginx start
The error log directory is: /var/log/nginx/error.log
The above has introduced the installation and configuration of nginx, including the relevant aspects. I hope it will be helpful to friends who are interested in PHP tutorials.