I'm getting a 404 error after install phpMyAdmin using Digital Ocean's guide. I have multiple domains setup on Ubuntu running nginx. There is a phpmyadmin directory within /var/www/. The only difference from the guide was the following command:
sudo ln -s /usr/share/phpmyadmin/ /var/www
Do I need to add server block possibly? Since I have multiple domains, each of them has a separate configuration file.
Sample config file:
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/domain1.com/html;
index index.php index.html index.htm index.nginx-debian.html;
server_name MY_IP_ADDRESS;
location / {
try_files $uri $uri/ =404;
}
location /phpmyadmin {
root /var/www/;
index index.php index.html;
}
location ~ \.php$ {
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
include fastcgi_params;
try_files $uri /index.php;
}
location ~ /\.ht {
deny all;
}
}
I'm not great at server administration. Any suggestions?
Define this server block it worked for me.
A basic configuration for phpmyadmin in you case.As you have created a symbolic link in /var/www.
sudo ln -s /usr/share/phpmyadmin/ /var/www
server {
listen 80;
server_name website.in www.website.in;
autoindex on;
location /phpmyadmin {
root /var/www/;
index index.php index.html;
location ~ \.php$ {
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
include fastcgi_params;
try_files $uri $uri/ /index.php;
}
}
location / {
root /var/www/your/path;
index index.php index.html;
location ~ \.php$ {
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
include fastcgi_params;
try_files $uri $uri/ /index.php;
}
}
}
Related
I have a react website which I am serving using NGINX. I wanted to create a blog for the same. So I tried to use wordpress in a sub-directory.
`
server {
root /var/www/html;
index index.php index.html index.htm index.nginx-debian.html;
server_name domain.com;
location / {
try_files $uri $uri/ =404;
}
location ^~ /blog {
client_max_body_size 10m;
if (!-f $request_filename) {
rewrite [^/]$ $uri/ permanent;
}
try_files $uri $uri/ /index.php?$args;
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^/wordpress(/.+\.php)(.*)$;
include fastcgi.conf;
fastcgi_index index.php;
fastcgi_pass unix:/run/php/php8.1-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
include fastcgi_params;
}
}
listen [::]:443 ssl ipv6only=on;
listen 443 ssl;
#ssl certificates here
}
`
After hours of reading docs, blogs and stack I got my homepage set up. However all my pages on the blog are returning 404. I am attaching my nginx config.
My directory structure is
/var/www/html/ : root folder for my react website
/var/www/html/blog : root folder for my wordpress ( no /wordpress subfolder present)
Add this lines
location /blog {
try_files $uri $uri/ /blog/index.php?$args;
}
location ~ \.php$ {
fastcgi_split_path_info ^(/blog
}
Please help me, I want to move the project rest api (Slim 4 use Design Pattern) from apache to nginx, but I haven't found a solution to this problem, how to convert .htaccess to nginx server configuration, the error I found is always 404 (Slim / Middleware / RoutingMiddleware.php)
thank you for your help
this server config nginx
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
index index.html index.php index.htm index.nginx-debian.html;
autoindex off;
server_name _;
location / {
try_files $uri /index.php$is_args$args;
}
location ~ \.php$ {
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_index index.php;
}
location /FjbBaseApi {
index index.php index.html index.htm;
try_files $uri $uri/ /FjbBaseApi/public/index.php;
rewrite ^/$ /public/ break;
rewrite ^(.*)$ /public/$1 break;
}
location ~ /\.ht {
deny all;
}
}
I want to install my vps to develop multiple websites at the same time.
My root directory structure:
/var/www/html/web1;
/var/www/html/web2;
/var/www/html/wordpress1;
/var/www/html/wordpress1;
/var/www/html/drupal1;
/var/www/html/drupal2;
I want to link to the website http://123.123.123.123/drupal1 and 123.123.123.123 is the IP of the VPS.
Now whenever I add a website I have to edit the config file. Is there a way to install it for every page?
Here is my nginx config:
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
index index.html index.htm index.nginx-debian.html index.php;
server_name _;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location #sub_rewrite {
rewrite ^/drupal1/(.*)$ /drupal1/index.php?$1;
}
location /drupal1/ {
try_files $uri #sub_rewrite;
}
}
Thanks everyone!
My domain registrar's DNS hits my server and gets the nginx default page, so that's properly configured
I copied an nginx vhost that is currently working, changed the server_name and the name of the conf file and nothing else.
Diff:
diff 701sm.club.conf drz400.info.conf
3c3
< server_name www.701sm.club 701sm.club;
---
> server_name www.drz400.info drz400.info;
then I restarted nginx.
Here is the entire non-functioning vhost:
server {
listen 80;
server_name www.701sm.club 701sm.club;
index index.php index.html index.htm;
access_log /var/www/drz400.info/logs/access.log;
error_log /var/www/drz400.info/logs/error.log;
location / {
root /var/www/drz400.info/production;
}
location ~ \.php$ {
root /var/www/drz400.info/production;
try_files $uri =404;
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
Both sites should hit my .../production/index.html, but only one does. What could be wrong here?
Please try the following code,
server {
listen 80;
server_name www.701sm.club 701sm.club;
index index.php index.html index.htm;
access_log /var/www/drz400.info/logs/access.log;
error_log /var/www/drz400.info/logs/error.log;
root /var/www/drz400.info/production;
location / {
try_files $uri /index.html;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
Just got curious about your log directive, you point out the log to /var/www/drz400.info/logs/error.log while your domain was www.701sm.club. If you access www.701sm.club, is there any error on your error.log ?
And what type of error was occurred ?
I'm setting up nginx with php5-fpm on Ubuntu 12.04LTS for wordpress and phpMyAdmin.
My phpMyAdmin locates in/var/www/phpMyAdmin, wordpress in /home/user/workspace/wordpress, MySQL at /var/run/mysqld/mysqld.sock
I want to map / to wordpress, /phpmyadmin to phpMyAdmin, so how can I achieve this??
Wordpress seemed OK, but when accessing /phpmyadmin, the browser "downloads" the request as files...??
This is my current nginx.conf:
server {
listen 8000;
root /home/user/workspace/wordpress;
index index.html index.htm index.php;\
location ~* /phpmyadmin { #TODO: shall here be a tailing slash??
#TODO: root or alias???
}
location ~ \..*/.*\.php$ {
return 403;
}
location / {
#TODO: show the following line be un-commented??
#try_files $uri $uri/ /index.php?q=$uri&$args;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
# NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
fastcgi_intercept_errors on;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;#TODO: could this being removed??
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
#FIXME: and how to block all access to /home/user/workspace/wordpress/server.d/*
#This doesn't work??
location /sever\.d {
autoindex on;
deny all;
}
And, what permission should I set for both the directory wordpress/ and phpMyAdmin/ if all the servers are running as www-data:www-data??
Currently I set them as 755 user:www-data, is that correct??
I haven't set up server under linux yet, I was using those servers under WinXP, so I'm trying.
in you between location add this
location /phpmyadmin {
root /usr/share/;
index index.php index.html index.htm;
location ~ ^/phpmyadmin/(.+\.php)$ {
try_files $uri =404;
root /usr/share/;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include /etc/nginx/fastcgi_params;
}
location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
root /usr/share/;
}
}
location /phpMyAdmin {
rewrite ^/* /phpmyadmin last;
}
anywhere between
also
your missing a server name. type in a server_name example.com;