I'm thinking about writing a Rails application to manage servers like cPanel.
The hardest part is to select the best way to run commands that require root privileges, like adduser
, or doing things that require another user's privileges, like changing nginx config files.
I know only two ways to achieve this:
Which of these ways are best? Does there exist another way to to this?
2.1 bin/rails serverGo to your browser and open http://localhost:3000, you will see a basic Rails app running. You can also use the alias "s" to start the server: bin/rails s . The server can be run on a different port using the -p option. The default development environment can be changed using -e .
To generate a controller and optionally its actions, do the following: Press Ctrl twice and start typing rails g controller. Select rails g controller and press Enter . In the invoked Add New Controller dialog, specify the controller name.
To undo a rails generate command, run a rails destroy command. You can then edit the file and run rake db:migrate again. (See how to roll back a Migration file to rollback a specific migration or multiple migrations.)
sudo -i
I tried doing things like sudo bundle exec rails console
but it wouldn't quite run it as root so when I tried to create a directory from the console it let me know that I did not have the correct permissions.
However, using sudo -i
it enters you into an "interactive console" as the sudo root user and then you can run bundle exec rails console
as the sudo root user.
Hopes that helps others.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With