I found many links regarding this type of topic , so far i still could not solve my problem. I have just installed nginx via homebrew. Here are the steps that i did :
Added site name to etc/hosts
127.0.0.1 mysite.com
On my usr/local/etc/nginx, i created folder using
mkdir sites
(most instructions i have read so far already have sites-enabled or sites-default on thier setup, but mine was clean so i created one.) Then within the folder i created file just using vim :
vim mysite
then in the file i have this :
server { listen 80; server_name mysite.com; root /Users/myname/mysite/mainsite; client_max_body_size 10M; # serve static files location ~ ^/(images|javascript|js|css|flash|media|static)/ { expires 30d; } location / { index index.php index.html index.htm; try_files $uri $uri/ /index.php$is_args$args; } error_page 500 502 503 504 /50x.html; location = /50x.html { root /opt/local/share/nginx/html; } location ~ \\\\.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param FF_BOOTSTRAP_ENVIRONMENT dev; fastcgi_param FF_BOOTSTRAP_CONFIG webroot/dev; fastcgi_buffer_size 1024k; fastcgi_buffers 1024 1024k; fastcgi_busy_buffers_size 1024k; include /usr/local/etc/nginx/fastcgi.conf; } }
After this i include my created folder to nginx.conf and nginx.cnf.default but after this i still get a 404 error. The above configuration on mysite file, except for some directory changes, worked on my other computer but some how i cant replicate for it to work, I tried revising and editing my directory in root but i still get 404. Did I miss some important stuff when configuring? Or what are the other possible reasons why i cannot access mysite.com after the above configuration or how i would get 404. Also i think no other background applications are currently running because i have just restarted the computer to see it the site doesnt work.. Any more suggestions why this might be happening? Thanks in advance
404 :(
First of all you mentioned the missing sites-enabled part, probably cause you're using centos or some other distro, I've explained this part on my answer on another question
Your site isn't working because nginx can't see the config file, simply creating a folder in anywhere doesn't work, you need to tell nginx to look into you config file, if you're configuration is in usr/local/etc/nginx
like you said, then you need to move this config file mysite
to usr/local/etc/nginx/conf.d
at least,
or create the sites-available
, sites-enabled
pair like I explained in my other answer and move mysite
to sites-available
then symlink to it inside sites-enabled
Of course make sure you point things to the right path since your nginx lives inside usr/local/etc/nginx
instead of /etc/nginx
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.