Nginx in Ubuntu performs frontend calling of Apache for PHP dynamic request processing
Source: Internet
Author: User
1. create the site directory mkdir-p/srv/www/logs .... 1. create a site directory
Mkdir-p/srv/www/wangjiang.net/{logs,public_html}
2. install Nginx and enable it to listen on port 80;
Sudo apt-get install nginx
3. create a site configuration file under Nginx and try to let Nginx load any requested files or directories.
Apache processes requests for PHP files.
Nginx occupies port 80, filters static requests, and then dynamically requests the Proxy to port 8080 of Apache. The advantage of Proxy reverse Proxy is that port 80 is always used during access, and visitors will not notice any difference.
Sudo vi/etc/nginx/sites-available/wangjiang.net
Server {
Listen 80;
Access_log/srv/www/wangjiang.net/logs/nginx.access.log;
Error_log/srv/www/wangjiang.net/logs/nginx.error.log;
Root/srv/www/wangjiang.net/public_html;
Index. php index.html;
Server_name wangjiang.net;
Location \{
Try_files $ uri/index. php/$ uri;
}
Location ~ * ^. * \. Php $ {
If (! -F $ request_filename ){
Return 404;
}
Proxy_set_header X-Real-IP $ remote_addr;
Proxy_set_header X-Forwarded-For $ proxy_add_x_forwarded_for;
Proxy_set_header Host $ host;
Proxy_pass http: // 127.0.0.1: 8080;
}
Location ~ /\. (Ht | git ){
Deny all;
}
}
Sudo ln-s/etc/nginx/sites-available/wangjiang.net/etc/nginx/sites-enabled/wangjiang.net
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service