Setting Up a New Server with AWS EC2 & AMI’s

Home Knowledgebase Setting Up a New Server with AWS EC2 & AMI’s

We have switched from our former web-server-1.iteratemarketing.com to a newer model under TPC.

 

How to configure NGinx and PHP-FPM for increased uploads.

On Ubuntu 16.04 edit /etc/php/7.0/fpm/php.ini look for lines post_max_size and upload_max_filesize and set them both to 1000m. Then reboot PHP (sudo systemctl restart php7.0-fpm) and NGinx (sudo systemctl restart nginx)

 

How to configure NGinx and PHP-FPM to allow media uploads by WordPress

 

Where are SSL files stored?

If you used Let’s Encrypt or Certbot to generate SSL certificates them they are generated here:

/home/{domain-username}/domains/{domain}/ssl.cert

 

How to configure WordPress & WordPress Multisite with NGinx on our AWS AMI

This is the official documentation, but it’s lacking key details. I would contribute the clarified information but it’s locked down from contributions currently and I don’t have the time to figure out how to get permission.

This code belongs in /etc/nginx/sites-enabled/{name-of-the-site}.conf

# Generic startup file.
user {user} {group};

#usually equal to number of CPUs you have. run command "grep processor /proc/cpuinfo | wc -l" to find it
worker_processes  2;

error_log  /var/log/nginx/error.log;
pid        /var/run/nginx.pid;

# Keeps the logs free of messages about not being able to bind().
#daemon     off;

events {
	worker_connections  1024;
}

http {
#	rewrite_log on;

	include mime.types;
	default_type       application/octet-stream;
	access_log         /var/log/nginx/access.log;
	sendfile           on;
#	tcp_nopush         on;
	keepalive_timeout  3;
#	tcp_nodelay        on;
#	gzip               on;
        #php max upload limit cannot be larger than this       
	client_max_body_size 13m;
	index              index.php index.html index.htm;

	# Upstream to abstract backend connection(s) for PHP.
	upstream php {
                #this should match value of "listen" directive in php-fpm pool
		server unix:/tmp/php-fpm.sock;
#		server 127.0.0.1:9000;
	}

	include sites-enabled/*;
}

 

Troubleshooting

Errors rebooting NGinx

Ensure Apache is stopped, it uses the same ports as NGinx by default. sudo /etc/init.d/apache2 stop

Ensure you stop, start and restart NGinx using sudo: sudo /etc/init.d/nginx start

If files, such as SSL files, are not owned by root then NGinx can’t restart. You may get an error that looks like this:

➜ public_html git:(master) ✗ sudo service nginx stop

➜ public_html git:(master) ✗ sudo service nginx start Job for nginx.service failed because the control process exited with error code. See “systemctl status nginx.service” and “journalctl -xe” for details.

➜ public_html git:(master) ✗ systemctl status nginx.service

● nginx.service – A high performance web server and a reverse proxy server Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled) Drop-In: /etc/systemd/system/nginx.service.d └─override.conf Active: failed (Result: exit-code) since Thu 2018-08-23 22:30:23 UTC; 44s ago Process: 27985 ExecStop=/sbin/start-stop-daemon –quiet –stop –retry QUIT/5 –pidfile /run/nginx.pid (code=exited, status=0/SUCCESS) Process: 25445 ExecStartPost=/bin/sleep 0.1 (code=exited, status=0/SUCCESS) Process: 32481 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=1/FAILURE) Process: 32477 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS) Main PID: 25444 (code=exited, status=0/SUCCESS)

 

Solution

To resolve this you should run:

  • ps -aux | grep nginx to see “master process” with root user and sub processes.

 

Getting Apache page instead of NGInx

Test the URL incognito if you’re certain Apache is stopped and NGinx is running.




By
Categorized in:
This post is related to:

  • Generic selectors
    Exact matches only
    Search in title
    Search in content
    Search in posts
    Search in pages
    Filter by Categories
    10
    2D Vector Design
    8.1
    Adobe
    AdWords
    Analytics
    Apple
    Apps
    Bash / Shell
    Bedrock
    Blade
    Business Development
    Careers
    ChromeOS
    Company News
    Content Marketing
    Digital Design
    Digital Marketing
    Freelancing
    Gaming
    Google
    Google Hangouts
    Illustrator
    Linux
    Mac
    New Products or Services
    Operating Systems
    OS X
    Pay Per Click Management
    Paypal
    PHP
    Press Releases
    Programming
    Razer
    Reviews
    Roots
    Sage Theme
    Search Engine Marketing
    Search Engine Optimization
    Search Marketing
    Tips and Tricks
    Trellis
    Tutorials
    Ubuntu
    Uncategorized
    Video Production
    Web Hosting
    Website Development
    Website Development
    Windows
    WordPress
  • Recent Posts

  • Categories

  • Home Knowledgebase Setting Up a New Server with AWS EC2 & AMI’s

    We have switched from our former web-server-1.iteratemarketing.com to a newer model under TPC.

     

    How to configure NGinx and PHP-FPM for increased uploads.

    On Ubuntu 16.04 edit /etc/php/7.0/fpm/php.ini look for lines post_max_size and upload_max_filesize and set them both to 1000m. Then reboot PHP (sudo systemctl restart php7.0-fpm) and NGinx (sudo systemctl restart nginx)

     

    How to configure NGinx and PHP-FPM to allow media uploads by WordPress

     

    Where are SSL files stored?

    If you used Let’s Encrypt or Certbot to generate SSL certificates them they are generated here:

    /home/{domain-username}/domains/{domain}/ssl.cert

     

    How to configure WordPress & WordPress Multisite with NGinx on our AWS AMI

    This is the official documentation, but it’s lacking key details. I would contribute the clarified information but it’s locked down from contributions currently and I don’t have the time to figure out how to get permission.

    This code belongs in /etc/nginx/sites-enabled/{name-of-the-site}.conf

    # Generic startup file.
    user {user} {group};
    
    #usually equal to number of CPUs you have. run command "grep processor /proc/cpuinfo | wc -l" to find it
    worker_processes  2;
    
    error_log  /var/log/nginx/error.log;
    pid        /var/run/nginx.pid;
    
    # Keeps the logs free of messages about not being able to bind().
    #daemon     off;
    
    events {
    	worker_connections  1024;
    }
    
    http {
    #	rewrite_log on;
    
    	include mime.types;
    	default_type       application/octet-stream;
    	access_log         /var/log/nginx/access.log;
    	sendfile           on;
    #	tcp_nopush         on;
    	keepalive_timeout  3;
    #	tcp_nodelay        on;
    #	gzip               on;
            #php max upload limit cannot be larger than this       
    	client_max_body_size 13m;
    	index              index.php index.html index.htm;
    
    	# Upstream to abstract backend connection(s) for PHP.
    	upstream php {
                    #this should match value of "listen" directive in php-fpm pool
    		server unix:/tmp/php-fpm.sock;
    #		server 127.0.0.1:9000;
    	}
    
    	include sites-enabled/*;
    }

     

    Troubleshooting

    Errors rebooting NGinx

    Ensure Apache is stopped, it uses the same ports as NGinx by default. sudo /etc/init.d/apache2 stop

    Ensure you stop, start and restart NGinx using sudo: sudo /etc/init.d/nginx start

    If files, such as SSL files, are not owned by root then NGinx can’t restart. You may get an error that looks like this:

    ➜ public_html git:(master) ✗ sudo service nginx stop

    ➜ public_html git:(master) ✗ sudo service nginx start Job for nginx.service failed because the control process exited with error code. See “systemctl status nginx.service” and “journalctl -xe” for details.

    ➜ public_html git:(master) ✗ systemctl status nginx.service

    ● nginx.service – A high performance web server and a reverse proxy server Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled) Drop-In: /etc/systemd/system/nginx.service.d └─override.conf Active: failed (Result: exit-code) since Thu 2018-08-23 22:30:23 UTC; 44s ago Process: 27985 ExecStop=/sbin/start-stop-daemon –quiet –stop –retry QUIT/5 –pidfile /run/nginx.pid (code=exited, status=0/SUCCESS) Process: 25445 ExecStartPost=/bin/sleep 0.1 (code=exited, status=0/SUCCESS) Process: 32481 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=1/FAILURE) Process: 32477 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS) Main PID: 25444 (code=exited, status=0/SUCCESS)

     

    Solution

    To resolve this you should run:

    • ps -aux | grep nginx to see “master process” with root user and sub processes.

     

    Getting Apache page instead of NGInx

    Test the URL incognito if you’re certain Apache is stopped and NGinx is running.

    About

    Since 2005 we've been offering digital and content marketing strategy and implementation. Including website development, search engine optimization and marketing, search marketing and more.

    Continue Reading »

    Contact

    Email

    us@theportlandcompany.com

    Phone

    503-567-9561

    Follow

  • Logo for The Portland Company with a Coyote
    Thank you for using our site. x