Installing Apache, MySQL and PHP on Ubuntu
Quick guide for a server LAMP installation on a local Ubuntu system, including Apache2, PHP 5, MySQL 5 and phpMyAdmin.
Ubuntu does not have a software which installs and manages all the necessary software for a Web Server, such as EasyPHP for Windows.
However, the installation process is so simple that it is necessary only one command to have a comprehensive and reliable system:
sudo apt-get install apache2-mpm-prefork mysql-server libapache2-mod-php5 php5-mysql php5-gd phpmyadmin
In addition to Ubuntu root password, you will be requested the MySQL password for root user and the type of server that phpMyAdmin must interface: you must select Apache 2.
After that we will have the following software installed and ready for use:
web server Apache 2
MySQL database server
PHP 5 with the Apache module and the gd library
phpMyAdmin for an easy database management
DocumentRoot and Virtual Server
As above, the system is already operating at 100%, but there with a small correction to the configuration we could have many benefits in a few simple steps.
This is the DocumentRoot of the Apache server, which by default is located in /var/www, but it would be better to move it in your Home for more than one reason, including an issue of file permissions, a better management of file system and a more efficient procedure in the event of a crash or system backup.
This doesn't require particular webserver configuration skills.
In your Home, create a directory called public_html, that will be your web root.
mkdir /home/user/public_html
Obviously, from now on, remember to replace user with your Home name.
For Apache2 sites are separate configurations that the web will read, loaded in /etc/apache2/sites-available. By default, there is only one site available, called default, but you can load multiple configurations simultaneously, activating from time to time only those necessary.
In your case, you must create a new site and move the DocumentRoot in /home/utente/public_html/, and then activate it on Apache2.
To create the new site:
Copy the default website as a starting point.
sudo cp /etc/apache2/sites-available/default /etc/apache2/sites-available/mysite
Modify the new configuration with a notepad, for example:
sudo gedit /etc/apache2/sites-available/mysite
Change the DocumentRoot parameter so it will point to the new location, eg. /home/user/public_html/.
Change the Directory instruction, replacing <Directory /var/www/> with <Directory /home/user/public_html/>.
Save the file
It is now necessary to disable the old site (default) and activate the new one (mysite). To do this, Ubuntu has created two easy commands, which are respectively a2dissite and a2ensite.
sudo a2dissite default && sudo a2ensite mysite
Last but not least step is restarting Apache2:
sudo /etc/init.d/apache2 restart
If you have forgotten to create the directory /home/user/public_html/, a warning message will appear.
By opening a browser to http://localhost/ you should be redirected to the content of ~/public_html/.
I would like to remind you that this is a basic configuration, best suited for local tests, not for Web server usage.
To increase security and add some customization, you can modify the main Apache 2 configuration file, located in /etc/apache2/apache2.conf. Remember to create a backup of this file before start testing. You must also restart apache2 for changes to take effect.
If you need more information, please visit the Apache and Web Server section or read the user guide about Apache2 modules.
Concerning the PHP configuration, I can only tell you that the php.ini configuration file is located in /etc/php5/apache2.
Remember to move all the content of /var/www in your new DocumentRoot folder.
Notes
webserver ubuntu, apache ubuntu, apache linux, installare lamp, server lamp, public html ubuntu
Publication details
Category: Apache and Web Server
Published by: loryzz on date: 16.09.2008 15:11:21
Last edit by: loryzz on date: 16.09.2008 16:27:00
Ratings
Leave a comment
All comments must be approved by site administrator.
Please write comments on topic. Spam will be never approved.
Apache and Web Server: Linked articles
Install SVN on Ubuntu published by loryzz in Apache and Web Server
Enable / disable Apache 2 modules published by loryzz in Apache and Web Server
























Ritorna all'inizio
Based total comments
0 %
Comments percentage
0 %