🌍 PHP Deployment – Detailed Answers
1. What is deployment?
Answer:
Deployment is the process of moving a PHP application from the local development environment to a live server so that it is accessible via the internet. It involves transferring files, configuring databases, and setting up the environment.
2. Difference between localhost and live server?
Answer:
Localhost runs on my machine using tools like XAMPP or WAMP. It’s for development and testing. A live server is hosted online, accessible to users globally, with its own domain, IP, and server configuration.
3. What is shared hosting?
Answer:
Shared hosting means multiple websites share the same server resources. It’s cost-effective and easy to use but offers limited performance and no root access.
4. What is VPS hosting?
Answer:
VPS (Virtual Private Server) hosting provides dedicated server resources virtually. Unlike shared hosting, it offers full control, root access, better performance, and flexibility to configure server settings.
5. What is a domain name?
Answer:
A domain name is the human-readable address of a website, like
example.com. It is mapped to the server’s IP via DNS records so that users can access the site easily.
6. What is DNS?
Answer:
DNS (Domain Name System) translates the domain name into the server IP address. For example,
example.com→192.168.1.1. It includes records like A, CNAME, MX, and TTL.
7. What is cPanel?
Answer:
cPanel is a web-based control panel to manage hosting. It allows you to upload files, manage databases, set up emails, install SSL, monitor server usage, and more, without using command line.
8. What is public_html?
Answer:
public_htmlis the root directory where all website files are stored for the live domain. Only files in this folder are publicly accessible.
9. How do you deploy a PHP project on shared hosting?
Answer:
- Compress the project folder and upload it to
public_html.- Extract the files.
- Create a database in cPanel and import the SQL file.
- Update the configuration file (DB credentials, site URL).
- Set proper file permissions.
- Test the website online.
- Enable SSL for HTTPS.
10. How do you connect a domain to hosting?
Answer:
Either by updating the domain’s nameservers to the hosting provider’s nameservers or by adding an A record in DNS pointing to the server IP.
11. What is a .env file?
Answer:
The
.envfile stores environment variables like database credentials, API keys, and application settings. It allows easy configuration for local and production environments.
12. Why should .env not be public?
Answer:
It contains sensitive data. If exposed, hackers could access the database, APIs, or other secure resources.
13. How do you migrate a database?
Answer:
Export the database from localhost using phpMyAdmin or
mysqldump, then import it into the live server database using phpMyAdmin or command-line tools.
14. What is SSL and why is it important?
Answer:
SSL (Secure Sockets Layer) encrypts data transmitted between server and user, enabling HTTPS. It protects sensitive information, improves SEO, and increases user trust.
15. How do you force HTTPS on a PHP site?
Answer:
By using
.htaccessrules:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
16. What is FTP?
Answer:
FTP (File Transfer Protocol) is used to upload and manage files on the server. FileZilla is a common FTP client.
17. What is Git and how is it used in deployment?
Answer:
Git is a version control system to track changes. For deployment, we push the project to GitHub or GitLab and pull it on the server. It ensures version control and team collaboration.
18. How do you deploy a Laravel project?
Answer:
- Upload the project or clone via Git.
- Run
composer installto install dependencies.- Configure
.envwith DB credentials and app URL.- Generate application key using
php artisan key:generate.- Run migrations
php artisan migrate.- Set proper permissions on
storageandbootstrap/cache.- Test and enable SSL.
19. What are common deployment mistakes?
Answer:
- Wrong database credentials.
.envmissing or incorrect.- File permissions incorrect.
- Debug mode ON.
- Not testing before going live.
20. How do you secure a PHP application?
Answer:
- Validate and sanitize user inputs.
- Use prepared statements to prevent SQL injection.
- Protect admin panels with authentication.
- Hide
.envand sensitive files.- Use HTTPS and keep PHP updated.
21. Scenario Question – Website not loading after deployment. What will you check?
Answer:
- Domain points correctly to hosting (DNS).
- Files are in
public_html.- Database connection details are correct.
- File permissions are proper.
- Check server error logs.
✅ These answers are ready to use in interviews, concise but professional.






