Updated: v1.3.13 – Changes
Inspiration comes from my previous post, my friend, and lnmp.org. Nginx Auto Installer with PHP and MySQL plus additional modules and apps with the current latest packages.
Why only CentOS? You know Debian or Ubuntu will consume less memory, right?
Of course not, starting from version 1.3.9 i’ve added Auto Installer for Debian 6.0 Squeeze and Ubuntu 10.10 Maverick, i was trying to make the Auto Installer for Ubuntu Lucid, but i found that Lucid template has a bug which makes the box cannot boot / reboot. However, since i’ve just learned about Debian and Ubuntu, the Auto Installer for both could be not working properly, so i really need your help to report if there’s any error during installation process.
So what are the differences between this auto installer and the others?
I don’t know, maybe the differences are only in structures and sources, also this new version is built from source and using a few latest modules, so it will take a little bit longer for installation process than the previous version. Here are the provided apps and modules:
- NginX 1.1.18 & 1.0.14
- PHP 5.3.10 with PHP-FPM (Latest 5.3.x , faster for processing php script)
- MySQL 5.5.22
- phpMyAdmin 3.4.10.2
- ionCube PHP Loader 4.0.14
- Alternative PHP Cache (APC) 3.1.9
- eAccelerator 0.9.6.1
- XCache 1.3.2
- Suhosin Extension 0.9.33
- Imagick 3.0.1 (Optional)
- FFMPEG 0.6.0 (Optional)
- PureFTPD 1.0.36 (Optional)
- Latest WordPress (Additional)
Preparation
Before you’re going to install it, set your domain a record in your domain control panel
Type Host Target a record * Your IP address a record domain.com Your IP address a record www.domain.com Your IP address
If you want to use name server instead of ip based / public dns please check:
Setting Nameserver Based For Domain
Download and Unpack the auto installer
wget http://serversreview.net/pkgs/nginxauto-1.3.13.zip unzip nginxauto-1.3.13.zip
or browse it via github
https://github.com/2298/NginX-Auto-Installer/downloads
Make the scripts executable
chmod +x centos.sh debuntu.sh vhost.sh
optional: create an installation log first before you start the installation process, so if there’s any error it would be easier to detect. If the installation is not complete or goes wrong, please send the log file to: log [att] serversreview.net
script log.txt
after the installation has finished, type
exit
and it will generate ‘log.txt’ file
Install master script on a fresh OS box
For CentOS 5 (If you’re already using the previous version, the script will ask if you want to upgrade your current NginX version.)
./centos.sh
For Debian 6.0 and Ubuntu 10.10
./debuntu.sh
Add / Remove Domain
./vhost.sh
Main Apps Init command
Nginx
/etc/init.d/nginx { start | stop | restart }
PHP-FPM
/etc/init.d/php-fpm { start | stop | restart }
MySQL
/etc/init.d/mysql { start | stop | restart }
How much memory it consumes?
Well, i’ve tested this script in 4 different vps location and most of them eat about 50MB to 80MB on idle condition (without bind), here’s the status from 2 vps:
256MB XEN CentOS 5.5 (idle)
[root@server2 ~]# top
top - 04:36:56 up 3 days, 6:11, 1 user, load average: 0.00, 0.02, 0.04
Tasks: 113 total, 4 running, 109 sleeping, 0 stopped, 0 zombie
Cpu(s): 0.0%us, 0.0%sy, 0.0%ni,100.0%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
Mem: 262144k total, 187040k used, 75104k free, 7324k buffers
Swap: 262136k total, 1780k used, 260356k free, 110464k cached
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
1 root 15 0 10352 236 204 S 0.0 0.1 0:00.09 init
2 root RT -5 0 0 0 S 0.0 0.0 0:00.20 migration/0
3 root 34 19 0 0 0 S 0.0 0.0 0:00.08 ksoftirqd/0
4 root RT -5 0 0 0 S 0.0 0.0 0:00.00 watchdog/0
5 root 10 -5 0 0 0 S 0.0 0.0 0:00.00 events/0
6 root 10 -5 0 0 0 S 0.0 0.0 0:00.00 khelper
7 root 12 -5 0 0 0 S 0.0 0.0 0:00.00 kthread
9 root 10 -5 0 0 0 S 0.0 0.0 0:00.00 xenwatch
10 root 10 -5 0 0 0 S 0.0 0.0 0:00.00 xenbus
15 root RT -5 0 0 0 S 0.0 0.0 0:00.29 migration/1
16 root 34 19 0 0 0 S 0.0 0.0 0:00.00 ksoftirqd/1
17 root RT -5 0 0 0 S 0.0 0.0 0:00.00 watchdog/1
18 root 10 -5 0 0 0 S 0.0 0.0 0:00.00 events/1
19 root RT -5 0 0 0 S 0.0 0.0 0:00.17 migration/2
20 root 34 19 0 0 0 S 0.0 0.0 0:00.00 ksoftirqd/2
21 root RT -5 0 0 0 S 0.0 0.0 0:00.00 watchdog/2
22 root 10 -5 0 0 0 S 0.0 0.0 0:00.00 events/2
23 root RT -5 0 0 0 S 0.0 0.0 0:00.22 migration/3
[root@server2 ~]# free
total used free shared buffers cached
Mem: 262144 186748 75396 0 7332 110456
-/+ buffers/cache: 68960 193184
Swap: 262136 1780 260356
256MB OpenVZ CentOS 5.6 (idle)
[root@server5 ~]# top
top - 22:47:41 up 2:34, 1 user, load average: 0.52, 1.14, 0.89
Tasks: 22 total, 1 running, 21 sleeping, 0 stopped, 0 zombie
Cpu(s): 0.0%us, 0.0%sy, 0.0%ni,100.0%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
Mem: 524288k total, 59320k used, 464968k free, 0k buffers
Swap: 0k total, 0k used, 0k free, 0k cached
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
1 root 18 0 2156 672 576 S 0.0 0.1 0:00.16 init
1512 root 19 0 2720 844 672 S 0.0 0.2 0:00.00 xinetd
3556 root 15 0 10988 3828 2272 S 0.0 0.7 0:01.56 sshd
3558 root 15 0 3616 1504 1272 S 0.0 0.3 0:00.02 bash
3599 root 15 0 2832 632 548 S 0.0 0.1 0:00.00 script
3600 root 15 0 2836 408 316 S 0.0 0.1 0:00.56 script
3601 root 15 0 3616 1504 1264 S 0.0 0.3 0:00.02 bash
3850 root 18 0 5684 700 424 S 0.0 0.1 0:00.00 saslauthd
3851 root 18 0 5684 440 164 S 0.0 0.1 0:00.00 saslauthd
3909 root 15 -4 2260 644 432 S 0.0 0.1 0:00.01 udevd
4055 root 15 0 1812 568 480 S 0.0 0.1 0:00.00 syslogd
5134 root 18 0 7200 1032 636 S 0.0 0.2 0:00.00 sshd
5279 root 18 0 4492 1100 556 S 0.0 0.2 0:00.00 crond
9588 root 18 0 3236 676 588 S 0.0 0.1 0:00.00 pure-ftpd
9720 root 18 0 12388 1464 340 S 0.0 0.3 0:00.00 nginx
9721 www 18 0 12672 2412 1008 S 0.0 0.5 0:00.00 nginx
9722 www 18 0 12568 1964 600 S 0.0 0.4 0:00.00 nginx
9726 root 18 0 44976 4564 1420 S 0.0 0.9 0:00.00 php-fpm
[root@server5 ~]# free
total used free shared buffers cached
Mem: 524288 58988 465300 0 0 0
-/+ buffers/cache: 58988 465300
Swap: 0 0 0
I only post two vps(es) status because another two was run out of lease term
also it all depends on your box condition, but i can suggest you to choose XEN rather than OpenVZ to ensure the stability and avoid memory exhausted (run out of memory allocation) during the installation process. Okay you can now try this auto installer and please give some critics or suggestions regarding this auto installer, because i’m planning to keep improving and updating, thank you.
Thanks to
- lnmp.org for beautiful idea about the autoinstaller
- Junker @ vbfk.com for helping me out, you rock!
- Uncle G for free unlimited knowledge gateway
- WebHostingTalk for being my inspiration
- Few useful sites, forums, and wikis plus thousands spam sites that i cannot mention all
Troubleshooting
phpMyAdmin import database connection time out
Most of phpMyAdmin problem happened when importing a large database because by default i only set a few basic configurations so you can set your own configuration based on your needs. Here are the solutions:Location: /etc/init.d/nginx.conf
client_max_body_size 8M client_body_buffer_size 128kMax body size accepted which effecting max upload limit is 8MB with 128kB temporary files written, add/change this value if you need to import database more than 8MB, otherwise you will get “Request Entity Too Large” error.
Location: /usr/lib/php.ini or /usr/lib64/php.ini
memory_limit = 256M post_max_size = 8M upload_max_filesize = 8MMaximum memory usage during processing php script is 256MB, post_max_size value is nearly equal with NginX client_max_body_size, and upload_max_filesize is the upload size limit setting.
Location: /usr/html/yourphpmyadminfoldername/config.inc.php
$cfg['ExecTimeLimit'] = '0';Add the above line to phpMyAdmin configurations to disabled execution time limit.
Location: /etc/php-fpm.conf
pm.max_children = 20This setting is optional, but it is good if you’re increasing children worker to optimize php script process.
Cannot Login phpMyAdmin
You may get this error when trying to login to phpMyAdmin
#2002 Cannot log in to the MySQL server
Connection for controluser as defined in your configuration failed.Solution:
edit config.inc.php and change localhost with 127.0.0.1
/strong/strong

TestWeb
April 3, 2012 • 3:17 amHello,
I had installed the script successfully on CentOS 5.8 OpenVZ VPS ,but I have a question related to DNS
My Domain name is registered from NetFirms.Com
In my Control Panel I should direct my domain to 2 Nameservers at least ,e.g: ns1.mywebsitedomain.com ns2.mywebsitedomain.com
although I had assigned the A record to my server’s IP, I must add the correct nameservers to the domain control panel.
I ‘ll be waiting for your reply.
—-
Many Thanks.
2298
April 3, 2012 • 3:24 amHello,
It seems that you’re using a record instead of your private nameserver, if so you should add:
ns1.yourregistrarnameserver.com
ns2.yourregistrarnameserver.com
ns3.yourregistrarnameserver.com
ns4.yourregistrarnameserver.com
in your domain control panel (not ns1.yourdomainname), and then assign your ip address to a record (dns management) in your domain control panel.
Hope it helps.
————————————-
Anyway NginX Auto Installer for CentOS 6 will be released in the near future, and then (probably) for Ubuntu 11.10 (Oneiric Ocelot)
TestWeb
April 3, 2012 • 9:28 amHello,
1- Yes, I am using a record, How to use my private nameserver?
2- How to add another database for the same domain?
3- How to make this server to be secured?
4- If I search for the server’s Type, I ‘ll get it written Nginx ,How to changes this name to any other statement?
Many Thanks.
2298
April 4, 2012 • 12:51 am1. You can use bind or nsd, i’m currently using bind and webmin to create it, you can check it here
2. Use phpMyAdmin or CLI
3. You can do stuffs from wht thread here
4. I still don’t get about this question you ask, could you please be more detail?
TestWeb
April 3, 2012 • 8:54 amHello,
Thanks. This worked well
and I am able to start my wordpress website, Please if you can tell me how to add another database for the same domain ?
Many Thanks.
2298
April 4, 2012 • 12:46 amTo add database you can use phpMyAdmin at http://youripaddress/yourphpmyadmindirname or you can login as mysql root user in cli.
miki
April 4, 2012 • 9:51 pmHi,
What is wrong here http://pastebin.com/jLkddhZL ?
i clean before installing apache php mysql
apt-get remove apache2*
apt-get remove php*
….
Reboot, and fresh install with NAI.
2 installs same issue.
2298
April 4, 2012 • 9:58 pmHi, what virtualization and OS did you use anyway? And how much memory does your box have?
miki
April 5, 2012 • 5:46 amI use Debian x64 / 128 MB
miki
April 5, 2012 • 11:41 amOpenVS | 128 Memmory | Debian x64
2298
April 6, 2012 • 4:17 ami suspect that memory exhaust is the problem when installing php
miki
April 6, 2012 • 6:40 pmSolved, memmory was the problem too low, but work fine with x32 and 128mb.
Adam
April 6, 2012 • 2:52 amHi
i am new to web server thing
i have installed nginx and connected my domain,it run very smooth actually
BUT the new problem came when myfriend ask for a space for his simple blog,since my box can run a bit longer i accept his challenge
i do exactly like this
http://articles.slicehost.com/2008/5/16/ubuntu-hardy-nginx-virtual-hosts
and for the domain(my friend domain) i do the same setup as my domain,setting ns to default,point A to my server’s IP
but it still dont load a bit!!
am i missing something???
2298
April 6, 2012 • 4:21 amHi,
I’m confused about your problem because i don’t see your setting, but if it still don’t load then the problem maybe from server_name ip_address; tag in virtual host.
Adam
April 6, 2012 • 4:50 amHere is my nginx.conf
http://pastebin.com/kgGPdYD0
for site-enable,here is for my friend domain (mine is fine)
http://pastebin.com/7HCsvWwK
i think i am missing something for DNS
is it right to use same configuration like the first domain,just use the default ns,and point A adress directly to VPS?
thank you very much
Adam
April 6, 2012 • 4:53 amoh,and i found this too on site-enable,its default
http://pastebin.com/kgGPdYD0
2298
April 9, 2012 • 9:50 pmnothing wrong with the conf, and yes you’re also correct about dns setting, i’m a bit confused if i’m not looking directly to your box.
miki
April 6, 2012 • 6:43 pmvhost.sh , is not available in v1.3.13 ?
or work to use without problems vhost.sh from v1.3.12 or need to be updated for v1.3.13 ?
To use vhost.sh is a easy mode for beginer to create virtual hosts.
2298
April 9, 2012 • 9:59 pmare you sure about that? please check again the package in v1.3.13, i’ve included vhost.sh in the zip file.
ashique
April 12, 2012 • 5:48 pmi have an issue, i am around 23rd day about this matter, I installed nginx using justincarmony.com/blog/2011/10/24/setting-up-nginx-php-fpm-on-ubuntu-10-04/ , Worked fine, Google listed my website, it is fast. But timthumb not working with nginx, i installed apache with fcgid with another vps, found working , with modern wordpress theme.
while checking long time, i found that there is no php-fpm.conf file in my system, not generated automatically,
Should i neeed to install this script, or just a php-fpm.conf can solve this, if yes, kindly give me default php-fpm.conf file.
2298
April 12, 2012 • 9:04 pmso the problem is no php-fpm.conf in your box? have you tried to search it using slocate?
#apt-get install slocate
or
#apt-get install mlocate
#updatedb
#locate php-fpm.conf
for php-fpm.conf file you can get it from php source, download it from php.net, /sapi/fpm/php-fpm.conf if i’m not wrong.
TestWeb
April 12, 2012 • 11:50 pmFor this error: Gate Way Time Out / Nginx
how to change this error message ?
2298
April 13, 2012 • 12:29 amdid you mean change the message or solve the gateway timeout?
TestWeb
April 13, 2012 • 4:45 pmIf you can tell me both of them?
TestWeb
April 14, 2012 • 4:07 amBoth of them, how to change the message and how to solve the gateway timeout.
2298
April 15, 2012 • 7:32 pmgateway timeout caused by fastcgi when processing a large data, as i said before the settings (php.ini, ngx.conf, php-fpm.conf) i’ve included are only basic settings, you can raise the value of client_header_timeout, client_body_timeout, and send_timeout in nginx.conf, after that restart nginx and see the differences.
for gateway timeout message i’m sorry i don’t have any idea how to change it.
Ashique Zakariyya
April 13, 2012 • 2:30 ami have used ur script, worked fine
if a new version of nginx released, how i update it, Will you add a update script to ur programm
2298
April 13, 2012 • 3:18 amthe script contains new update of nginx each time i’m updating this script, it will automatically detect and ask you to update without reinstalling all functions, however, i don’t follow every nginx update because it is too fast.
Ashique Zakariyya
April 13, 2012 • 3:12 amcould you help by giving rewrite setting for wordpress
2298
April 13, 2012 • 3:18 amyou can use vhost.sh, it includes nginx rewrite setting for wordpress
ashique
April 13, 2012 • 10:49 pmi accedentally upgraded to nginx 1.1.18 develoment version, Is there any issue by installing dev version, Also 1.1.19 lounged now, ..
i have installed eaccelerator, i like to install apc also, anyway can i do it with your script. it is very awsome.
i also like to install imagemagick for vbulletin and FFMPEG for religious brodcasting purpose, can i install it with your script.
i want to keep all my setting, didnt like to remove whole thing HELP HELP
miki
April 25, 2012 • 8:33 am2012-04-23
nginx-1.2.0 stable version has been released.
ashique
April 13, 2012 • 11:01 pmYou are raeally active person, Thanks
i found w3 total cache is best one than wp-supercache.
it has many features, and easy. including minify
i cant succeed it with nginx and wordpress, can u help,they says that it support nginx officially, but found much css, js minify issue, including rewrite files for cache,i given config file access for w3c for auto configure, but it fails.
wp-super cache not support db cache, opcode cache etc
2298
April 15, 2012 • 7:29 pmyou may want to look at these links:
http://wordpress.org/support/topic/plugin-w3-total-cache-nginx-support-status
http://wordpress.org/support/topic/plugin-w3-total-cache-nginx
http://devilsworkshop.org/nginx-rewrite-rules-for-w3-total-cache-plugin
thinkevd
April 21, 2012 • 1:13 amIs there a script can uninstall the nginx-auto? or how to remove it manually?
2298
April 21, 2012 • 8:18 amthe quick way is reinstalling your os, but if you dont want to do that then you can just stop the service of ngx php mysql and remove them from init
miki
April 25, 2012 • 8:29 amI have a VPS like this:
CPU: 1core @ 3.16Ghz
RAM: 512
OS: Debian 6 x64
My question is:
Is ok if I will use “use epoll;
multi_accept on;” on Nginx config ?
On my VPS run a forum with min 100 Users online, and the number increase in every month, maybe at the end of year i will have 500 Users online.
2298
April 25, 2012 • 8:10 pmyou can use any settings in nginx.conf, for 100 or 500 users online at the same time i don’t know because i only include basic settings in this auto installer, but you can try to increase nginx child process and php-fpm values configuration.
Alex
April 25, 2012 • 8:36 amHow i can upgrade nginx to stable version 1.2.0 from 1.1.8 ?
2298
April 25, 2012 • 8:11 pmi’ll include 1.2.0 update on the next release
khafi
April 30, 2012 • 5:09 pmmas..
kalo saya mau assign ip lebih dari satu…
misal web a ipnya 1.1.1.2
web b ipnya 2.2.2.1
itu yg perlu di setting yg mananya…
Terimakasih atas jawabannya..
2298
May 1, 2012 • 10:57 pmset these in your domain dns configuration:
- type: a record, host: domain a, record answer: 1.1.1.2
- type: a record, host: domain b, record answer: 2.2.2.1
and you’re all set
Loul
May 1, 2012 • 6:44 pmThanks for your work!
Please, make a new release, because there is a new version of PHP, nginx and others…
2298
May 1, 2012 • 10:57 pmwill do in a few days, thank you.
Loul
May 1, 2012 • 6:51 pmAlso, I get this error in PhpMyAdmin :
Connection for controluser as defined in your configuration failed.
And PhpMyAdmin is only in English, it will be great if it can be available in others languages.
2298
May 1, 2012 • 10:59 pmedit your phpmyadmin configuration, find $cfg['Servers'][$i]['host'], change the 127.0.0.1 with localhost or vice versa