Drawing up a Web Service

So you have a machine setup running which is a server. Your server should have an external IP address. This makes your machine address seekable. An IP v4 would look like 123.45.67.89. Nowadays IPv6 is both applicable. Well, we are not very interested about this here.What we are looking at is DNS. Domain Name Server. There are a few out there such as GoDaddy, Register.com etc. Most are good. Avoid small unknown name servers. The prices are competitive so going to larger companies is the way forward.
Setting up DNS using your Domain Host (such as GoDaddy)
In your domain, just set the IP address to point to your new server IP (given to you by your provider, Rackspace or Amazon. You can do this by going on to the machine and typing

> ifconfig

Setting up DNS using RackSpace’s servers
Some DNS guides at rackspace are rather complicated and hard to manage. I would leave it to using the domain providers or your hosting provider’s DNS system. At rackspacecloud; and i presume most DNS settings have similar setting options, heres how its set:
you need

  • 1x A record [which is IP],
  • 1x CName record [which is www.mydomain.com],
  • 1x MX record [which is mydomain.com; this allows asd@mydomain.com], and thats it.
if you need more sub domains you can add more CNames e.g. abc.mydomain.com

A record

  • Name = mydomain.com;
  • Content = 123.45.67.89; [content is your ip address]
  • TTL = 300;
CName record
  • Name = www.mydomain.com;
  • Content = mydomain.com;
  • TTL = 300;
MX record:
  • Name = mydomain.com;
  • Content = mydomain.com;
  • TTL 300;
  • Priority = 10 [if you use google apps, they will give you a huge list of 6 mx records, I know. its a pain. Enter them all by changing the Content, such as Content = aspx.googlemail.com]
Take a note of TTL which is time to live in seconds. 300 seconds would be 5 minutes. If DNS is changed it will take 5 minutes to propagate throughout the world. Normally people put 84600 which is 24 hours.Install a HTTP server
You might notice why i call it a http server and not web server. Web server works but to make the term clearer so you remember what it is for, we stick to HTTP server. Apache / Cherokee / Lighttpd / thttpd and many more are just HTTP servers. All they do is sit as a service at port 80 (default) and listen to incoming requests.
So what about Php and LAMP stack etc? Those are good terms and technologies but i see them confusing lots of people. Php is just an interpreter. It takes in php scripts and processes it. Occassionally its used to spurt out HTML code. Aha! thats why you need a HTTP server to parse the HTML code to the world!
So with this in mind. You dont really need php to do server side scripting. Python, Ruby, even C is possible.
Installing Cherokee with Php5
Cherokee (is the alternative of Apache). Its non blocking style of http service make is outperform Apache in response. (http://www.cherokee-project.com/). To install it, open up terminal and type in the following,

> apt-get install cherokee

To call up an interface, run the following

> sudo cherokee-admin -b

The rest should be quite self explanatory.
Installing Lighttpd with Php5

apt-get install lighttpd php5-cgi
/etc/lighttpd/lightly-enable-mod fastcgi [1]
/etc/init.d/lighttpd restart [4]

Now we can proceed to create a skeleton for your domains. This is so you can reuse it when you are adding new domains. Ignore this if you have just 1 domain.
cd /etc/skel
mkdir -p {backup,logs,private,public/uploads} [5]
now every time you create a new domain user, this will create a new structure. If you go to your domain from any browser http://123.45.67.89 you should see a lighttpd page.
cd /etc/skel/public/uploads
nano index.html
add in the following:

Site under maintenance, please come back later

[press crtl-x to exit nano]
Install php-myadmin
> apt-get install phpmyadmin
select lighttpd using spacebar then hit enter. when it asks to configure database for phpmyadmin, select yes. it will then ask for your mysql password, and ask you to set phpmyadmin password .

Before you start with .htaccess

If you don’t have a .htaccess file in your directory just create a simple textfile with the name .htaccess, remember to save the .htaccess file with a “.” dot. In Windows Notepad save as “.htaccess” (with quotes in the save dialog).
Lines starting with # indicates a comment and will note be parsed.

Prevent downloading of your SQLite database

If you place your SQLite database in a public www directory it could be downloaded by a visitor. See the SQLite quick tips for creating a SQLite database in a safer way. Add or remove file extension if needed. Place the following code in your .htaccess file.

# Deny sqlite file access. File extensions in parentheses
<FilesMatch “.(sqlite|sqlite2|sqlite3|sq|sq2|sq3)$”>
Deny from all

Custom error pages, “404 page not found”…

If you want to set your own error page for “404 page not found” and for other HTTP status codes you can do that easily in a .htaccess file.

ErrorDocument 404 /yourOwn404Page.html

Just replace the “404” with the the code you need and the file that should be shown.

Disable directory browsing

If you have an image directory that shows all your files when accessing it, you can disable this by placing an .htaccess file with the following code (notice the minus sign)

# – (minus) disable browsing. + (plus) enable browsing
Options -Indexes

If you place a plus sign in front of Indexes it will list your files again. A simpler variant is just to place an index.html file in that directory, it will do the same thing. You decide 🙂

Change default index page

Want to have another index page than the regular index.html, index.php page? Change the myStartPage.html in the following code and then add all other index pages you need. If myStartPage.html is not found it will try index.html and then index.php (and so on).

# reading left to right
DirectoryIndex myStartPage.html index.html index.php

Reference

Shamelessly quoted from: http://www.litewebsite.com/?k=tips
[1]some blogs say that we should add fastcgi-server={… config. The above was done without problems. perhaps bug fixed.]
so where are my http files? its at /var/www/
some blogs report memory leaks of lightly like a seive. Bahh. add in weekly cron server restart
[4] this will stop 403 errors when you try to access phpmyadmin remotely
[5] if you make a mistake you can use > rm -r xxxx to remove the xxxx directory.

Designing your webserver and access

The file you need to alter here is /etc/group
make sure theres a www-data group in the list. A record like “www-data:x:33:mywebsite.com,mysite2.com” means that mywebsite.com is a user of www-data
www-data is the group that controls your web sites. The idea is to add your first user account which is the administrator. “madmin” is my first user. I added this user to www-data to help ease traversing and controlling the websites by command line.
I have then made individual users by their website name to help ftping.
1) Have 1 admin user who is not the root
2) Have users for each domain to access FTP when needed.

Adding a new domain website

> useradd -d /home/mydomain.com -m mydomain.com
[note that adduser is different. it requires more details]
[rm -r to remove the directory from /home/mydomain]
[userdel to delete the user if wrongly created]
> passwd mydomain.com
> usermod -a -G www-data mydomain.com
[this adds your user to the www-data group]
> chgrp -R www-data /home/mydomain.com/public
> chmod -R 2750 /home/mydomain.com/public
> chmod -R 2770 /home/mydomain.com/public/uploads
[if you copy stuff from another directory using root remember to use following]
> chown -R mydomain:www-data /home/mydomain.com/public
> chgrp -R www-data /home/mydomain.com/public
> chmod -R 2750 /home/mydomain.com/public
[otherwise you may get ftp errors]
[lightly configuation and logs]
> nano /etc/lighttpd/lighttpd.conf
[find a nice place: scroll all the way down till: #### handle Debian Policy Manual, Section 11.5. urls]
[add in the following]
$HTTP[“host”] =~ “(^|.)mydomain.com$” {
server.document-root = “/home/mydomain.com/public”
server.errorlog = “/var/log/lighttpd/mydomain.com/error.log”
accesslog.filename = “/var/log/lighttpd/mydomain.com/access.log”
server.error-handler-404 = “/e404.php”
}
> mkdir /var/log/lighttpd/mydomain.com
> chown -R www-data:www-data /var/log/lighttpd
[now lighttpd own this logs directory]
[you have to run this everytime you add a new domain]
> /etc/init.d/lighttpd restart
[this should restart the server nicely. if you have installed vsftp you should be able to put in a test.html file in the public folder and test it.]
[at this time you can configure your dns for mydomain.com to point to this ip address. This would be the A record]
FAQ:
Q: Why asd.html file is not found but sdf.html file is found when i type in 123.45.67.89 when both files are in the directory?
A: File permission settings might be wrong. check that www-data is the group and its chmod -R 2750 to the public folder

Install ftp server

> apt-get install vsftpd
> nano /etc/vsftpd.conf
[change the following: you have to remove # from the front of the line]
* anonymous_enable=NO
* local_enable=YES
* chroot_local_user=YES
[press crtl-x to exit and save]
> /etc/init.d/vsftpd restart [1][2]

NOTES:

  1. [1] just by running vsftpd restart will give you a OOPs 500 error. You need to put “service” before vsftpd
  2. [2] or you can run > service vsftpd restart
  3. seems like vsftpd or other ftp software hooks onto user accounts. so for web servers, each domain should have a ftp account
  4. remember to set chroot
  5. by default openssh should be installed on ubuntu

FTPS for VSFTPD (Very secure ftp daemon)

Note that ftps is different from sftp.
> mkdir /etc/vsftpd
> openssl req -x509 -nodes -days 365 -newkey rsa:1024 -keyout /etc/vsftpd/vsftpd.pem -out /etc/vsftpd/vsftpd.pem
> chmod 600 /etc/vsftpd/vsftpd.pem
> nano /etc/vsftpd.conf
[Add in or make sure the following is uncommented.]
ssl_enable=YES
allow_anon_ssl=NO
force_local_data_ssl=YES
force_local_logins_ssl=YES
require_ssl_reuse=NO
# need require ssl reuse otherwise you get errors when you are editing files using ftps
# error “vsftpd: SSL connection failed session reuse required”
ssl_tlsv1=YES
ssl_sslv2=YES
ssl_sslv3=YES
rsa_cert_file=/etc/vsftpd/vsftpd.pem
listen_port=21
#you can use any port, filezilla defaults to port 21. So does wordpress
pasv_min_port=20000
pasv_max_port=20999
# you will need this pasv, otherwise when you set up firewall, you get ftp connection problems. as a sample use 20000 – 20999
> /etc/init.d/vsftpd restart
now you can ftp into your system using port 990 with ftps

NOTES:

  1. Ref: http://ubuntuforums.org/showthread.php?t=518293

Recent Posts
Why Job Sites Are Disappearing? · Apprentice, Journeyman, and Master · List of Docker Registries · Installing Debian 10 buster on virtualbox · Cross platform terminal emulators · Keep active keep happy · Tools to secure your devices · Secrets of the Face and Palm · Vim as an IDE for developers · WordPress multisite on Debian · Mongodb guide to basics · Jagged Alliance 2 some historic notes · Antivirus solutions and why its needed · A taovilla review and history · MacOS X high sierra running out of disk space · Airprint on bonjour missing scan function for all-in-one printers · Improving terminal load times · Knowing website design costs and pitfalls · Keeping secure and checking if your password is safe? · Installing Virtualbox Guest Additions for Debian Stretch · Windows XP Virtualbox on Mac OS X High Sierra · DNS settings and getting on public DNS · Extracting OVF from VMware ESXI 6.0 · Installing LMDE 2 Betsy · SSL Certificates and Encryption · Machine Learning with Spark · Installing Lubuntu in Virtualbox · Getting started with Docker (docker-toolbox) · Ubuntu upgrade limited boot space · Top 10 Browsers Overview · Taovilla Oracle app beta built using meteorjs · Setting up Debian on VirtualBox · The HomeBrew doctor · Afterlife Buddhist Chants · Caffeine icon for ubuntu / lubuntu · Updating wordpress without FTP · Preinstalled Languages on mainstream OS · Reminisce of Xcom · Java install on Ubuntu · Display image as ASCII art · VirtualBox Resizing Lubuntu Guest Linux · Introducing Samurai · Buddhist Chants · Macbook Pro Key mapping for Lubuntu · Common Apache Nginx commands · The nothingness between Zen and Tao · Tao, Zen and Theravada · Meditation for Growth · Buddhism · Refreshing Git versioned files · Basic Environments for Jira · Coffee Shops and Feng Shui · Converting a hg mercurial to git repository · Long term domain name costs comparison · SVG Graphing · 2 ways to Php install on mac · New EBook Launched Secrets of Human Face and Palm · Introducing Samurai and Installing Meteorjs to own server · Improving the speed of Linux Mint · Ma Zu Deity in Malaysia Sabah · SVG graphics with Javascript · FTP Clients for Mac OS X · Windows Apps on Mac · Programming Languages Compared · Hackers Natural Cure · Publishing on Ebooks · Editors such as SublimeText2 · Good Coding Practice · LMDE Linux Mint Debian Edition · Heroku Webapp · Hadoop Single node 32bit on 12.10 Mint XFCE · Tracing User Behaviour FRUBO · Installing Nginx on MacOSX · Installing Ruby on MacOS X · Turn off annoying compress outlook message · HTML5 Apps on Cordova PhoneGap with MacOSX · Choosing and using Latex · Reviewing Javascript World · Gemstones · Han Xin the Hero of Han · Gathered Wisdoms · Oriental Calendar · Li Qi Feng Shui · Five Elements Feng Shui · Taoist Philosophy Overview · 25th Anniversary Singapore Taoist Philosophy Group · Draw up an Ubuntu Server Environment · Draw up a Lightweight Mail Server · Draw up a Web Database · Php CMS and Frameworks · Drawing up a Web Service · Draw up a Virtual Cloud Server · Unlocking and Flashing your ZTE Blade · Tai Chi and Qi Gong · Pip error in Python with Homebrew · Setting up homebrew for OSX · Personality by Month · Life and Death in Oriental Beliefs · Windows and Linux Desktop Security · Ruan Tou Feng Shui · Life Analysis and Prediction · Cemetery Feng Shui · Taoism · Confucius · Guan Gong · Meditation · Gu Qin · TexMaker with Glossary on Mac · Quick way to OpenStack on Lubuntu · Ancient IT Dictionary · Oriental Poems · Fan Li · IChing · Dao De Jing · TeaTime for Basic Python · CVs and Jobhunting · Chinese Input on Linux Ubuntu · Research in Computer Science · Reviewing Applications on My Mac · Reviewing Applications on My Windows · Installing Windows XP · Installing wireless on Linux Ubuntu or Mint · Restoring an Amazon EC2 Backup · Mac Update PASV problem · Reviewing Green Computing · Consuming the Cloud Storage Space · Using Cherokee and WordPress Whine · Disabling Lubuntu Screensaver · Installing Lubuntu from USB drive · Searching for a Micro Mini CMS · ReStructuredText in Python · Rackspacecloud Vs Amazon · Hacking your old PSP · Attending Atlanta 55th MMM Conference · Smart devices for everyday use · Creative Programmers · Linux Settings · Embarking on Further Education · Machine Learning · Mac Tips – Viewing hidden files on desktop · Creating PDF files for free · Online Media for All · C# ASP Settings · SVN Git and Mercurial Versioning · Getting the last inserted id using datasets · Think Lucky and be Happy · AngieGallery Design · AceTravel Design · Letter to Mum · Prison Vs Work · Irish Daughter · Are you a carrot, an egg or a coffee bean? · Home Media Entertainment Setup · Collection of Interesting sites · Studying in London · Great Oriental eats in London · CMS Joomla, WordPress, Drupal compared ·

© 2024 · mirageglobe · using zenifywp theme by www.mirageglobe.com ·
  · RSS Feed