Page 1 of 11 1234 ... LastLast
Results 1 to 25 of 266
  1. #1
    Join Date
    Oct 2008
    Posts
    637

    Smile Debian/Ubuntu LAMP and LNMP setup script

    Hello everyone,

    I've been testing and setting up various kinds of webserver configurations lately, and realized that it would save me a lot of time if I had a script to automatically do a base install" whenever I spin up a fresh new server to benchmark. Had a some spare time this afternoon so I wrote one(two) scripts and figured others might find it useful somehow.

    I know there are many low footprint install scripts around like the lowendbox's lowendscript and Centmin posted a few months back. But being a Debian person myself, I prefer Apache over nginx and none of the scripts offer the Debian + Apache combo.

    Anyway, lets get down to details. The scripts automatically sets up the following :-

    Serversetup Script http://tuxlite.com

    - Basic server configuration such as setting the hostname, SSHD ports etc.
    - Choice of 3 LAMP setups (switching setup from 1 to 2 or 3 works fine, but I've not tested the other way round)
    1. mpm_prefork + mod_php
    2. mpm_worker + mod_fcgid
    3. mpm_worker + mod_fastcgi + PHP-FPM

    - Optimizes LAMP config for low memory usage.
    - Extra options to setup rtorrent and cronjobs for backups

    Domainsetup Script http://tuxlite.com

    - Quickly add a domain to Apache virtualhost config
    - Setup awstats + phpmyadmin for each domain with daily log rotation
    - Option to remove domain from server


    To use the scripts, download them and make them executable. E.g.

    Code:
    wget http://tuxlite.com
    chmod +x serversetup.sh
    ./serversetup.sh


    Why Use These Scripts?


    - Setup server, add your domain, set your DNS and you'll be hosting sites within minutes.
    - Memory usage is ~50MB under Xen or KVM using mpm_worker setup.
    - Apache mpm-worker config gives comparable/adequate performance to nginx for most situations. Setup is also compatible with the latest mpm-event module as well.
    - ALL packages are from official Debian repositories, therefore configurations are standard and its easy to keep your server updated
    - Functions are coded in simple "english", and some personal preferences of mine are commented out to keep installs as stock as possible. You can easily configure the functions to your liking.


    Who Should Use These Scripts?

    - Debian 6 users. Scripts will work with Debian 5 (lenny) as well, but remember to change sources.list to oldstable or lenny if you are using the script to reconfigure apt.
    - Those using VPS to host personal sites, and do not require multi user / shared hosting environment.
    - People who are lazy like me and wants things automated
    - People who loves messing about with various LAMP stacks because Apache is win and life is meaningless without .htaccess support
    - You are l33t and prefer not to use control panels with pretty GUIs



    Bear in mind that my shell scripting skills are anything but good, and some of the code is adapted from various sources.
    So if you find something off do let me know and I'll update the scripts accordingly.
    Last edited by Quartz; 04-27-2011 at 03:45 AM.


    Tuxlite.com Complete LAMP and LNMP script for Debian and Ubuntu.

  2. #2
    Join Date
    Apr 2009
    Posts
    481
    Thanks, what an excellent contribution!!

    I just deployed a "lampworker" configuration in 3m19s including interactive parts and it seems to have worked very nicely straight out-of-the-box

    One one warning:
    Code:
    By default, MySQL comes with a database named 'test' that anyone can
    access.  This is also intended only for testing, and should be removed
    before moving into a production environment.
    
    Remove test database and access to it? [Y/n] 
     - Dropping test database...
    ERROR 1008 (HY000) at line 1: Can't drop database 'test'; database doesn't exist
     ... Failed!  Not critical, keep moving...
    Exceptional VPS Hosting. With love, 6sync.

  3. #3
    Join Date
    Oct 2008
    Posts
    637
    Welcome!
    For the mysql issue, its probably because Debian packages mysql without the "test" database. The warning message can be ignored.

    Quote Originally Posted by RavC View Post
    Thanks, what an excellent contribution!!

    I just deployed a "lampworker" configuration in 3m19s including interactive parts and it seems to have worked very nicely straight out-of-the-box

    One one warning:
    Code:
    By default, MySQL comes with a database named 'test' that anyone can
    access.  This is also intended only for testing, and should be removed
    before moving into a production environment.
    
    Remove test database and access to it? [Y/n] 
     - Dropping test database...
    ERROR 1008 (HY000) at line 1: Can't drop database 'test'; database doesn't exist
     ... Failed!  Not critical, keep moving...


    Tuxlite.com Complete LAMP and LNMP script for Debian and Ubuntu.

  4. #4
    Join Date
    Oct 2008
    Posts
    637
    Made some changes to the script to fix some (harmless) typos.
    Anyone using the scripts before this reply should download them again


    Tuxlite.com Complete LAMP and LNMP script for Debian and Ubuntu.

  5. #5
    Join Date
    Jan 2011
    Location
    Canada
    Posts
    938
    Might want to stick suhosin in there. I feel so naked without it But thanks for sharing!

  6. #6
    Join Date
    Mar 2010
    Posts
    4,533
    Does this happen to secure /tmp etc? That would be a great feature to have.


    I have always wanted to use debian with a major website but I wanted to test centmin first. Now that the owner has disappear from the forum and the latest update was to my disliking I am stuck with it since the server has about 100gb of data on it that cannot be backed up.

    Although, I am thinking it is time to dump the 100gb of data just to try this

  7. #7
    Join Date
    Oct 2008
    Posts
    637
    Quote Originally Posted by tchen View Post
    Might want to stick suhosin in there. I feel so naked without it But thanks for sharing!
    Both the suhosin source patch and the extension is installed by default Debian PHP package. Fire up a phpinfo page and you'll see it loaded


    Quote Originally Posted by techjr View Post
    Does this happen to secure /tmp etc? That would be a great feature to have.

    I have always wanted to use debian with a major website but I wanted to test centmin first. Now that the owner has disappear from the forum and the latest update was to my disliking I am stuck with it since the server has about 100gb of data on it that cannot be backed up.

    Although, I am thinking it is time to dump the 100gb of data just to try this
    Just added two new options to secure /tmp. I didn't include it earlier because securing /tmp can be very machine specific, especially if you plan to run stuff like eaccelerator that needs huge cache directories. Be sure to know what you're doing before copy-pasting codes from the interwebs.

    As for your data, why not rsync it to a backup server and move them back after you're done setting up? That's a lot of data to lose


    Tuxlite.com Complete LAMP and LNMP script for Debian and Ubuntu.

  8. #8
    Join Date
    Feb 2004
    Location
    Sacramento CA
    Posts
    3,513
    Great script! Have you done any performance tests to see how the different options scale with traffic? I'm going to see if any of my test hosts offer Deb 6 and run them through loadimpact and compare it to some of the php/Nginx setups, but ~50MB is really sweet for Apache. Good job!

  9. #9
    Join Date
    Oct 2008
    Posts
    637
    On memory/cpu limited VPS, I find that the mpm-worker (option 2 or 3) config scales much better, especially with concurrent connections. The config that I use for the script is very conservative and will only use ~100MB memory on full load. However it should have no problems handling >50 req/sec for a wordpress site. >200 req/sec if using supercache and I'm getting up to 2000 req/sec when I place varnish in front of it all. This is on a 1CPU 512mb test box.

    Though if you have massive amount of RAM and CPU allocation, the vanilla LAMP stack with mpm-prefork should in theory be slightly faster.

    It will work with Debian 5 if you don't select the php-fpm option, or else the sources.list needs to be edited because it assumes a Debian 6 OS.


    Tuxlite.com Complete LAMP and LNMP script for Debian and Ubuntu.

  10. #10
    Join Date
    Dec 2007
    Posts
    235
    Great stuff : ). Would be great if you could include Varnish part too (or separate script maybe? ) in future..

    WHere can I donate?

  11. #11
    Join Date
    Mar 2010
    Posts
    4,533
    Quote Originally Posted by Scientist View Post
    On memory/cpu limited VPS, I find that the mpm-worker (option 2 or 3) config scales much better, especially with concurrent connections. The config that I use for the script is very conservative and will only use ~100MB memory on full load. However it should have no problems handling >50 req/sec for a wordpress site. >200 req/sec if using supercache and I'm getting up to 2000 req/sec when I place varnish in front of it all. This is on a 1CPU 512mb test box.
    I know some of the other scripts (CentOS) are getting an extreme amount of requests per second. It would be cool if you could include a secondary script that tweaks server settings as traffic grows to better manage to load. Such as installing varnish.

    Quote Originally Posted by Scientist View Post

    As for your data, why not rsync it to a backup server and move them back after you're done setting up? That's a lot of data to lose
    Gave away my backup type vps after a buddy's host got shut down. I guess I will download it to my hard drive and then take the drive to a local data-center and borrow there connection (They allow it for a small fee)

  12. #12
    Join Date
    Oct 2008
    Posts
    637
    Quote Originally Posted by Amar View Post
    Great stuff : ). Would be great if you could include Varnish part too (or separate script maybe? ) in future..

    WHere can I donate?
    Quote Originally Posted by techjr View Post
    I know some of the other scripts (CentOS) are getting an extreme amount of requests per second. It would be cool if you could include a secondary script that tweaks server settings as traffic grows to better manage to load. Such as installing varnish.
    Just added another 2 functions to quickly turn varnish on and off. As usual just re-download the scripts from the same links.

    My test box is hitting 8000 req/sec for phpinfo. Do post your results as well if you folks are doing any benchmarks.


    Tuxlite.com Complete LAMP and LNMP script for Debian and Ubuntu.

  13. #13
    Join Date
    Mar 2010
    Posts
    4,533
    Quote Originally Posted by Scientist View Post
    Just added another 2 functions to quickly turn varnish on and off. As usual just re-download the scripts from the same links.

    My test box is hitting 8000 req/sec for phpinfo. Do post your results as well if you folks are doing any benchmarks.
    This has massive potential, I would get a site setup and get a community going myself. I see it doing great for the average unmanaged user with little to no experience who are running a single forum and such.

    Do you recommend lamp setup #2 or #3? Also, may I share this with others? If so do you have any places I may link to in order to provide you the credit of making it?

  14. #14
    Join Date
    Oct 2008
    Posts
    637
    Quote Originally Posted by techjr View Post
    This has massive potential, I would get a site setup and get a community going myself. I see it doing great for the average unmanaged user with little to no experience who are running a single forum and such.

    Do you recommend lamp setup #2 or #3? Also, may I share this with others? If so do you have any places I may link to in order to provide you the credit of making it?
    I'd go with setup #2 because its a safe config, as in you can swap #1 and #2 repeatedly as you wish without breaking anything.

    Setup #3 is the "better" way of using PHP, but using experimental packages means you don't get timely security updates. I'd personally only use this setup to test out PHP-FPM's features and nothing more. Also once you go option #3, its much harder to revert back to #1 or #2.

    And sure, go ahead and share this with anyone, I've posted it in public after all Linking back here will be best until I find a more suitable place to host the scripts. Unless of course WHT mods give me access to edit my first post.
    If you find it useful and want to treat me coffee, I'd be happy to oblige


    Tuxlite.com Complete LAMP and LNMP script for Debian and Ubuntu.

  15. #15
    Join Date
    Mar 2010
    Posts
    4,533
    I just ran the lampworker install on a new server... It said leave the mysql password blank if I did not have it setup, but I am getting access denied. Any ideas?


    Also running ./serversetup.sh basic it would be nice if it told you what the ssh port was changed to. Although not needed it makes it easier to see what it is right off the bat.

    Using the add user command shows "Current Kerberos password:"
    Last edited by techjr; 02-23-2011 at 06:15 PM.

  16. #16
    Join Date
    Mar 2010
    Posts
    4,533
    Quote Originally Posted by techjr View Post
    I just ran the lampworker install on a new server... It said leave the mysql password blank if I did not have it setup, but I am getting access denied. Any ideas?


    Also running ./serversetup.sh basic it would be nice if it told you what the ssh port was changed to. Although not needed it makes it easier to see what it is right off the bat.

    Using the add user command shows "Current Kerberos password:"
    Can no longer edit my post.

    Ignore this, it never saved the edited file. Before running the script. My fault

  17. #17
    Join Date
    Oct 2008
    Posts
    637
    Those parameters must be set first by editing the script variables. Look at the line at the beginning that says

    #Edit values below before using script

    Looks like you ran the script using the default values so your mysql password would be abcd1234 and the ssh port is 1234.


    Tuxlite.com Complete LAMP and LNMP script for Debian and Ubuntu.

  18. #18
    Join Date
    Oct 2008
    Posts
    637
    And oh before I forget, need to thank RavC for helping to make the script readable


    Tuxlite.com Complete LAMP and LNMP script for Debian and Ubuntu.

  19. #19
    Join Date
    Mar 2010
    Posts
    4,533
    All issues are fixed besides one... Whats the Current Kerberos password: ?

    I have never seen this used before. Seems to be on though haha.

    I always have issues with these scripts for some reason but once I learn them it saves me tons of time.
    Last edited by techjr; 02-23-2011 at 08:56 PM.

  20. #20
    Join Date
    Oct 2008
    Posts
    637
    That is unusual, did you run the script on a fresh Debian 5/6 OS? The scripts doesn't have a "install kerberos" function at all.

    Unless... if you accidently used the "apt" function, it may have pulled that package from Sid repos. If thats the case try removing the package using the command below :-

    aptitude purge libpam-krb5


    Tuxlite.com Complete LAMP and LNMP script for Debian and Ubuntu.

  21. #21
    Join Date
    Mar 2010
    Posts
    4,533
    Quote Originally Posted by Scientist View Post
    That is unusual, did you run the script on a fresh Debian 5/6 OS? The scripts doesn't have a "install kerberos" function at all.

    Unless... if you accidently used the "apt" function, it may have pulled that package from Sid repos. If thats the case try removing the package using the command below :-

    aptitude purge libpam-krb5
    Works thanks. I also installed a few extra packages so it may be a borked template with my new host.

  22. #22
    Join Date
    Oct 2008
    Posts
    637
    Quote Originally Posted by techjr View Post
    Works thanks. I also installed a few extra packages so it may be a borked template with my new host.
    No prob, glad its working

    I updated the script menu to give more info about the "apt" function. Its optional so not everyone needs to use it. I hope you didn't execute ALL of the available functions


    Tuxlite.com Complete LAMP and LNMP script for Debian and Ubuntu.

  23. #23
    Join Date
    Mar 2010
    Posts
    4,533
    Quote Originally Posted by Scientist View Post
    No prob, glad its working

    I updated the script menu to give more info about the "apt" function. Its optional so not everyone needs to use it. I hope you didn't execute ALL of the available functions
    On one server I did. On my proper vps I ran two commands and thats it. I like to see what happens when the wrong things are done


    Anyways it is now working great but using 433 mb of ram just running the script the secures the ports and lamp stack #2 - Running openvz but it should not make that much of a difference vs xen.

    Code:
                                               CPU  MeM
    25836 mysql     15   0  152m  17m 5428 S    0  1.7   0:00.12 mysqld
    24500 root      18   0  9396 5064 3320 S    0  0.5   0:00.22 apache2
     5267 root      16   0  8320 2820 2292 S    0  0.3   0:00.10 sshd
     3528 root      16   0  8320 2788 2264 S    0  0.3   0:00.08 sshd
    26256 root      18   0  5772 1852 1500 S    0  0.2   0:00.01 master
    26266 postfix   18   0  5832 1812 1464 S    0  0.2   0:00.00 qmgr
    26268 postfix   15   0  5788 1776 1436 S    0  0.2   0:00.01 pickup
    Not really a big deal but just in-case you wanted to see the memory usage that others are having.
    Last edited by techjr; 02-23-2011 at 10:48 PM.

  24. #24
    Join Date
    Oct 2008
    Posts
    637
    Quote Originally Posted by techjr View Post

    Anyways it is now working great but using 433 mb of ram just running the script the secures the ports and lamp stack #2 - Running openvz but it should not make that much of a difference vs xen.

    Code:
                                               CPU  MeM
    25836 mysql     15   0  152m  17m 5428 S    0  1.7   0:00.12 mysqld
    24500 root      18   0  9396 5064 3320 S    0  0.5   0:00.22 apache2
     5267 root      16   0  8320 2820 2292 S    0  0.3   0:00.10 sshd
     3528 root      16   0  8320 2788 2264 S    0  0.3   0:00.08 sshd
    26256 root      18   0  5772 1852 1500 S    0  0.2   0:00.01 master
    26266 postfix   18   0  5832 1812 1464 S    0  0.2   0:00.00 qmgr
    26268 postfix   15   0  5788 1776 1436 S    0  0.2   0:00.01 pickup
    Not really a big deal but just in-case you wanted to see the memory usage that others are having.

    400MB sounds about right for OpenVZ, and yes the difference can be that big if you don't use Xen/KVM. If you look at the mysql memory usage, its taking up 152MB while Xen/KVM would only use 17MB.

    Delete the serversetup.sh script, download it again. Then run optimizelamp function. Should drop your memory usage by 100MB or so. I've just edited mysql tuning part a little bit.

    Of course a long term solution would be to avoid OpenVZ entirely


    Tuxlite.com Complete LAMP and LNMP script for Debian and Ubuntu.

  25. #25
    Join Date
    Mar 2010
    Posts
    4,533
    Quote Originally Posted by Scientist View Post
    400MB sounds about right for OpenVZ, and yes the difference can be that big if you don't use Xen/KVM. If you look at the mysql memory usage, its taking up 152MB while Xen/KVM would only use 17MB.

    Delete the serversetup.sh script, download it again. Then run optimizelamp function. Should drop your memory usage by 100MB or so. I've just edited mysql tuning part a little bit.

    Of course a long term solution would be to avoid OpenVZ entirely
    Thats odd. The centmin script was running about 70mb ram but was also nginx and included mysql.
    used free shared buffers cached
    67 188 0 0 0
    67 188

    It is now using 329 memory after running the optimizer. Although the memory usage is higher then it should be for some odd reason I must say pages load AMAZINGLY FAST, compared to most scripts or guides found online. I ran a test site and websites loaded over 35% faster using the identical script and server vs a standard lamp install. Reverting back to a centos install using centmin or the lowend box actually had about a 45% slower load speed then this lamp setup script for me.
    Last edited by techjr; 02-23-2011 at 11:36 PM.

Page 1 of 11 1234 ... LastLast

Similar Threads

  1. CentOS or Ubuntu or Debian
    By Host4Geeks in forum Hosting Software and Control Panels
    Replies: 26
    Last Post: 08-24-2010, 04:50 AM
  2. Seems Debian BETTER than CentOS for LNMP VPS?
    By 21andy in forum VPS Hosting
    Replies: 8
    Last Post: 02-24-2010, 03:20 AM
  3. Debian Server - Professional LAMP Setup, Optimization + Hardening Needed
    By Netarch in forum Systems Management Requests
    Replies: 5
    Last Post: 07-16-2008, 11:49 AM
  4. Any decent guides for chrooting apache2 in ubuntu lamp installation?
    By Georgecooldude in forum Hosting Security and Technology
    Replies: 2
    Last Post: 05-12-2008, 06:42 PM
  5. Hassle Free CentOS/Ubuntu LAMP install disc?
    By RobinWrit in forum Colocation, Data Centers, IP Space and Networks
    Replies: 2
    Last Post: 03-05-2008, 01:58 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •