You are not logged in.

#1 2023-11-20 14:30:35

jojo06
Member
Registered: 2023-11-04
Posts: 196

[SOLVED!]Neither nginx nor httpd works

For a few days I have been dealing with a "mysqli extension" problem on httpd. I switched to nginx, I guess it was more difficult to configure. I must have missed something or done something incomplete. But I can't see it. When I try to connect to localhost I get a 403 Forbidden error and localhost/wordpress gives me a not found error.

================================================================
NGINX
================================================================

/etc/nginx/nginx.conf:

user guns users;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       mime.types;
    include		/etc/nginx/sites-enabled/*;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    server {
        listen       80 default_server;
        listen [::]:80 default_server;
	root /usr/share/nginx/html/wordpress;
        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
		#try_files $uri $uri/ /wordpress/index.php?$args;
            root   /usr/share/nginx/html/;
            index  index.html index.htm index.php;
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   /usr/share/nginx/html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ \.php$ {
        #    root           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }


    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}


    # HTTPS server
    #
    #server {
    #    listen       443 ssl;
    #    server_name  localhost;

    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;

    #    ssl_session_cache    shared:SSL:1m;
    #    ssl_session_timeout  5m;

    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers  on;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}

}

Check: my username is guns, the site sitename.com also in the /usr/share/nginx/html/sitename.com.
Check: wp-config.php mysql conf is done and right.
Check: in /usr/share/nginx/html/sitename.com all files perms to: guns users
Check: i also edit php-fpm conf to user = guns group = users & listen user/group as well.

Check: i created a folder conf.d in /etc/nginx/conf.d and created conf named sitename.conf in there:

server {
  listen 80;
  listen [::]:80;
  server_name www.sitename.com sitename.com;
  root /usr/share/nginx/sitename.com/;
  index index.php index.html index.htm;

  error_log /var/log/nginx/wordpress.error;
  access_log /var/log/nginx/wordpress.access;

  location / {
    try_files $uri $uri/ /index.php;
  }

   location ~ ^/wp-json/ {
     rewrite ^/wp-json/(.*?)$ /?rest_route=/$1 last;
   }

  location ~* /wp-sitemap.*\.xml {
    try_files $uri $uri/ /index.php$is_args$args;
  }

  error_page 404 /404.html;
  error_page 500 502 503 504 /50x.html;

  client_max_body_size 20M;

  location = /50x.html {
    root /usr/share/nginx/html;
  }

  location ~ \.php$ {
    fastcgi_pass unix:/run/php/php8.1-fpm.sock;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
    include snippets/fastcgi-php.conf;
    fastcgi_buffers 1024 4k;
    fastcgi_buffer_size 128k;
  }

  #enable gzip compression
  gzip on;
  gzip_vary on;
  gzip_min_length 1000;
  gzip_comp_level 5;
  gzip_types application/json text/css application/x-javascript application/javascript image/svg+xml;
  gzip_proxied any;

  # A long browser cache lifetime can speed up repeat visits to your page
  location ~* \.(jpg|jpeg|gif|png|webp|svg|woff|woff2|ttf|css|js|ico|xml)$ {
       access_log        off;
       log_not_found     off;
       expires           360d;
  }

  # disable access to hidden files
  location ~ /\.ht {
      access_log off;
      log_not_found off;
      deny all;
  }
}

Check: sudo chmod 640 wp-config.php < i gave the perm. I can read&write&change and all. Only wp-config.php root root.

sudo nginx -t:
duplicate default server problem:

2023/11/20 16:54:17 [emerg] 1850#1850: a duplicate default server for 0.0.0.0:80 in /etc/nginx/nginx.conf:37
nginx: configuration file /etc/nginx/nginx.conf test failed

FOR NGINX: I have this curse on me that either the conf file or the default was missing. Conf was empty etc. I reinstalled it, I found it on the internet. So I don't know if I missed even the smallest thing. Please ask anything you can think of. I reinstalled again and again, waiting for your solutions.

### I edited 3 times and solved a lot of problems but still there is problems ###

======================================
HTTPD/APACHE (much less problems)
======================================

I tried back to apache, wordpress installation doesn't work, phpinfo doesn't work. But the host is active. I can open the .txt file. I commented the user/group I added in php.ini.
/etc/httpd/conf/extra/httpd-wordpress.conf:

Alias /wordpress "/usr/share/webapps/wordpress"
<Directory "/usr/share/webapps/wordpress">
	AllowOverride All
	Options FollowSymlinks
	Require all granted
</Directory>

httpd_error log:

[Mon Nov 20 17:50:17.796597 2023] [proxy:error] [pid 9878] (13)Permission denied: AH02454: FCGI: attempt to connect to Unix domain socket /run/php-fpm/php-fpm.sock (*:80) failed
[Mon Nov 20 17:50:17.796665 2023] [proxy_fcgi:error] [pid 9878] [client 192ipadress:60652] AH01079: failed to make connection to backend: httpd-UDS, referer: http://192ipadress/

Thank you very much in advance

Last edited by jojo06 (2023-11-21 03:02:21)

Offline

#2 2023-11-21 03:02:05

jojo06
Member
Registered: 2023-11-04
Posts: 196

Re: [SOLVED!]Neither nginx nor httpd works

Oh, my God! The wrath of the Internet! It took me 3 days and I didn't see a warning about this anywhere. I was always misguided. IF ANYONE IS READING THIS NOW THAT IS FIGHTING THIS PROBLEM: The operating system is everything, friends. I didn't have www-data. They kept saying user/group or something on the internet. http should be http. AI has not found a solution so far either. Of course, when you've been trying for 3 days, there's no brain left.

Stick with Apache/httpd. If there is a problem, reinstall it. I had to deal with nginx because of mysqli and other reasons. php-fpm was not installed, I needed it. Don't look at the status, don't forget, I deleted the wrong code in php.ini. It says line 400 but it ends in 100 lines, keep in mind. The last wordpress white screen problem came. The solution is as follows:

sudo chown -R http:http /path/to/your_wordpress
sudo chmod 755 /path/to/your_wordpress

SOLVED!

Offline

Board footer

Powered by FluxBB