Created
January 3, 2021 19:56
-
-
Save exocode/89897bfc911c7a62a3afc72b5c952a4f to your computer and use it in GitHub Desktop.
Create Wordpress instance on Cloudcone
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
| apt-get update && apt-get upgrade | |
| # create user | |
| useradd deploy | |
| adduser deploy sudo # make user an admin | |
| # restart ssh to make user active | |
| sudo service ssh restart | |
| # install nginx | |
| sudo apt-get install nginx | |
| # show IP addresses | |
| ip addr show eth0 | grep inet | awk '{ print $2; }' | sed 's/\/.*$//' | |
| # Test browser | |
| http://YOUR_IP | |
| # install PHP | |
| # php-fpm | |
| sudo apt-get install software-properties-common python-software-properties | |
| sudo add-apt-repository ppa:ondrej/php | |
| sudo apt-get update | |
| sudo apt-get install -y php5.6 | |
| php -v #should be 5.6 | |
| # PHP 7 / you have to activate that extensions in /etc/php/7.0/fpm/php.ini | |
| sudo apt-get install php7.0-mbstring php7.0-mcrypt php7.0-mysql php7.0-xml php7.0-intl php7.0-intl php7.0-mbstring php7.0-cli php7.0-gd php7.0-curl | |
| sudo apt-get install php7.0-fpm | |
| # PHP 5.6 | |
| sudo apt-get install php5.6-mbstring php5.6-mcrypt php5.6-mysql php5.6-xml php5.6-intl php5.6-intl php5.6-mbstring php5.6-cli php5.6-gd php5.6-curl | |
| sudo apt-get install php5.6-fpm | |
| # check if socket is the right one | |
| sudo nano /etc/php/7.0/fpm/pool.d/www.conf | |
| sudo nano /etc/php/5.6/fpm/pool.d/www.conf | |
| listen = /run/php/php5.6-fpm.sock # should be that | |
| /etc/init.d/php5.6-fpm restart | |
| # install mysql | |
| sudo apt-get install mysql-server | |
| mysql_secure_installation | |
| mysql -u root -p | |
| CREATE DATABASE wordpress; | |
| CREATE USER wordpress@localhost IDENTIFIED BY 'password'; | |
| GRANT ALL PRIVILEGES ON wordpress.* TO wordpress@localhost; | |
| FLUSH PRIVILEGES; | |
| exit; | |
| # setup Nginx | |
| sudo nano /etc/nginx/sites-available/default | |
| # add at the beginning 'index.php' to 'index' section | |
| # add your IP address to 'server_name' | |
| # add the following lines below location / {} | |
| server { | |
| listen 80 default_server; | |
| listen [::]:80 default_server; | |
| root /var/www/html; | |
| index index.php index.html index.htm index.nginx-debian.html; | |
| server_name YOUR_DOMAIN_NAME; | |
| location / { | |
| try_files $uri $uri/ /index.php?$args; | |
| } | |
| location ~ \.php$ { | |
| try_files $uri =404; | |
| fastcgi_pass unix:/run/php/php5.6-fpm.sock; | |
| fastcgi_index index.php; | |
| fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
| include fastcgi_params; | |
| } | |
| } | |
| # reload nginx | |
| sudo systemctl reload nginx | |
| # prepare folders | |
| sudo chown -R www-data:www-data /var/www/ | |
| #make sure www-data members can add files | |
| sudo chmod -R 774 /var/www | |
| # SSL | |
| sudo add-apt-repository ppa:certbot/certbot | |
| sudo apt-get update | |
| sudo apt-get install python-certbot-nginx | |
| # version 1 | |
| sudo certbot --nginx -d hempalaya.com -d www.hempalaya.com | |
| # version 2 (worked for me) | |
| sudo certbot --authenticator webroot --installer nginx --agree-tos -d hempalaya.com -d www.hempalaya.com --renew-by-default --email mail@hempalaya.com --webroot-path /var/www/html/ | |
| # if it's not working try without --renew-by-default and --email | |
| # renew automatically | |
| service certbot start | |
| cat /etc/cron.d/certbot | |
| systemctl list-timers --all | |
| # find out who is running nginx | |
| ps -elf | grep nginx | |
| # put a user to the www-data group | |
| sudo usermod -aG www-data deploy | |
| # folder and file permissions | |
| sudo find /var/www/html/ -type d -exec chmod 755 {} \; | |
| sudo find /var/www/html/ -type f -exec chmod 644 {} \; | |
| sudo chown -R www-data /var/www/html | |
| sudo chmod -R 755 www-data /var/www/html | |
| # setup firewall | |
| sudo ufw allow 'Nginx HTTP' | |
| sudo ufw allow 'OpenSSH' | |
| sudo ufw enable | |
| sudo ufw status |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment