Ruby on Rails is a powerful web application framework that allows developers to create high-quality web applications quickly and efficiently. In this guide, we will walk through the steps to install Ruby on Rails with PostgreSQL on Rocky Linux 8.4.

Step 1: Update Your System

Start by ensuring your system is up to date:

sudo dnf update -y

Step 2: Install Required Dependencies

Install the necessary packages, including PostgreSQL, Git, and development tools:

sudo dnf install -y gcc gcc-c++ make \
    postgresql postgresql-server postgresql-devel \
    git

Step 3: Install Ruby

Install Ruby using the RVM (Ruby Version Manager) for managing Ruby versions:

sudo dnf install -y curl
curl -sSL https://get.rvm.io | bash -s stable

Load RVM and install Ruby:

source ~/.rvm/scripts/rvm
rvm install 3.0.0
rvm use 3.0.0 --default

Step 4: Install Rails

Now that Ruby is installed, you can install Rails:

gem install rails

Step 5: Configure PostgreSQL

Initialize and start the PostgreSQL service:

sudo postgresql-setup --initdb
sudo systemctl start postgresql
sudo systemctl enable postgresql

Next, create a new PostgreSQL user for your Rails application:

sudo -u postgres psql
CREATE USER railsuser WITH PASSWORD 'your_password';
ALTER USER railsuser CREATEDB;
\q

Replace your_password with a strong password of your choice.

Step 6: Create a New Rails Application

Create a new Rails application with PostgreSQL as the database:

rails new myapp -d postgresql

Navigate to the application directory:

cd myapp

Step 7: Configure Database Settings

Edit the config/database.yml file to set up the database connection:

nano config/database.yml

Update the configuration as follows:

development:
  adapter: postgresql
  encoding: unicode
  database: myapp_development
  pool: 5
  username: railsuser
  password: your_password

Step 8: Create the Database

Run the following command to create the database:

rails db:create

Step 9: Start the Rails Server

Start the Rails development server:

rails server -b 0.0.0.0

Step 10: Access Your Application

Open your web browser and navigate to:

http://your_server_ip:3000

Conclusion

You have successfully installed Ruby on Rails with PostgreSQL on Rocky Linux 8.4. This setup provides a solid foundation for developing web applications.

If you're looking for a reliable hosting solution for your Ruby on Rails application, consider using Windows VPS UK. With Windows VPS, you can efficiently host your applications and ensure high performance. Whether you need VPS UK Windows or Windows Virtual Private Servers, you'll find a solution that fits your requirements.

For larger deployments or enterprise needs, explore Windows Virtual Dedicated Server Hosting or Virtual Private Server Hosting Windows. Whether you're located in the UK, Italy, or elsewhere, Windows VPS Italy and UK VPS Windows offer reliable hosting options. Visit Windows VPS Hosting UK to discover the best hosting solutions for your development needs.

War diese Antwort hilfreich? 0 Benutzer fanden dies hilfreich (0 Stimmen)