Documentation
Installation
Composer command
composer create-project dhruvjoshi/precocious
Create Linux Server and Auto-installer - Apache | Nginx
Finalizing Installation
The script will perform the necessary installations and configurations. Once it finishes, you will see a completion message.
sudo curl -O https://raw.githubusercontent.com/DevDhruvJoshi/PrecociousServerConfiguration/main/setup.sh && sudo chmod +x setup.sh && sudo ./setup.sh
Run MySQL Secure Installation: After the setup, you will need to run the command mysql_secure_installation manually to secure your MySQL installation.
Expected Output
You will see messages indicating the progress of the installation, including updates, package installations, and configuration steps. Any errors will be displayed in red for easy identification.
Post-Installation
Verify Apache Installation: Open your web browser and navigate to your server’s IP address or domain name. You should see a page indicating that the server is running.
Access Your Website: The document root for your domain is located at /var/www/your-domain, where you can place your web files.
Notes
Ensure that your domain’s DNS A record is pointing to your server’s public IP address before accessing it.
It’s recommended to review firewall settings to ensure Apache is allowed to serve traffic (usually set up by the script).
Troubleshooting
If you encounter issues, check the Apache logs located at /var/log/apache2/error.log for errors. Ensure that your server is updated and that all necessary packages are available.
Conclusion
This script simplifies the process of setting up a web server environment. By following this documentation, users can quickly get their server ready for web hosting with the required software stack.
Enabling mod_rewrite module
mod_rewrite is an Apache module that allows you to rewrite URLs and create custom rules for your website. This can be very useful for SEO and improving user experience.
Here's a guide on enabling mod_rewrite for different operating systems:
Windows (XAMPP):
Open your Apache configuration file:
Location: C:\xampp\apache\conf\httpd.conf
Uncomment the mod_rewrite module: Find the line:
#LoadModule rewrite_module modules/mod_rewrite.so
Remove the # symbol at the beginning to uncomment the line.
Restart Apache: In the XAMPP control panel, click "Stop" and then "Start" to restart the Apache service.
Linux:
Open your Apache configuration file:
Location (may vary): /etc/apache2/apache2.conf
Uncomment the mod_rewrite module: Follow the same steps as Windows (point 2).
Set AccessFileName to htaccess.txt: Follow the same steps as Windows (point 3).
Create an .htaccess.txt file: Follow the same steps as Windows (point 4).
Restart Apache: Use the following command in your terminal:
sudo systemctl restart apache2
Mac:
Open your Apache configuration file:
Location: /etc/apache2/httpd.conf
Uncomment the mod_rewrite module: Follow the same steps as Windows (point 2).
Set AccessFileName to htaccess.txt: Follow the same steps as Windows (point 3).
Create an .htaccess.txt file: Follow the same steps as Windows (point 4).
Restart Apache: Use the following command in your terminal:
sudo apachectl restart
Additional Tips:
If you're unsure how to write rewrite rules, there are many online resources and tutorials available.
In case of any issues, refer to the official Apache documentation or forums for help.
Virtual Host
1. Editing the Hosts File
Before configuring the virtual host, you need to modify the hosts file to map a custom domain name to your local machine's IP address (usually 127.0.0.1).
Windows: Open the hosts file located in C:\Windows\System32\drivers\etc.
Linux/macOS: Open the hosts file located in /etc/hosts.
Note: You'll likely need administrator privileges to edit this file. Use a text editor like Notepad++ (Windows) or TextEdit (Mac) with administrator rights.
Add the following line to the hosts file, replacing precocious.dev with your desired domain name:
127.0.0.1 precocious.dev
2. Configuring the Virtual Host
The location of the virtual host configuration file depends on your operating system and web server software. Here's a breakdown for common setups:
A. Apache (Windows/Linux/Mac):
The virtual host configuration file is typically located in:
Windows: C:\xampp\apache\conf\extra\httpd-vhosts.conf (if using XAMPP)
Linux: /etc/apache2/sites-available/ (default location)
macOS: /private/etc/apache2/other/ (default location)
Create a new virtual host configuration file with a descriptive name (e.g., precocious.conf).
Add the following code to the virtual host file, replacing placeholders with your project details:
Apache
<VirtualHost *:80>
ServerName precocious.dev
DocumentRoot /path/to/your/precocious/project
<Directory /path/to/your/precocious/project>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
Use code with caution.
Replace the following placeholders:
precocious.dev: The domain name you added to your hosts file.
/path/to/your/precocious/project: The actual directory path where your precocious project resides on your system.
3. Enabling the Virtual Host
A. Apache (Windows/Linux/Mac):
Windows (XAMPP):
Uncomment the line Include conf/extra/httpd-vhosts.conf in the main Apache configuration file (httpd.conf).
Restart the Apache service in XAMPP control panel.
Linux/macOS:
Enable the virtual host configuration file you created. The command varies depending on your distribution:
Ubuntu/Debian: sudo a2ensite precocious.conf
CentOS/RHEL: sudo ln -s /etc/apache2/sites-available/precocious.conf /etc/apache2/sites-enabled/precocious.conf
Restart the Apache service:
Ubuntu/Debian: sudo systemctl restart apache2
CentOS/RHEL: sudo systemctl restart httpd
4. Testing Your Virtual Host
Once you've completed the steps above, you should be able to access your precocious project using the domain name you specified in the hosts file (e.g., [invalid URL removed]).