After stopping Apache service, why can I still get Apache default page on my IP address? - linux

I want to install Nginx, but the port 80 has been taken up by Apache2. I stop it by:
$ sudo kill -9 my-apache-pid
$ sudo service apache2 stop
$ sudo /etc/init.d/apache2 stop
[ ok ] Stopping apache2 (via systemctl): apache2.service.
and I can install Nginx. I usesudo systemctl status nginx.
It shows working well and Apache2 seems inactive. But when I enter my IP address in the browser, it still shows Apache2 hello-page. Why?

I had the same problem. To my wonder clearing history and cookies of the browser worked.

Apache and Nginx home pages located in this directory:
/var/www/html
But there is a small point, and that is that each of these two apps that were installed earlier takes up the index.html file, and when you enter the address of localhost in the browser, that file actually opens.
As a result, all you have to do is go into this directory and see what the name of Nginx home file.you must do this in your terminal:
ls -l /var/www/html
that show index.nginx-debian.html name for Nginx html file, So if you search for this address in your browser:
localhost/index.nginx-debian.html
you can see the home page of Nginx.
all you need for show Nginx home page when search localhost is change then name of those two files.

Even after you remove apache2 completely, you will still have its "default site" files sitting in /var/www/
Run the following command and refresh the page.
mv /var/www/html/index.html index.html_bkp

Related

Unable to Connect to Jenkins Server (Amazon Linux AMI)

When I had installed Jenkins on Amazon Linux AMI following steps mentioned in http://bhargavamin.com/how-to-do/install-jenkins-on-amazon-linux-aws/
After installation I was able to open Jenkins through browser but when I selected option "Install Plugins" it showed error as "Unable to connect to Jenkins Server."
So then how to troubleshoot this issue??
The problem here is pretty simple, if you do curl http://127.0.0.1:8080 on your host machine, you should get a message stating:
Authentication required
<!--
You are authenticated as: anonymous
Groups that you are in:
Permission you need to have (but didn't): hudson.model.Hudson.Administer
-->
This means that jenkins has anonymous priviledges which is not allowing any connection.
To solve this issue, you will have to do two changes:
Add Jenkins user to root group: sudo usermod -a -G root jenkins
Make Jenkins listen to all external IPs by editing file /etc/sysconfig/jenkins and changing the JENKINS_LISTEN_ADDRESS="0.0.0.0"
Once this is done, restart the jenkins server and then try to install plugins for jenkins.
I'm using this trick https://issues.jenkins-ci.org/browse/JENKINS-45388 and it works. What I did is add passwd: as prefix of file /var/lib/jenkins/secrets/initialAdminPassword and click retry button for several times and finally it works.
Updating java-1.7.0-openjdk to java-1.8.0-openjdk will do the trick and restart the jenkins service or else change the port number and try it.
I got the same error on my ubuntu VPC, here is how I solve Unable to connect to Jenkins issue.
In my VPC Nginx is installed. Nginx is listening on port 80 so you need to open the firewall to that port as well.
To open the firewall use the following command:
sudo ufw allow 80.
And run this command sudo ufw status to verify the firewall is opened for port 80
After that, you can get the default web page for Nginx by using your_public_ip:80 and Jenkins by entering your_public_ip:8080.
1.Click on retry
2.Fill admin user name, pwd ,mail, full name
3.If filled already use pwd given in initialAdminPassword folder
4.proceed

Symlink to raspberry pi webroot breaks

I have my raspberry pi setup as an internal web server. I have an external hard drive connected to the pi and mounted correctly.
I then symlink two folders from the hard drive to the web root on the pi, one is /Movies, and the other is /Series.
Initially this all works fine, as in if I hit http://192.168.1.17/Movies I get a list of all the files, I then click one and it starts playing no problem. However, after leaving it for a while and coming back, I can still get to the file directory in /Movies or /Series, but when I click a file, the web browser cannot open it.
I have no idea what's going on, it seems weird that I can still access the file directory, but playing a file doesn't work?
Any thoughts or help appreciated.
Are you using an apache server?
If so Symlinking is not a good idea.
An alternative which is more secure and may fix your problem is to install Userdir
sudo a2enmod userdir
Then you need to make a directory in home
mkdir public_html
Restart Apache
sudo service apache2 restart
If you want to change the home directory apache points to you can do so in /etc/apache2/mods-enabled/userdir.conf .Then change the <Directory /home/*/public_html> to the directory you want.
To access you're server simply enter ip_of_Rpi/~pi_username. e.g 192.168.0.100/~pi
more details here: http://ubuntuserverguide.com/2012/10/how-to-enable-and-configure-apache2-userdir-module-in-ubuntu-server-12-04.html
If you are using Apache web server, you can use mod_alias to map some directory in a URL path like this
Alias /mnt/external_disk01/movies /Movies
Alias /mnt/external_disk02/series /Series
Before use alias, make sure it is activated.
To activate:
a2enmod alias
more info in http://httpd.apache.org/docs/2.2/mod/mod_alias.html

Is there a way to dynamically change hostname to ip address mapping in linux (without having to restart)?

In a linux system, I suppose you can configure hostname to IP address mapping in /etc/hosts, but I guess if you change the mapping for a particular hostname, you would have to restart for the change to take effect.
Is there a way to dynamically (without restarting) change the mapping of a hostname to a different IP address?
In linux, administrators can specify the order of the source that an application will ask domain name information.
This file is
/etc/nsswitch.conf
and the default setting for dns is:
hosts: files dns
so yes you can add your sites in /etc/hosts and your application will follow that order. You dont need to restart and yes you can do it dynamically.
For more info type:
man nsswitch.conf
although there is a way for your application to bypass this feature. And that is when the application can "ask for dns" through a remote point or if the application havent built to use the operating system gethostbyname/gethostbyaddr system calls.
You just need to change the IP address in the /etc/hosts. Most of the time this change will propagate into the NS cache automatically. However, sometimes you just need to flush the name-server cache on your system. Depending on what you've got running the actual steps may vary. I'll list a few popular ones:
NSCD
$ sudo /etc/init.d/nscd restart
OR
$ sudo service nscd restart
OR
$ sudo systemctl restart nscd
dnsmasq
$ sudo /etc/init.d/dnsmasq restart
OR
$ sudo service dnsmasq restart
OR
$ sudo systemctl restart dnsmasq
BIND server dns cache
unrelated to OP question but in case someone ends up here
$ sudo rndc restart
OR
$ sudo rndc flushname foo.local
Where foo.local is the particular hostname you wish to r

Node.js / VPS - page doesn't show update

I've signed up with Digital Ocean to start learning Node.js; I've got it all working but when I change this:
res.end('Hello World\n');
to this:
res.end('Something else\n');
and click refresh in FF and Chrome, they both still show 'Hello World', even if I clear the history.
However, when I click [Power Cycle] on my droplet in the Digital Ocean dashboard, the changes are shown when I refresh FF & Chrome.
Any ideas why?
Do I need to configure something on the VPS?
Thanks in advance...
Think I found the problem...
I was using a batch script called deploy.bat that:
copied any js file updates using WinSCP.exe
called a restart file with plink.exe to update the server
The restart file had these two lines:
sudo /sbin/stop www
sudo /sbin/start www
So I was trying to write the updates to my Node server whilst Node was still running (using ps aux | grep node to show running processes) and when I tried to refresh my browsers, the updates weren't showing.
If I opened Putty.exe and ran sudo /sbin/stop www then made changes to my server.js file and then ran sudo /sbin/start www, the updates showed up.
tl;dr - stop server -> update file(s) -> start server

Varnish Cache log not working

varnishlog is returning:
_.vsm: No such file or directory
Has anyone else seen this before?
It looks like varnishlog is not pointing to the correct directory, or has not access to it.
Please check the command line options of varnishd. If the deamon run with -n <instancename> argument, you have to add it to varnishlog as well.
The second thing, is to see the permissions of varnish directory.
In order to see the current directory used, you must log into root and run the command below :
$ lsof -p <PID of varnishd> | grep vsm
Once revealed, you just had to be sure the full path has read permission for your user.
In Varnish 4.1 the root cause can be due to incorrect rights for reading _.vsm file. For example:
# service varnishncsa start
* Starting HTTP accelerator log deamon [fail]
Can't open log - retrying for 5 seconds
Can't open VSM file (Cannot open /var/lib/varnish/dev-me/_.vsm: Permission denied
Varnishncsa works from varnishlog user. But /var/lib/varnish/dev-me/_.vsm can be readable from varnish group or root user only:
# ls -l /var/lib/varnish/dev-me/_.vsm
-rw-r----- 1 root varnish 84934656 Apr 15 05:58 /var/lib/varnish/dev-me/_.vsm
So you can fix this problem in the following way:
# usermod -a -G varnish varnishlog
# id varnishlog
uid=110(varnishlog) gid=116(varnishlog) groups=116(varnishlog),115(varnish)
And now you can start varnishncsa.
In our case the hostname of the server was changed.
If you do not specify an instance name, varnish uses the hostname. It was looking for a directory holding the shared memory logging configuration with the new hostname, but the instance was still running from the directory with the old hostname.
Restarting varnish solved the problem.
I just had the same error message while trying to issue varnishadm commands. Turned out that I renamed my machine without stopping varnish. There was some directory in /var/varnish/ corresponding to the machine name that varnish needed access to. "sudo service varnish restart" fixed this for me.

Resources