Technically you can run both nginx and apache web server on your lubuntu, but they can't be on the same port number. This article i'm going to show you how to run both web server on lubuntu 16.04.
Nginx and apache web server not only use the same port number (port 80) as default port, but also share the same document root which is /var/www/html/. So basically in order to make them both running, we need to change the port number and document root.
The changes can be made for apache or nginx, For this tutorial i'm going to keep apache as it is and change the port number and document root for nginx. So basically here's what i'm going to do:
The changes can be made for apache or nginx, For this tutorial i'm going to keep apache as it is and change the port number and document root for nginx. So basically here's what i'm going to do:
- apache still using port 80
- apache document root still in /var/www/html/
- nginx will be using port 8181
- nginx document root will be in /var/www/nginx/
So no change will be made for apache web server, but we are going to change nginx web server. Note that this tutorial assume you already install both apache web server and nginx web server.
Step by step how to change port number and document root Nginx
create new directory called 'nginx'
copy index.nginx-debian.html from /var/www/html/ to /var/www/nginx/
go to /etc/nginx/sites-enabled directory
open the config file using text editor (leafpad for example)
find this line code
change it into like this
save and exit
restart nginx
Step by step how to change port number and document root Nginx
- open command line on lubuntu (press CTRL + ALT + T)
- go to /var/www/ directory
cd /var/www/
sudo mkdir nginx
sudo cp /var/www/html/index.nginx-debian.html /var/www/nginx/
cd /etc/nginx/sites-enabled/
sudo leafpad default
# Default server configuration
#
server {
listen 80 default_server;
listen [::]:80 default_server;
...
root /var/www/html;
# Default server configuration
#
server {
listen 8181 default_server;
listen [::]:8181 default_server;
...
root /var/www/nginx;
sudo service nginx restart
You can open apache web server as usual on http://localhost/ and nginx on http://localhost:8181/.
No comments:
Post a Comment