I am currently trying to implement a wordpress on a sub-domain using nginx.
I've installed all the dependencies (php 7.2, mariadb, mysql) and configured it all.
When I try to access to the website, here is what I got :
To be more explicit: here's what I did to configure nginx in order to use wordpress:
sudo nano /etc/nginx/conf.d/location.conf
server{
server_name subdomain.domain.fr;
root /home/domain/wordpress/;
location / {
fastcgi_pass unix:/run/php/php7.2-fpm.sock;
include fastcgi_params;
index index.php index.html index.htm;
try_files $uri $uri/ =404;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
}
}
My problem is that when I first use a wordpress website, I'm used to see some CSS on the page. When I inspect this page, I can see that the css files are included, but not used. I dont understand why. I think I have a privilege issue or anything else, but it's my first time using nginx with wordpress so I must have done something wrong:
Thanks for your help
I've found a solution that works perfectly:
adding this solved all my problems :
location ~* \.(?:css|js|map|jpe?g|gif|png)$ { }
Thanks for your help
Related
First at all I am new here and new to unix. My previous experience was solely with cPanel, Plesk etc. So please forgive me if there are some mistakes in my approach here.
I have a Centos (release 7.3.1611) VPS with Nginx (1.10.2) and PHP (7.0.17).
I followed some guides to get PHP running and followed some answers given here to similar problems as well to no avail.
Here is my configuration:
www.conf:
listen = /run/php-fpm/php-fpm.sock
listen.owner = nginx
listen.group = nginx
user = nginx
group = nginx
I changed permission and ownership on php-fpm.sock.
nginx.conf:
include /etc/nginx/default.d/*.conf;
nginx/default.d/default.conf:
index index.php index.html index.htm;
server_name _;
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
Finally I have created a info.php file. When executing it I am getting a nginx error: The page you are looking for is temporarily unavailable. Please try again later.
If disabling the nginx error page the browser is asking me if I want to download the file info.php.
Thank you for helping me out!!!
I initially encountered similar issues but fixed by making sure the path to 'include' and 'fastcgi_pass' were valid. You can verify if something is available at these paths by navigating to those directories.
# PHP 7
# cgi.fix_pathinfo=0 in php.ini
# case-sensitive regex
location ~ \.php$ {
include /usr/local/nginx/conf/fastcgi_params;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
fastcgi_index index.php;
try_files $uri $uri/ =404;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
Hope this helps.
Cheers,
Ian
I installed CodeIgniter 3 after a long time on PHP-fpm and nginx (Ubuntu). Previously I had always used CodeIgniter on Windows and configuring it on Windows and Apache it was a piece of cake.
Now I wanna install it on nginx, because I wanna use nginx-push-stream-module, which isn't possible from apache.
Now when I'm configuring it, its not working.
If I type localhost/myexample.com or localhost/myexample.com/index.php it works (myexample.com is the name of that directory)
but when I try to access
localhost/myexample.com/welcome
or
localhost/myexample.com/welcome/index
or
localhost/myexample.com/index.php/welcome
or
localhost/myexample.com/index.php/welcome/index
it doesn't work in any of the 4 cases (with or without index.php)
My root directory is /var/www/html/myexample.com
I tried all of the rewrite settings available online (including the following settings) from different blog posts etc (as I'm not used to nginx myself)
server {
server_name myexample.com;
root /var/www/html/myexample.com/;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.php;
}
location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|xml)$ {
expires 15d;
}
location ~ \.php$ {
include /etc/nginx/fastcgi_params;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/html/myexample.com/index.php;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
}
}
Edit: I also tried the method mentioned at Nginx's official website, but that's also not working.
You should modify your /etc/hosts and add this line:
127.0.0.1 myexample.com
And after that use myexample.com or myexample.com/welcome to access your CodeIgniter site
First - confirm what the server name is going to be. Set that in the your hosts file, then confirm the web root.
So in /etc/hosts add
127.0.0.1 myexample.com
Then your index.php file should be in
/var/www/html/myexample.com/
You should get CI up and working on the url
http://myexample.com
I'm building a website in Laravel 5.2 and rather than building a forum from scratch, I wish to install one such as SMF.
Laravel is currently in the root directory of my web server and I wish to keep it there as I wish to install SMF in a folder.
For example: www.example.com/smf
I'm thinking to install it in Laravel's /public folder but I'm afraid they will they conflict with each other. Is the /publicfolder the correct place to install SMF and should I use a route to point to the SMF folder?
Server: D.O droplet via Laravel Forge
You need to add custom rules for the folder(s) you want to use before Laravel related rules:
location /smf/index.php(/.*)?$ {
fastcgi_split_path_info ^(/smf/index.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_read_timeout 1000;
fastcgi_param PATH_INFO $fastcgi_path_info;
include fastcgi_params;
}
location /smf/ {
if (!-e $request_filename) {
rewrite ^.*$ /smf/index.php last;
}
try_files $uri $uri/ smf/index.php?args;
}
Please look for sample nginx config file here.
You could use Nginx to redirect www.example.com/smf to your SMF installation. To do so add this to your server block:
location /smf {
# nginx will concatenate the string above with the root value
# so your SMF files should be in "/path/to/smf/parent/dir/smf".
# Make sure that Nginx can access them.
root "/path/to/smf/parent/dir";
# change this config to suit your needs
index index.php index.html index.htm;
location ~ \.php$ {
# Here use the same config from the server block that allows you
# to execute PHP scripts
fastcgi_pass 127.0.0.1:9123;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
A couple of things I should add:
Backup the config file before editing them.
Although I've tried the code above (and it works on my machineā¢) I must say that I'm not an Nginx expert.
I'm stuck with the installation of Wordpress for Nginx on Debian. The website pointing to my server is mes-affaires.xyz.
Nginx logs are showing 200 responses for any URL from that domain, and appearing all blanks in my browser. That's the difficulty as I'm having no error log of any kind.
Any idea why it's doing this or where I could get a kind of error log?
Now www.mes-affaires.xyz shows nginx default page.
Be sure u got config for your site, and u added it in nginx.conf.
If you are using php-fpm, then you need right setting at server directive. For example:
location ~ \.php$ {
try_files $uri =404;
include fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
location ~ /\.ht {
deny all;
}
Especially line
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
must have right configuration and causes white blank page in browser when its missconfigured. Also check
$document_root
variable and ofcourse your log files.
For some reason, my nginx installation is running some .php files properly, while doesn't.
I have some files:
upload.php, sig.php, popup.php - executes and works.
asdfsda.php - doesn't work, when I visit it, the file downloads.
(SOLVED by clearing browser cache) visiting my domain - downloads my index.html file with the name "download", when I visit mydoma.in/index.html, I can see my index file properly.
I have no idea what could cause this issue.
I tried:
reinstalling PHP5-FPM
restarting the server
restarting nginx/php5-fpm services
chmod files to 777
Related nginx config part:
root /boot/www;
index index.html index.php;
server_name - my domain here -;
location / {
try_files $uri $uri/ =404;
}
location /upload.php {
include php5.conf;
}
location /asdfsda.php {
include php5.conf;
}
location /popup.php {
include php5.conf;
}
location /sig.php {
include php5.conf;
}
php5.conf:
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
This issue started today, I didn't change anything in my config files recently.
It worked fine yesterday.
I'll appreciate any help, thanks!
UPDATE: If I change the name of asdfsda.php file that doesn't execute to something else, it actually does execute. For example, I renamed it to d.php and changed the config entry from asdfsda to d and it executed.
What is wrong?
Why not use this?
location ~ ^/(upload|asdfsda|popup|sig)\.php$ {
fastcgi_index index.php;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include /etc/nginx/fastcgi_params;
}