Questions & Answers

Restart Apache in Lightsail Terminal

As I found a blocker in one approach to make a Django app production ready I've gone with a different approach documented here.

In particular, this question is about this step where it says «Restart Apache for the changes to be taken into effect» and has the following associated command

sudo /opt/bitnami/ restart apache

Thing is, isn't in that folder but in /opt/bitnami/stack. Then, when running in that forder

sudo restart apache

I get this error

sudo: command not found

Lightsail restart Apache

The file is there so I thought it would be something related with permissions (as pointed here).

The script is in the right folder, so the problem points to incorrect permissions.

sudo chmod 755

but running the command to restart Apache got me into the same "command not found" error.

Lightsail can't restart Apache

2023-01-19 00:10:05
This question is really unrelated to any of the tags you have added to it. It's just a basic linux path question.
2023-01-19 00:10:05
@MarkB it relates to the other tags due to the base documentation which has particular mistakes (path wise).
2023-01-19 00:10:05
@MarkB this is a particular Django instance created in Lightsail together with Bitnami. As Bitnami shifts their folder structures, AWS's documentation gets this mistakes and it ceases from being updated. I'm not sure the same is necessarily happening with other instances.
Answers(2) :

"command not found" does not point to "incorrect permissions". You're getting errors because the script is not in your PATH. There's two ways you can go this

  1. Discover and specify the full path.
  2. Specify the current directory.

Method 1



and you will get the full path. If you get /home/bitnami/stack, then, run

sudo /home/bitnami/stack/ restart apache

Amazon Lightsail restart Apache

Method 2


sudo ./ restart apache

and that will work too

Amazon Lightsail restart Apache

2023-01-19 00:10:05
Doing that I get sudo: /opt/bitnami/stack/ command not found. As you can see in the first image, the script is in that location I'm at
2023-01-19 00:10:05
@TiagoMartinsPeres李大仁 All I can see from the screenshot is that you are in ~/stack. Is your home directory /opt/bitnami? What folder does it say you are in when you run the pwd command? How about just specifying the current directory via sudo ./ restart apache

The following worked for me (I was getting a command not found error too):

sudo /opt/bitnami/ restart apache

Taken from