Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save malihassan20/6c1e7a10b973cf34260b0a203443994d to your computer and use it in GitHub Desktop.
Save malihassan20/6c1e7a10b973cf34260b0a203443994d to your computer and use it in GitHub Desktop.
Updating the Package List
---> sudo apt-get update
Installing Apache
---> sudo apt-get install apache2
check it: http://your-ip-address/
Installing MySql
---> sudo apt-get install mysql-server
At this point, we’re going to install PHP 7.1. Since 7.1 is new and cutting edge,
it is not available in the regular apt repository. We’re going to use a PPA (Personal Package Archive)
to install this non-standard software.
Add the Onrej PPA to your machine.
---> sudo apt-add-repository ppa:ondrej/php
---> sudo apt-get update
---> sudo apt-get install php7.1
replace php with the version you want to use
---> sudo apt-get install libapache2-mod-php php-mysql php-mbstring php-curl php-gd php-json php-mcrypt php-zip
Check it:
echo "<?php phpinfo(); ?>" | sudo tee /var/www/html/phpinfo.php
http://your-ip-address/phpinfo.php
Installing phpMyAdmin
---> sudo apt-get install phpmyadmin
Checking Successful Installation of phpMyAdmin
http://your-ip-addrss/phpmyadmin
Modifying Apache to Allow URL Rewrites
First, we need to modify the Apache virtual host file for WordPress to allow for .htaccess overrides.
You can do this by editing the virtual host file.
By default, this is 000-default.conf, but your file might be different if you created another
configuration file:
---> sudo nano /etc/apache2/sites-available/000-default.conf
Inside of this file, we want to set up a few things. We should set the ServerName and create
a directory section where we allow overrides. This should look something like this:
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
ServerName server_domain_name_or_IP
<Directory /var/www/html/>
AllowOverride All
</Directory>
. . .
Next, we need to enable the rewrite module, which allows you to modify URLs. You can do this by typing:
---> sudo a2enmod rewrite
---> sudo service apache2 restart
Set File Permissions
Add the www group to your instance.
---> sudo groupadd www
Add your user (in this case, ec2-user) to the www group.
---> sudo usermod -a -G www ec2-user
You need to log out and log back in to pick up the new group.
You can use the exit command, or close the terminal window.
Reconnect to your instance, and then run the following command to verify your membership in the www group.
---> groups
Which should return group names:
ec2-user wheel www
Change the group ownership of /var/www and its contents to the www group.
---> sudo chown -R root:www /var/www
Change the directory permissions of /var/www and its subdirectories to add group write
permissions and to set the group ID on future subdirectories.
---> sudo chmod 2775 /var/www
---> find /var/www -type d -exec sudo chmod 775 {} \;
Recursively change the file permissions of /var/www and its subdirectories to add group write permissions.
---> find /var/www -type f -exec sudo chmod 664 {} \;
Restart the Apache web server to pick up the new group and permissions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment