Linux command
rails-server 命令
文件
复制后可按需替换文件名、目录或参数。
常用示例
Start the Rails development server
rails server
Start the server on a specific port
rails server -p [port]
Start the server binding to all interfaces
rails server -b 0.0.0.0
Start the server in production environment
rails server -e production
Start using a specific server
rails server -u [puma|thin|webrick]
Start in daemon mode
rails server -d
说明
rails server starts a web server for the Rails application. By default, it uses Puma and listens on http://localhost:3000 in the development environment. The server automatically reloads code changes in development mode, allowing rapid iteration without restarts. It displays request logs in the terminal, showing HTTP methods, paths, response codes, and timing information. Binding to 0.0.0.0 makes the server accessible from other machines on the network, useful for testing on mobile devices or from other computers.
参数
- -p, --port _PORT_
- Run server on specified port (default: 3000)
- -b, --binding _IP_
- Bind to specified IP address (default: localhost)
- -e, --environment _ENV_
- Run in specified environment (development, test, production)
- -d, --daemon
- Run server as a daemon (background process)
- -u, --using _SERVER_
- Use specified Rack server (puma, thin, webrick, etc.)
- -P, --pid _FILE_
- Specify PID file path
- -C, --dev-caching
- Toggle development mode caching
- --early-hints
- Enable HTTP/2 early hints
- -h, --help
- Show help information
FAQ
What is the rails-server command used for?
rails server starts a web server for the Rails application. By default, it uses Puma and listens on http://localhost:3000 in the development environment. The server automatically reloads code changes in development mode, allowing rapid iteration without restarts. It displays request logs in the terminal, showing HTTP methods, paths, response codes, and timing information. Binding to 0.0.0.0 makes the server accessible from other machines on the network, useful for testing on mobile devices or from other computers.
How do I run a basic rails-server example?
Run `rails server` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -p, --port _PORT_ do in rails-server?
Run server on specified port (default: 3000)