Quote:
Correct me if I am wrong do I need to install apache server on ubuntu server or does ubuntu server comes with apache?
You might want to install lighttpd instead of apache, depending on how much memory your linode account has, as it uses less RAM.
Steps
1. Firewall
Code:
# apt-get install arno-iptables-firewall
The installation will prompt you for the ports to enabled. Ports you may want to enable:
- 7 echo (for ping)
- 22 ssh
- 25 smtp
- 80 http
- 110 pop3
- 143 Imap
- 443 https
- 993 Imap over ssl/tls
- 995 pop3 over ssl/tls
- 3306 mysql
2. Create a script, say,
~/firewall-stop to flush all iptables rules (just in case you need it).
Code:
#!/bin/bash
echo "Stopping firewall and allowing everyone..."
iptables -F
iptables -X
iptables -t nat -F
iptables -t nat -X
iptables -t mangle -F
iptables -t mangle -X
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT
Code:
# sudo chmod u+x ~/firewall-stop
You can execute it
Code:
# sudo ~/firewall-stop
if you get locked out, from the linode console java applet (without needing to ssh).
3. Install lighttpd
Code:
# aptitude install lighttpd
4. Either create a file uploads directory for
lighttpd or set
upload_tmp_dir in php.ini and create the directory, setting the group to www-data (chgrp) and setting the permissions appropriately. This step is not needed as of lighttpd 1.4.19 and above.
Code:
# mkdir /var/cache/lighttpd/uploads
# chgrp –R www-data /var/cache/lighttpd/uploads
# chmod g+rw /var/cache/lighttpd/uploads
5. Enable
fastcig and
auth modules
Code:
# lighty-enable-mod fastcgi auth
6. Install php and phpmyadmin
Code:
# aptitude install php-cgi php5-cli php-db php-pear php5-gd php5-mcrypt php5-mysql php5-xcache phpmyadmin
7. Create the ‘recommended’ php.ini
Code:
# cp /usr/share/doc/php5-common/examples/php.ini-recommended /etc/php5/cgi/php.ini
8. Configure fast-cgi
Code:
fastcgi.server =
(
".php" => (( "bin-path" => "/usr/bin/php-cgi -c /etc/php5/cgi/php.ini",
"socket" => "/tmp/php.socket",
"max-procs" => 1,
"idle-timeout" => 20,
"bin-environment" => ( "PHP_FCGI_CHILDREN" => "4", "PHP_FCGI_MAX_REQUESTS" => "10000" ),
"bin-copy-environment" => ( "PATH", "SHELL", "USER" ),
"broken-scriptfilename" => "enable"
))
)
See
Lighttpd and PHP configuration for more information.
max-procs = 1 is recommended is using an php op code cacher.
9. Install php op code cacher xcache.
Code:
# aptitude install php5-xcache
Encrypt and set the password for the administration page for xcache. See
How to Install XCache Administration Page. You need to encrypt your xcache admin password by creating and running this php script:
Code:
<?php
echo md5("password");
?>
substituting your actuall password for "password". Then edit
/etc/php5/conf.d/xcache.ini and change the lines
Code:
xcache.admin.user = "mOo"
xcache.admin.pass = "5f4dcc3b5aa765d61d8327deb882cf99"
using a user name of your choice and the encrypted password generate from the script above.
10. Set up any virtual hosts for lighttpd (If you have many, then you would want to either enable
simple_vhost or use the built-in
evhost.path-pattern setting in
/etc/lighttpd/lighttpd.conf).
Sampe virtual hosts
Code:
# sudo nano /etc/lighttpd/lighttpd.conf
Code:
$HTTP["host"] =~ "^(www\.)?sampledomain1.com$" {
server.document-root = "/usr/share/phpgedview/"
}
$HTTP["host"] =~ "^(www\.)?someblog.com$" {
server.document-root = "/usr/share/wordpress/"
}
$HTTP["host"] =~ "^(www\.)?sampledomain3.com$" {
server.document-root = "/var/www/sampledomain3.com/"
}
# /etc/init.d/lighttpd force-reload.
=~ signifies a regular expresssion syntax is being used.
Include any aliases in a separate file.
Code:
# sudo nano /etc/lighttpd/myconf.conf
alias.url += ( "/xcache-admin" => "/usr/share/xcache/admin",
"/aptitude" => "/usr/share/doc/aptitude/html/en",
"/apt-doc" => "/usr/share/doc/apt-doc")
Edit
/etc/lighttpd/lighttpd.conf and add the line
Code:
include "myconf.conf"
after the virtual host entries.
11. Set up users and password for any password-protected lighttpd directories. See this guide:
Lighttpd setup a password protected directory12. restart lighttpd
Code:
# /etc/init.d/lighttpd restart