Install Config Wiki

All about installing, configuring and troubleshooting

User Tools

Site Tools


install_nqinx_webserver_linux_ubuntu_server_20_04_lts

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
install_nqinx_webserver_linux_ubuntu_server_20_04_lts [2020/06/10 03:03] – [Change Apache2 Default Port to Custom Port on Ubuntu / Debian] wikiadmininstall_nqinx_webserver_linux_ubuntu_server_20_04_lts [2020/06/10 04:42] (current) – [Configure PhpMyAdmin within Nginx Server default sites-available virtual host file] wikiadmin
Line 1: Line 1:
-====== Install Nginx Webserver on Linux Ubuntu Server 20.04 LTS ======+====== Install Nginx Webserver on Linux Ubuntu Server 20.04 LTS (Changing from Apache2 already installed) ======
  
-<code>$ sudo apt update +It would be necessary to switch from Apache to Nginx if, for example, you want to install NextCloud and OnlyOffice Document Server on the same Ubuntu server and integrate them to work together in order to provide document creation, editing, collaboration, and cloud storage. A prerequisite for OnlyOffice Document Server is that it must run on Nginx webserver.  NextCloud can run on either Apache or Nginx, but Nginx is the common denominator to run both NextCloud and Only/Office Document Server on the same box.
-$ sudo apt upgrade </code>+
  
-Stop apache2 if that webserver is also installed and running.+<code>sudo apt update 
 +sudo apt upgrade </code> 
 + 
 +Stop apache2 if that webserver is also installed and running. It may also be necessary to change the http Port bind to Apache2 before starting Nginx after it is installed.
  
 <code>sudo systemctl stop apache2.service</code> <code>sudo systemctl stop apache2.service</code>
 +
 +See below if you need to change http port 80 that is bind to Apache2.
  
 ===== Installing Nginx Server ===== ===== Installing Nginx Server =====
  
-<code>sudo apt install nginx</code>+<code>sudo apt install nginx</code>
  
 After the installation is completed, start the Nginx service and enable it to launch every time at system boot.  Check the status of Nginx. After the installation is completed, start the Nginx service and enable it to launch every time at system boot.  Check the status of Nginx.
Line 67: Line 71:
 Save and close the file. Save and close the file.
  
-If the ports.conf file also has the following, change ssl port 443 to port 444 or something else.+If the ports.conf file also has the following, may need to change ssl port 443 to port 444 or something else.
  
 <code> <code>
Line 105: Line 109:
 <code>tcp6           0:::880         :::   LISTEN      4066/apache2 </code> <code>tcp6           0:::880         :::   LISTEN      4066/apache2 </code>
  
 +==== Return (above) to Start Nginx, Enable it to start at start-up, and check its status ====
 +
 +<code>
 +sudo systemctl start nginx
 +
 +sudo systemctl enable nginx
 +
 +sudo systemctl status nginx
 +</code>
 +
 +===== Open the UFW firewall for Nginx port 80 and 443 =====
 +
 +If you have enabled the uncomplicated firewall (ufw) on Ubuntu, then you will need to type the following ufw command to open TCP port number 80 and 443 for everyone.  If the firewall is not enabled because you are behind a NAT router (or whatever reason), then skip these steps to open ports in the firewall.
 +
 +<code>
 +sudo ufw allow 80/tcp comment 'accept HTTP Nginx'
 +
 +sudo ufw allow 443/tcp comment 'accept HTTPS/TLS Nginx connections'
 +</code>
 +
 +Verify port status it:
 +
 +<code>sudo ufw status</code>
 +
 +===== Configure Nginx to Use the PHP Processor =====
 +
 +===== Configure PhpMyAdmin within Nginx Server default sites-available virtual host file =====
 +
 +Now go to the '/etc/nginx' configuration directory, and edit the default virtual host file.
 +
 +<code>
 +cd /etc/nginx/sites-available/
 +
 +sudo cp default default-original 
 +
 +sudo vim default
 +</code>
 +
 +Paste the following Nginx configuration for PHPMyAdmin inside the 'server {...}' bracket.
 +
 +<code>
 +location /phpmyadmin {
 +    root /usr/share/;
 +    index index.php;
 +    try_files $uri $uri/ =404;
 +
 +location ~ ^/phpmyadmin/(doc|sql|setup)/ {
 +    deny all;
 +    }
 +
 +location ~ /phpmyadmin/(.+\.php)$ {
 +    fastcgi_pass unix:/run/php/php7.4-fpm.sock;
 +    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
 +    include fastcgi_params;
 +    include snippets/fastcgi-php.conf;
 +    }
 +}
 +</code>
 +
 +Save and exit.
 +
 +Test the nginx configuration and make sure there is no error, then restart the nginx service.
 +
 +<code>
 +sudo nginx -t
 +
 +sudo systemctl reload nginx
 +</code>
 +
 +And we've added the Nginx configuration for our phpMyAdmin installation, it's accessible through the path URL as 'http://server-ip/phpmyadmin'.
  
  
  
  
install_nqinx_webserver_linux_ubuntu_server_20_04_lts.1591758228.txt.gz · Last modified: 2020/06/10 03:03 by wikiadmin