I’ve been trying to install PageSpeed on an existing Nginx server for the last 12 hrs with no luck, I keep running into different errors and having to read over and again to solve them. This is my first VPS
But I understand that some PPAs have this inbuilt. I don’t mind starting a new server to have this installed from the scratch and rebuild WP on it. I know that Easyengine had it but took Pagespeed out in Ver 3.6
Any other PPA suggestions will be welcome
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
@ososoba
Before We Get Started
This is meant to be a copy and paste command, meaning you copy it from top to bottom and paste it to the CLI, then hit enter and let it run its course.
This installs NGINX w/Pagespeed, PHP 7.1, and MariaDB, but it will take a little bit of time to complete, so be patient; source compiles take time.
I’ve provided configuration samples for NGINX and your first Server Block below the command with a few details. This should get you started with a working build environment. You’ll still need to create your database(s), upload your PHP files, etc.
Finally … this is a long post. Take your time :-).
The One-Liner
Once the above completes, we need to run the following, which will delete our existing NGINX config and files we don’t need.
Now, we’ll implement our actual NGINX configuration by creating a new NGINX configuration file.
and paste in:
Now we’ll create our PHP FastCGI Params file, much like we did the above.
and paste in:
Ok, now we need to create a server block for your domain, so we’ll create that now. Simply replace
yourdomain.com
with your actual domain.and paste in:
Change
/home/username/htdocs/public
to the actual directory where you’re installing WordPress (i.e. where the WordPressindex.php
file resides).Finally, we need to make sure PHP-FPM can read/write on your files, so whichever directory you set as the
root
above, i.e./home/username/htdocs/public
, we need to change ownership of everything towww-data
.That’ll make all files and directories owned by
www-data
, as they should be. Now we just need to start NGINX and restart PHP-FPM for good measure.Type in
nginx
and hit enter, then:@ososoba
You don’t specifically need a PPA as they have their own auto-installer that’s available. It’ll automate a source build of NGINX w/
ngx_pagespeed
as a module. All you need to do is run:… and follow the on-screen prompts.
Keep in mind, this is a very barebones installation of NGINX. If you need specific modules compiled in, you’ll need to specify those when the script prompts you.
References
https://modpagespeed.com/doc/build_ngx_pagespeed_from_source
https://modpagespeed.com/doc/configuration
http://wiki.nginx.org/InitScripts
Ive written a tutorial on this lEMP stack pagespeed mod. Hope this helps anyone needing mariadb php7 pagespeed mod nginx and letsencrypt markbarry.info
@jtittle Why does it overwrite my nginx every time I upgrade my server and there is an new nginx version. I gotta go offline every time to fix it. Anyways to stop that?
Thank you I appreciate everything you do.
Hi! @jtittle @jtittle1 ,
Is this still working? ubuntu 16.04x64 1G
cd /usr/local/src git clone https://github.com/serveradminsh/installers.git
cd installers/nginx chmod +x installer.sh ./installer.sh or cd /opt/installers/nginx chmod +x installer.sh ./installer.sh
Then copy above nginx.conf, fastcgi_params, and domain.com.conf?
I’m totally new on droplets. I tried installing ngx_pagespeed + ssl with no avail. Well, I have a working L E MariaDB P and WP, but after installing fastcgi, redis, phpredis I don’t know how to purge the cache, I don’t even know if the modules are properly working. I hope ngx_cache_purge will not give me headache.
What will be the best droplet for this kind of installation? Can I stay in ubuntu16.04 lts 1g x 64? I don’t have much traffic, just started.
Thanks
Thank you @jtittle .
Unfortunately there is somewhere a mistake.
When i just replace beta with stable then it tries to get the zip from…
…which should be…
And when i adjust the code like so…
line 57:
from line 126:
and on line 232:
…i get:
:-(
Any idea what’s going wrong here?
Hi @jtittle,
unfortunately i am having some issues with the beta version of pagespeed which is compiled with nginx in your installer.sh. When changing the pagespeedVers in line 57 to 1.11.33.4 i get the error: ngx_pagespeed: pagespeed optimization library not found.
How can we change the installer.sh so the latest stable version of pagespeed is installed rather then the beta version?
Thank you again for your time and help.
Best regards nolybom
Hi @jtittle, please don’t let this project die.
@nolybom
You’ll need to install the PHP packages that you require for your website(s). The
apt-cache
command only searches for packages – it won’t install them for you.You’ll need to choose which packages you want to install and use
apt
orapt-get
to install.i.e.
etc.
You’d repeat this for each version that you wish to install.
@jtittle
WOW! This is by far the most reliable and amazing approach of setting up an nginx server…and trust me…i am looking around for a while.
I have followed each step and must admit that i struggled a little when setting up pagespeed and naxsi because of no documentation, but found solutions thru the web.
I can provide some handpicked pagespeed-configs if you’d like to integrate them in your examples. Let me know if that’s interesting.
My next step is to install different php versions (5.6, 7,0 7.1) and be able to switch between them in server blocks. Any idea how to achieve that without facing big troubles?
HHVM is also worth noticing and might be a good idea to integrate in your installers. What do you think?