{"id":22680143,"url":"https://github.com/coderooz/phpwebserver","last_synced_at":"2025-06-13T10:35:15.349Z","repository":{"id":249492488,"uuid":"831667025","full_name":"coderooz/PHPWebserver","owner":"coderooz","description":"This is a simple web-server project made entirely using PHP. This projects is to experiment and demonstrate with how to create a web server using PHP.","archived":false,"fork":false,"pushed_at":"2024-07-21T09:22:34.000Z","size":15,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-04T14:36:16.440Z","etag":null,"topics":["php","php-server","web-server"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/coderooz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-07-21T09:06:13.000Z","updated_at":"2024-07-21T09:23:12.000Z","dependencies_parsed_at":"2024-07-21T10:32:02.810Z","dependency_job_id":"5c212c7f-c104-4b15-a770-fda6c45ab330","html_url":"https://github.com/coderooz/PHPWebserver","commit_stats":null,"previous_names":["coderooz/phpwebserver"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coderooz%2FPHPWebserver","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coderooz%2FPHPWebserver/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coderooz%2FPHPWebserver/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coderooz%2FPHPWebserver/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/coderooz","download_url":"https://codeload.github.com/coderooz/PHPWebserver/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246193156,"owners_count":20738450,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["php","php-server","web-server"],"created_at":"2024-12-09T19:12:32.195Z","updated_at":"2025-03-29T13:43:19.577Z","avatar_url":"https://github.com/coderooz.png","language":"PHP","readme":"# PHP Web Server\r\n\r\nThis is a simple PHP-based web server designed for experimentation and demonstration purposes. It allows you to serve multiple websites from different directories and handle basic `.htaccess` configurations.\r\n\r\n## Features\r\n\r\n- Serve multiple websites from different directories.\r\n- Basic `.htaccess` support for URL rewriting.\r\n- Customizable configuration file for website mapping and ports.\r\n- Targets `index.html` by default when serving directories.\r\n\r\n## Installation\r\n\r\n1. **Clone the Repository**\r\n\r\n   ```bash\r\n   git clone https://github.com/coderooz/php-web-server.git\r\n   cd php-web-server\r\n   ```\r\n\r\n2. **Install Dependencies**\r\n\r\n   Make sure you have [Composer](https://getcomposer.org/) installed. Run:\r\n\r\n   ```bash\r\n   composer install\r\n   ```\r\n\r\n## Configuration\r\n\r\n1. **Create `config.json`**\r\n\r\n   Create a `config.json` file in the project root directory with the following format:\r\n\r\n   ```json\r\n   {\r\n       \"websites\": [\r\n           {\r\n               \"port\": 8000,\r\n               \"documentRoot\": \"htdocs/website1\"\r\n           },\r\n           {\r\n               \"port\": 8080,\r\n               \"documentRoot\": \"htdocs/website2\"\r\n           }\r\n       ]\r\n   }\r\n   ```\r\n\r\n   - `port`: The port on which the website should be served.\r\n   - `documentRoot`: The directory where the website files are located.\r\n\r\n2. **Directory Structure**\r\n\r\n   Place your website directories under the `htdocs` folder. For example:\r\n\r\n   ```\r\n   php-web-server/\r\n   ├── htdocs/\r\n   │   ├── website1/\r\n   │   │   ├── .htaccess\r\n   │   │   ├── index.html\r\n   │   │   └── other-files\r\n   │   └── website2/\r\n   │       ├── .htaccess\r\n   │       ├── index.html\r\n   │       └── other-files\r\n   ├── src/\r\n   ├── config.json\r\n   ├── server\r\n   └── README.md\r\n   ```\r\n\r\n## Running the Server\r\n\r\nStart the server by running:\r\n\r\n```bash\r\nphp server\r\n```\r\n\r\nThe server will read the `config.json` file and start serving the websites on the specified ports. For example:\r\n\r\n- Website 1 will be served on [http://localhost:8000](http://localhost:8000).\r\n- Website 2 will be served on [http://localhost:8080](http://localhost:8080).\r\n\r\n## Handling `.htaccess`\r\n\r\nThe server performs basic `.htaccess` processing for URL rewriting. If you need more advanced `.htaccess` support, consider using a dedicated web server like Apache or Nginx.\r\n\r\n## Example `.htaccess`\r\n\r\nHere's a basic example of a `.htaccess` file for URL rewriting:\r\n\r\n```\r\nRewriteEngine On\r\nRewriteRule ^old-page\\.html$ new-page.html [L,R=301]\r\n```\r\n\r\n## Contributing\r\n\r\nContributions are welcome! Please fork the repository and submit a pull request. For major changes, please open an issue first to discuss what you would like to change.\r\n\r\n## License\r\n\r\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\r\n\r\n## Contact\r\n\r\nFor questions or comments, please contact Ranit Saha at [Coderooz](https://github.com/coderooz).\r\n\r\n\r\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoderooz%2Fphpwebserver","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcoderooz%2Fphpwebserver","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoderooz%2Fphpwebserver/lists"}