Last active
June 23, 2016 14:02
-
-
Save oak-tree/50d09d63e8d90e218310a99aca79b12a to your computer and use it in GitHub Desktop.
installing ngix + mysql on ec2 ubuntu
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ####READ COMMENTS | |
| #### comments contain instruction that are must be done and not via terminal! | |
| ############################################################################# | |
| # install ubuntu | |
| # make sure to add security group that allows to connect mysql instance | |
| sudo apt-get update | |
| # add ngix repository | |
| #ubnutu get stable | |
| sudo -s | |
| nginx=stable # use nginx=development for latest development version | |
| add-apt-repository ppa:nginx/$nginx | |
| apt-get update | |
| apt-get install nginx | |
| sudo vim /etc/nginx/nginx.conf | |
| #add the following line | |
| client_max_body_size 10M; | |
| sudo nginx -s reload | |
| vim /etc/php5/fpm/php.ini | |
| #add the following lines | |
| upload_max_filesize = 10M | |
| post_max_size = 10M | |
| /etc/init.d/php5-fpm restart | |
| # make sure you can access port 80 on browser (nginx on ubuntu is running on default after installtion) | |
| #sudo apt-get install phpmyadmin # note that it will ask you to install apache or other webserver | |
| sudo apt-get install git | |
| git clone https://github.com/phpmyadmin/phpmyadmin.git --depth 1 | |
| sudo apt-get install php5-curl | |
| php ../composer.phar install --no-dev | |
| cp phpmyadmin folder to /usr/share/phpmyadmin | |
| vim libraries/vendor_config.php | |
| define('SETUP_CONFIG_FILE', '/var/lib/phpmyadmin/config.inc.php'); | |
| define('CONFIG_DIR', '/etc/phpmyadmin/'); | |
| import create_tables.sql from phpmyadmin/sql folder | |
| create pma user | |
| GRANT SELECT, INSERT, UPDATE, DELETE ON phpmyadmin.* TO 'pma'@'0.0.0.0' IDENTIFIED BY 'password'; | |
| # note that if one use dbconfig then it will have /etc/phpmyadmin/db-config.php file | |
| # in that file one should put the details of the above user | |
| #install https://getcomposer.org/download/ | |
| sudo ln -s /usr/share/phpmyadmin /usr/share/nginx/html | |
| sudo vim /var/lib/phpmyadmin/config.inc.php | |
| # if mistakly installed apache | |
| sudo apt-get --purge remove apache | |
| find / -name config.sample.inc.php | grep php | |
| cd /usr/share/phpmyadmin/ | |
| cp config.sample.inc.php config.inc.php | |
| $cfg['Servers'][$i]['host'] = '<Sever name>'; | |
| sudo nano /etc/php5/fpm/php.ini | |
| #set cgi.fix_pathinfo=0 | |
| sudo vim /etc/nginx/sites-available/default | |
| #add index.php | |
| #setup php configuration like in https://gist.github.com/oak-tree/953f2ed75554be3689c41ab4c7a20f93 | |
| #unmark php stuff at bottom | |
| sudo nginx -s reload | |
| $cfg['Servers'][$i]['port'] = '<Port>'; | |
| #https://www.digitalocean.com/community/tutorials/how-to-create-a-self-signed-ssl-certificate-for-nginx-in-ubuntu-16-04 | |
| # privately sign ssl | |
| sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/private/nginx-selfsigned.key -out /etc/ssl/certs/nginx-selfsigned.crt | |
| sudo openssl dhparam -out /etc/ssl/certs/dhparam.pem 2048 | |
| cd /etc/nginx/ | |
| sudo mkdir snippets | |
| cd snippets/ | |
| sudo vim self-signed.conf | |
| #paste the following lines | |
| ssl_certificate /etc/ssl/certs/nginx-selfsigned.crt; | |
| ssl_certificate_key /etc/ssl/private/nginx-selfsigned.key; | |
| sudo vim ssl-params.conf | |
| #paste the following lines | |
| # from https://cipherli.st/ | |
| # and https://raymii.org/s/tutorials/Strong_SSL_Security_On_nginx.html | |
| ssl_protocols TLSv1 TLSv1.1 TLSv1.2; | |
| ssl_prefer_server_ciphers on; | |
| ssl_ciphers "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH"; | |
| ssl_ecdh_curve secp384r1; | |
| ssl_session_cache shared:SSL:10m; | |
| ssl_session_tickets off; | |
| ssl_stapling on; | |
| ssl_stapling_verify on; | |
| resolver 8.8.8.8 8.8.4.4 valid=300s; | |
| resolver_timeout 5s; | |
| add_header Strict-Transport-Security "max-age=63072000; includeSubdomains; preload"; | |
| add_header X-Frame-Options DENY; | |
| add_header X-Content-Type-Options nosniff; | |
| ssl_dhparam /etc/ssl/certs/dhparam.pem; | |
| #backup nginx | |
| sudo cp /etc/nginx/sites-available/default /etc/nginx/sites-available/default.bak |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment