Ubuntu下构建LAMP服务器

豆豆网   技术应用频道   2007年03月03日    社区交流

本文详细介绍Ubuntu下构建LAMP服务器

# test.php
<?php phpinfo(); ?>

  Point your browser to http://ip.address/test.php or http://domain/test.php and this should show all your php configuration and default settings.

  You can edit necessary values or setup virtual domains using apache configuration file.

2. Installing MySQL Database Server

  Installing mysql database server is always necessary if you are running a database driven ecommerce site. Remember running mysql server to a fair extend requires atleast 256mb of RAM in your server. So unless you are running database driven sites you dont absolutely need mysql. The following commands will install mysql 5 server and mysql 5 client.

  apt-get install mysql-server mysql-client php5-mysql

  Note: If you have already installed php4, you should make a slight change like this.

  apt-get install mysql-server mysql-client php4-mysql

  The configuration file of mysql is located at: /etc/mysql/my.cnf

Creating users to use MySQL and Changing Root Password

  By default mysql creates user as root and runs with no passport. You might need to change the root password.

  To change Root Password

  mysql> USE mysql;

  mysql> UPDATE user SET Password=PASSWORD('new-password') WHERE user='root';

  mysql> FLUSH PRIVILEGES;

  You must never use root password, so you might need to create a user to connect to mysql database for a PHP script. Alternatively you can add users to mysql database by using a control panel like webmin or phpMyAdmin to easily create or assign database permission to users. We will install Webmin and phpmyadmin during later once we complete basic installation.

3. PhpMyAdmin Installation

  PhpMyAdmin is a nice web based database management and administration software and easy to install and configure under apache. Managing databases with tables couldnt be much simpler by using phpmyadmin.

  All you need to do is:

  apt-get install phpmyadmin

  The phpmyadmin configuration file is located at: /etc/phpmyadmin folder.

  To set up under Apache all you need to do is include the following line in /etc/apache2/apache2.conf:

Include /etc/phpmyadmin/apache.conf

  Now restart Apache:

  /etc/init.d/apache2 restart

  Point your browser to: http://domain/phpmyadmin

  That's it! MySQL and phpMyAdmin are ready. Log in with your mysql root password and create users to connect to database from your php script.

  This tutorial was written and contributed to HowToForge byScott who currently runs MySQL-Apache-PHP.com. Permission is fully granted to copy/republish this tutorial in any form, provided a source is mentioned with a live link back to the authors site.

作者:olddocks    责编:豆豆技术应用

正在加载评论...