Skip to content

Instantly share code, notes, and snippets.

@thosuperman
Last active January 1, 2019 12:12
Show Gist options
  • Save thosuperman/42eae938b492496ed3efb3760529ef4c to your computer and use it in GitHub Desktop.
Save thosuperman/42eae938b492496ed3efb3760529ef4c to your computer and use it in GitHub Desktop.
:: UPDATE YUM ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
sudo yum update -y
:: MAKE SWAP :::::::::::::::::::::::::::::::::::::::::::::::::::::::::
sudo dd if=/dev/zero of=/swapfile bs=1024 count=1024k
sudo su
mkswap /swapfile
swapon /swapfile
swapon -s
echo /swapfile none swap defaults 0 0 >> /etc/fstab
chown root:root /swapfile
chmod 0600 /swapfile
:: INSTALL WEBSERVER :::::::::::::::::::::::::::::::::::::::::::::::::::::::::
sudo yum install httpd24
sudo service httpd start
sudo chkconfig httpd on
chkconfig --list httpd
:: CONFIGURE HTTPD :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
sudo nano /etc/httpd/conf/httpd.conf
<Directory "/var/www/html">
Options All
AllowOverride All
Require all granted
</Directory>
:: CONFIGURE VHOSTS ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
sudo nano /etc/httpd/conf.d/vhosts.conf
<create log and vhost folders in html>
<VirtualHost *:80>
ServerName yourdomain.com
ServerAlias www.yourdomain.com
DocumentRoot "/var/www/html/www.other-site.com"
ErrorLog "/var/www/html/www.other-site.com/logs/error_log"
CustomLog "/var/www/html/www.other-site.com/logs/access_log" combined
<Directory "/var/www/html/www.other-site.com">
Options All
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
:: ADD EC2 USER TO WWW :::::::::::::::::::::::::::::::::::::::::::::::::::::::
ls -l /var/www
sudo groupadd www
sudo usermod -a -G www ec2-user
<exit>
<login>
groups
sudo chown -R root:www /var/www
sudo chmod 2775 /var/www
find /var/www -type d -exec sudo chmod 2775 {} +
find /var/www -type f -exec sudo chmod 0664 {} +
:: ADD APACHE USER TO WWW :::::::::::::::::::::::::::::::::::::::::::::::::::::::
sudo usermod -a -G www apache
<also change the apache config to use apache:www>
:: INSTALL MYSQL :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
sudo yum localinstall https://dev.mysql.com/get/mysql57-community-release-el6-11.noarch.rpm
sudo yum install mysql-community-server
sudo service mysqld start
::::::::::::::::::::::::::::::::
(Note: get temporary password for mysql by command:
sudo grep 'temporary password' /var/log/mysqld.log | awk '{print $NF}')
::::::::::::::::::::::::::::::::
sudo /usr/bin/mysql_secure_installation
<enter password get above>
<new-pass>
<new-pass>
<Y>
<Y>
<Y>
<Y>
sudo chkconfig mysqld on
:: Change to use another password that easy for remember than (optional) ::::::::::::::::::::::::::::::::
mysql -u root -p
uninstall plugin validate_password;
sudo /usr/bin/mysql_secure_installation
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: INSTALL PHP 7.2 WITH MYSQL AND SOME BASICS ::::::::::::::::::::::::::::::::
sudo yum install php72 php72-gd php72-imap php72-mbstring php72-mysqlnd php72-opcache php72-pdo php72-pecl-apcu php72-mcrypt
sudo service httpd restart
echo "<?php phpinfo(); ?>" > /var/www/html/phpinfo.php
:: EDIT PHP.INI ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
sudo nano /etc/php.ini
expose_php = Off
error_log = /var/log/php-error.log
date.timezone = "Asia/Ho_Chi_Minh"
sudo service httpd restart
:: INSTALL PHPMYADMIN ::::::::::::::::::::::::::::::::::::::::::::::::::::::::
sudo su
cd /var/www && wget https://github.com/phpmyadmin/phpmyadmin/archive/RELEASE_4_6_6.zip && unzip RELEASE_4_6_6.zip && mv phpmyadmin-RELEASE_4_6_6 phpmyadmin && rm -rf RELEASE_4_6_6.zip
sudo nano /etc/httpd/conf.d/phpmyadmin.conf
Listen 9000
<VirtualHost *:9000>
DocumentRoot /var/www/phpmyadmin
<Directory /var/www/phpmyadmin>
# enable the .htaccess rewrites
AllowOverride All
Options All
Require all granted
</Directory>
</VirtualHost>
sudo service httpd restart
:: INSTALL letsencrypt ::::::::::::::::::::::::::::::::::::::::::::::::::::::::
sudo service httpd stop
sudo service mysqld stop
sudo su
sudo yum install mod24_ssl
yum install python27-devel git
git clone https://github.com/letsencrypt/letsencrypt /opt/letsencrypt
/opt/letsencrypt/letsencrypt-auto --debug
sudo service httpd restart
sudo service mysqld restart
@thosuperman
Copy link
Author

$ cd ~
$ sudo curl -sS https://getcomposer.org/installer | sudo php
$ sudo mv composer.phar /usr/local/bin/composer
$ sudo ln -s /usr/local/bin/composer /usr/bin/composer

then you can run
$ sudo composer install

@thosuperman
Copy link
Author

sudo yum install php70 php70-gd php70-imap php70-mbstring php70-mysqlnd php70-opcache php70-pdo php70-pecl-apcu php70-mcrypt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment