Nginx development environment configuration steps:
1. View the location of the nginx configuration file: ps -ef |grep nginx
-c refers to the configuration file /etc/nginx/nginx.conf used.
2. View the configuration file: cat /etc/nginx/nginx.conf, in the last few lines
The virtual domain name configuration of nginx is placed in this. Loading ends with .conf, add your own development configuration address under include conf.d/*.conf. Such as: include test/*.conf
3. Create your own directory: cd /etc/nginx After entering this directory, mkdir yourlist creates your own development configuration directory (yourlist is conf.d)
vim www.mysite.com .conf, edit the configuration file
server { #Listening port listen 80; server_name www.mysite.com; #default homepage index index.html index.php; #Project entry directory root /home/workspace/www; #Access log main is the log format defined in nginx.conf, you can not add this main access_log /var/log/nginx/www.mysite.com.access.log main; #error log error_log /var/log/nginx/www.mysite.com.err.log error; #If it is a 404 error, jump to the set 404.html error_page 404 /404.html; #php file access processing location ~ [^/]\.php(/|$) { try_files $uri =404; fastcgi_pass unix:/var/run/php-cgi.sock; fastcgi_index index.php; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; } }
4. Create a development directory:
mkdir workplace create development directory
cd workplace to enter the directory
mkdir -p www creates multiple directories
cd www
vim index.php
<?php phpinfo(); ?>
Add executable permissions to the folder:
chmod +x /home
chmod +x /home/workplace
chmod +x /home/www
5. Monitor the nginx configuration file for abnormalities: /usr/sbin/nginx -t
As shown in the figure, ok means no problem;
6. /usr/sbin/nginx -s reload loads your latest configuration
7. Bind the host domain name
Then just access it on the browser. The content of phpinfo() comes out.