Como alterar porta do apache e do nginx

Como alterar porta do apache e do nginx???

Você pode encontrar essas informações na documentação dos dois produtos.

Achei esses dois scripts mais simples

Alterei mais ao tentar reiniciar o nginx não reinicia

Quando tento reiniciar o nginx da o seguinte erro:
root@vicediretora-Positivo-Master-D3200:/home/vicediretora# systemctl status nginx.service
× nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset:>
Active: failed (Result: exit-code) since Thu 2023-12-07 12:18:45 -03; 26s >
Docs: man:nginx(8)
Process: 50062 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_proc>
Process: 50063 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (>
CPU: 70ms

dez 07 12:18:43 vicediretora-Positivo-Master-D3200 systemd[1]: Starting A high >
dez 07 12:18:43 vicediretora-Positivo-Master-D3200 nginx[50063]: nginx: [emerg]>
dez 07 12:18:43 vicediretora-Positivo-Master-D3200 nginx[50063]: nginx: [emerg]>
dez 07 12:18:44 vicediretora-Positivo-Master-D3200 nginx[50063]: nginx: [emerg]>
dez 07 12:18:44 vicediretora-Positivo-Master-D3200 nginx[50063]: nginx: [emerg]>
dez 07 12:18:45 vicediretora-Positivo-Master-D3200 nginx[50063]: nginx: [emerg]>
dez 07 12:18:45 vicediretora-Positivo-Master-D3200 nginx[50063]: nginx: [emerg]>
dez 07 12:18:45 vicediretora-Positivo-Master-D3200 systemd[1]: nginx.service: C>
dez 07 12:18:45 vicediretora-Positivo-Master-D3200 systemd[1]: nginx.service: F>
dez 07 12:18:45 vicediretora-Positivo-Master-D3200 systemd[1]: Failed to start >
lines 1-18/18 (END)

Será que meu script está errado???

You should look at the following URL’s in order to grasp a solid understanding

of Nginx configuration files in order to fully unleash the power of Nginx.

Getting Started | NGINX

Pitfalls and Common Mistakes | NGINX

Nginx/DirectoryStructure - Debian Wiki

In most cases, administrators will remove this file from sites-enabled/ and

leave it as reference inside of sites-available where it will continue to be

updated by the nginx packaging team.

This file will automatically load configuration files provided by other

applications, such as Drupal or Wordpress. These applications will be made

available underneath a path with that package name, such as /drupal8.

Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.

Default server configuration

server {

listen 8082 default_server;

listen [::]:8082 default_server;

SSL configuration

listen 443 ssl default_server;

listen [::]:443 ssl default_server;

Note: You should disable gzip for SSL traffic.

See: https://bugs.debian.org/773332

Read up on ssl_ciphers to ensure a secure configuration.

See: https://bugs.debian.org/765782

Self signed certs generated by the ssl-cert package

Don’t use them in a production server!

include snippets/snakeoil.conf;

root /var/www/html;

Add index.php to the list if you are using PHP

index index.html index.htm index.nginx-debian.html;

server_name _;

location / {

First attempt to serve request as file, then

as directory, then fall back to displaying a 404.

try_files $uri $uri/ =404;

}

pass PHP scripts to FastCGI server

#location ~ .php$ {

include snippets/fastcgi-php.conf;

# With php-fpm (or other unix sockets):

fastcgi_pass unix:/run/php/php7.4-fpm.sock;

# With php-cgi (or other tcp sockets):

fastcgi_pass 127.0.0.1:9000;

#}

deny access to .htaccess files, if Apache’s document root

concurs with nginx’s one

#location ~ /.ht {

deny all;

#}

}

Virtual Host configuration for example.com

You can move that to a different file under sites-available/ and symlink that

to sites-enabled/ to enable it.

#server {

listen 8082;

listen [::]:8082;

server_name example.com;

root /var/www/example.com;

index index.html;

location / {

try_files $uri $uri/ =404;

}

Ficou difícil de entender o código do seu Nginx, consegue estruturar melhor?

root@vicediretora-Positivo-Master-D3200:/home/vicediretora# systemctl status nginx.service
× nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset:>
Active: failed (Result: exit-code) since Thu 2023-12-07 12:18:45 -03; 26s >
Docs: man:nginx(8)
Process: 50062 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_proc>
Process: 50063 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (>
CPU: 70ms

dez 07 12:18:43 vicediretora-Positivo-Master-D3200 systemd[1]: Starting A high >
dez 07 12:18:43 vicediretora-Positivo-Master-D3200 nginx[50063]: nginx: [emerg]>
dez 07 12:18:43 vicediretora-Positivo-Master-D3200 nginx[50063]: nginx: [emerg]>
dez 07 12:18:44 vicediretora-Positivo-Master-D3200 nginx[50063]: nginx: [emerg]>
dez 07 12:18:44 vicediretora-Positivo-Master-D3200 nginx[50063]: nginx: [emerg]>
dez 07 12:18:45 vicediretora-Positivo-Master-D3200 nginx[50063]: nginx: [emerg]>
dez 07 12:18:45 vicediretora-Positivo-Master-D3200 nginx[50063]: nginx: [emerg]>
dez 07 12:18:45 vicediretora-Positivo-Master-D3200 systemd[1]: nginx.service: C>
dez 07 12:18:45 vicediretora-Positivo-Master-D3200 systemd[1]: nginx.service: F>
dez 07 12:18:45 vicediretora-Positivo-Master-D3200 systemd[1]: Failed to start >
lines 1-18/18 (END)

Quando tento ver o status do nginx da erro. E não da start, nem restart e nem reload. O nginx da como failed. Eu alterei a porta do nginx para 8082. Pois quando digito o localhost so aparece apache2

Esse tipo de erro foge um pouco da solução, seria interessante seguir um passo a passo do zero ou pedir ajuda a alguém que já tenha passado por esta situação.