Enable mod_rewrite in ec2 linux and other configuration

people

Aneh Thakur

. 2 min read

In this post i explain how to enable mod_rewrite in amazon ec2 Linux instance and also show you how to enable gd extension and some use full command which you regular use while working with ec2.

Enable mod_rewrite on ec2 linux

Step 1. Login to server using putty

Step 2. Now switch to super user by typing this command

plaintext
sudo su

Step 3. After switching change directory to /etc/httpd/conf

plaintext
cd /etc/httpd/conf

Step 4. Now open this file to edit using command

plaintext
nano httpd.conf

Step 5. Find <Directory “/var/www/html”> it is on line no 132 in my case and look like as shown bellow, now you need to AllowOverride All from AllowOverride None .

plaintext
# Further relax access to the default document root:
<Directory "/var/www/html">
    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # http://httpd.apache.org/docs/2.4/mod/core.html#options
    # for more information.
    #
    Options Indexes FollowSymLinks

    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   Options FileInfo AuthConfig Limit
    #
    AllowOverride All

    #
    # Controls who can get stuff from this server.
    #
    Require all granted
</Directory>

One you edit this save the file using ctrl+o and hit enter and to exit press ctrl + x

Step 6. Now last step is to restart your server type this command

plaintext
service httpd restart

Done! now  you can rewrite your url.

Install GD Library in EC2 Linux

Enable GD in Linux ec2

Before start please check php info if GD is enable or not, if not then we do :-p.

Step 1. Login to ec2 instance using putty.

Step 2. Type bellow given command

plaintext
sudo yum install php56-gd

Step 3. Restart server

plaintext
service httpd restart

Done! Now check your phpinfo.

Useful commands you use in putty for ec2

Login as Super User :

  sudo su

Open, Save File:

nano <file_name>,  ctrl+o, ctrl+x

Install package using yum:

 sudo yum install <Package_name>

Remove yum package:

 sudo yum remove <Package_name>

Restart Server:

sudo /sbin/service httpd restart   or  service httpd restart

Get file from other server:

  wget  <URL>

UNZIP file :

unzip <filename.zip>

Remove file/folder:

 rm -rf <file_name>

Rename file/folder:

mv <file_name> <new_file_name>

Unistall php, mysql:

 sudo yum remove -y httpd24* php56* mysql55-server* php56-mysqlnd*

All done hope this help you.

happy coding.

More Stories from

Aneh Thakur
Aneh Thakur.4 min read

India’s Rise in the AI Era: Shaping the Future as a Global Leader

India is becoming a global AI leader through initiatives like IndiaAI, indigenous LLMs like Sarvam AI and BharatGPT, and rapid startup growth. Learn how AI is shaping India’s digital and inclusive future.

Aneh Thakur
Aneh Thakur.5 min read

AI and Beginner Developers: A Double-Edged Sword in Programming

AI tools are transforming how beginner developers learn to code. Discover the benefits, risks of over-reliance, and best practices to use AI effectively in your programming journey.

Aneh Thakur
Aneh Thakur.3 min read

Mastering Google AI Mode: A Guide for SEO Professionals in the Age of Answer Engines

Learn how Google AI Mode is changing search. Discover how to adapt your SEO strategy with Answer Engine Optimization (AEO) for AI-powered results.

SWATI BARWAL
SWATI BARWAL.3 min read

🚀 OpenAI’s $3 Billion Windsurf Acquisition: What It Really Means

OpenAI's $3 billion Windsurf deal shows that developer tools—not chatbots—are the real future of AI. Here’s what this means for coders, jobs, and the evolving dev landscape.

.
Aneh Thakur
Aneh Thakur.4 min read

🚀 How to Build an MCP Server for Zerodha – AI-Powered Trading with Claude

Learn how to build an MCP (Model Context Protocol) server that connects Claude AI with Zerodha’s trading API. Execute stock trades, view portfolios, and automate strategies using natural language.

Built on Koows