AdSense How to create a LAMP web server from scratch To create a web server full of the best features, that is also PHP and database management, a system can be perfect, LAMP (Linux Apache MySQL PHP).
This little guide is also suitable for those who try to take its first steps in this field, or it is impractical to Linux.
you can create a fully functional, reliable and cheaply (in my case only 30 €), the first requirement is:
- Subscription adsl flat
Without it should not even start. Then comes: do not need more, the keyboard and monitor will be connected only temporarily. The operating system is a Linux distribution without a GUI:
- Ubuntu 8.04.2 Server
Installs Ubuntu Server CD, completely formatting the hard disk. Okay create a partition with the basic method, without LVM. You must have an active internet connection to ensure the download of the software later.
careful do not leave the USB sticks during disk partitioning, may cause errors.
Now you must install the Apache 2 Web server, thanks to the command
$ sudo apt-get install apache2
Command download software from the Internet to manage the web server. When a request comes to the PC on port 80, it must respond by sending the file / var / www / index.html
.
If the PC with Ubuntu Server within a local network, you must set the router to send HTTP requests to the same computer, otherwise the web server is not reachable from outside the network.
- Port Forwarding
mode addressing of HTTP requests to the web server's network adapter you use depends on the router on your LAN. You do not need to do anything if it is the only PC connected to the Internet. Otherwise the site
http://www.portforward.com/routers.htm
can provide very accurate explanations. In some cases the IP addresses of local network created by the router can be assigned dynamically: it is necessary to avoid this disable DHCP on your LAN, or set the IP address of a network adapter Special features (that of the webserver in this case).
- DNS Name
If you want to assign a DNS name to your web server, to ensure its accessibility from all over the world, one can use a service like that offered on dyndns.com
. In practice, we assign a DNS name (such as tuonome.dyndns.org, tuonome.thruhere.net etc.) to the IP address you want.
Here's a tutorial to figure out what to do.
- DNS assigned to a dynamic IP
The problem is that most of the IP assigned by your ISP is dynamic. In this case, install a small program that controls the machine's IP address and communicate it to dyndns.com, so keep updated the DNS name you choose.
You can use the software
ddclient. This client communicates with the account you created earlier on dyndns.com and associated with the chosen DNS IP of the machine.
The disclosure of account information (name and password) can be protected with an encrypted connection using SSH. Installation:
$ sudo apt-get install ssh libio-socket-ssl-perl
$ sudo apt-get install ddclient
installation leads to some requests: If you want to set more than one domain name is sufficient indicate them separated by commas. When you need the interface to use, enter "web".
now need to set the encryption of communications and tracking the IP address of the machine, changing the configuration file
/ etc / ddclient.conf .
You use vim: $ sudo vim / etc / ddclient.conf
The file will appear like this: # Configuration file
for ddclient generated by debconf
# # / etc / ddclient.conf
pid = / var / run / ddclient.pid
protocol = dyndns2
use = if, if = web server =
members.dyndns.org
login = your-dyndns-username password =
your-dyndns-password
string
use = if, if = web
should be changed to:
use = web, checkip.dyndns.com = web, web-skip = 'IP Address' To do this you must press the
, entering the edit mode of vim.
Immediately after the first three commented lines, insert strings:
ssl = yes daemon = 300
to indicate the encryption of data and running as a daemon.
After the changes, press ESC
, then :wq per salvare e uscire. Occorre ancora assicurarsi che il file /etc/default/ddclient
contenga questa configurazione:
# Configuration for ddclient scripts
# generated from debconf on Tue Jan 29 20:23:32 CST 2008
# # /etc/default/ddclient
# Set to “true” if ddclient should be run every time a
# new ppp connection is established. This might be useful,
# if you are using dial-on-demand
run_ipup=”false”
# Set to “true” if ddclient should run in daemon mode
run_daemon=”true”
# Set the time interval Between the updates of the dynamic DNS name in seconds. # This option only
Takes effect if the ddclient runs in daemon mode.
daemon_interval = "300"
Finally, restart ddclient
sudo / etc / init.d / ddclient restart
- Installing PHP
Now that you have ensured the accessibility of a server from anywhere in the world, you could not install the software foundation for dynamic pages.
Type:
sudo apt-get install php5 libapache2-mod-php5
To interagine must restart Apache with php:
sudo / etc/init.d/apache2 restart
- Review of PHP
Simply
can edit the file / var / www / index.html index.php
calling and entering inside the string:
If all is unsuccessful the page, open a web browser, will show information about the PHP machine.
- Installing MySQL
$ sudo apt-get install mysql-server
The installation also requires the login information for root.
- Installing phpMyAdmin
This is a very powerful and convenient for the management of the database. Installation:
$ sudo apt-get install libapache2-mod-auth-mysql php5-mysql phpmyadmin
Now we need to edit a line in the file / etc/php5/apache2/php.ini
:
the
string; extension = mysql.so
must become
extension = mysql.so .
a restart of Apache to allow the interaction of phpmyadmin:
sudo / etc/init.d/apache2 restart
- Installation of Webmin is the operator for the remote machine!
Webmin is an open source alternative to CPanel, much appreciated. Supports data encryption access, by the Perl SSLeay library. Installation:
$ sudo apt-get install perl libnet-SSLeay-
Now you can securely access to WebMin via https.
$ sudo wget http://indirizzo-del-mirror/webmin-x.xxx.tar.gz
address to be included in the command are here
. Take the latest version of Webmin. To unpack the archive: $ sudo
tar zxvf webmin-1.340.tar.gz
Launch setup: $ sudo
./webmin-1.740/setup.sh
convenient to setup a gateway other than the default, to increase the security of access. After entering all the data required the installation is complete.
Now the monitor and keyboard are no longer needed the web server.
Sources: Installing LAMP
,
DynDNS Client Setup
,
Installing WebMin
See also:
MySQL Password Reset
,
Securing WebMin