(转载)ubuntu 10.10 安装配置LAMP

(转载)ubuntu 10.10 安装配置LAMP

Installing Apache MySQL, PHP and phpmyadmin on Ubuntu10.10 Maverick Meerkat is far easier and less complicated than doing the same on Fedora 13, (my own experience).

Step 1:You start by installing mysql

sudo apt-get install mysql-client mysql-server

Specify new password for the MySQl “root” user when prompted. Repeat it for a second time and you would have MySQL server and client installed.

Step 2:Next, installApache2:

sudo apt-get install apache2

And you get apache2 installed as well. To double check, point your browser to http://localhost, and you should see the Apache2 placeholder page like this.

Step 3:To install support for PHP, do the usual

sudo apt-get install php5 libapache2-mod-php5

To verify that everything installed correctly and php support is enabled, you need torestart apacheby doing this

sudo /etc/init.d/apache2 restart

Create a test php file called info.php, using a text editor of your choice (say gedit)

sudo gedit /var/www/info.php

and paste the following content and save the file

<?php phpinfo(); ?>

Now open the following page http://localhost/info.php and you should see something like this

Step 4:To make MySQL, php and apache talk among themselves, you would have to install php5-mysql, below I am listing some more useful packages that you might want to install

sudo apt-get install php5-mysql php5-curl php5-gd php5-idn php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-ming php5-ps php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl php5-common

Now refresh the info.php page that you have open in your browser and you should be able to see the support for mysql if you search for it by doing Ctrl+f, but before that don’t forget to restart apache again (sudo /etc/init.d/apache2 restart)

Step 5:Finally install phpmyadmin

sudo apt-get install phpmyadmin

It would ask if you want to configure it automatically for apache or lightppd choose apache (by pressing “spacebar” to display a star as shown below and then use tab to navigate to Ok and press enter.

It would be automatically configured, however it would ask if you want a database installed and configured, chooseyesand press enter

On the next screen you would be asked to enter the MySQL root password, that you provided in first step

next it would ask you to enter a password to be used by phpmyadmin to register with thedatabase(basically it would create a user called “phpmyadmin” the password is for that, most likely you won’t be needing this password ever. You can even choose to assign a random password for it.

Confirm that password on the next screen. Once you have made your choices the installation would finish and you should be able to access phpmyadmin by pointing your web browser to http://localhost/phpmyadmin/

ubuntu 10.4 的

http://www.oschina.net/bbs/thread/10794

http://blog.myspace.cn/e/407367767.htm

安装

当然不使用Gnome,使用终端命令也很简单:
直接一条命令:apt-get install apache2 mysql-server mysql-client php5 php5-gd php5-mysql

设置Ubuntu文件执行读写权限

LAMP组建安装好之后,PHP网络服务器根目录默认设置是在:/var/www。由于Linux系统的安全性原则,改 目录下的文件读写权限是只允许root用户操作的,所以我们不能在www文件夹中新建php文件,也不能修改和删除,必须要先修改/var/www目录的 读写权限。在界面管理器中通过右键属性不能修改文件权限,得执行root终端命令:sudo chmod 777 /var/www。 然后就可以写入html或php文件了。如果对777表示的文件权限不是很清楚可参考chmod命令。

如何安装phpmyadmin-Mysql 数据库管理

使用界面管理器
系统->系统管理->新立得软件包管理器->搜索 phpmyadmin->右键标记安装。
或直接使用一条命令:sudo apt-get install phpmyadmin 安装开始。

phpmyadmin设置
在安装过程中会要求选择Web server:apache2或lighttpd,选择apache2,按tab键然后确定。然后会要求输入设置的Mysql数据库密码连接密码 Password of the database's administrative user。
然后将phpmyadmin与apache2建立连接,以我的为例:www目录在/var/www,phpmyadmin在/usr/share /phpmyadmin目录,所以就用命令:sudo ln -s /usr/share/phpmyadmin /var/www 建立连接。

phpmyadmin测试:在浏览器地址栏中打开http://localhost/phpmyadmin。

Ubuntu LAMP 如何配置Apache

1. 启用 mod_rewrite 模块
终端命令:sudo a2enmod rewrite
重启Apache服务器:sudo /etc/init.d/apache2 restart

Apache重启后我们可以测试一下,在/var/www目录下新建文件test.php,写入代码: <?php phpinfo(); ?>保存,在地址栏输入http://127.0.0.1/test.php 或 http://localhost/test.php ,如果正确出现了php 配置信息则表明LAMP Apache已经正常工作了(记得重启Apache服务器后再测试)。

2.设置Apache支持.htm .html .php
sudo gedit /etc/apache2/apache2.conf
或sudo gedit /etc/apache2/mods-enabled/php5.conf
在打开的文件中加上
AddType application/x-httpd-php .php .htm .html 即可。

LAMP配置之Mysql测试

上面php,Apache 都已经测试过了,下面我们再测试一下Mysql 数据库是否已经正确启用。

在/var/www目录下新建 mysql_test.php:

<?php
$link = mysql_connect("localhost","root","020511");
if (!$link)
{
die('Could not connect: ' . mysql_error());
}
else echo "Mysql已经正确配置";
mysql_close($link);
?>

保存退出,在地址栏输入http://127.0.0.1/mysql_test.php,显示"Mysql 已经正确配置"则表示OK了,如果不行,重启Apache服务器后再试一下。

命令行一条命令安装LAMP

$sudo tasksel

输入管理员密码后进入菜单 ,选择LAMP server

输入MySQL密码

程序开始下载,并安装完成。

安装完后在浏览器输入 Server地址,一般默认情况下输入127.0.0.1

出现

It works!

This is the default web page for this server.

The web server software is running but no content has been added, yet.

则表明Apache运行中。

接下来检查MySQL工作情况:

命令行输入:

mysql -u root -p

如果运行正常如下

ander50@ander50-desktop:~$ mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 40
Server version: 5.1.41-3ubuntu12.3 (Ubuntu)

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

输入密码

配置概要

一、配置php5

命令:sudo gedit /etc/php5/apache2/php.ini

        修改允许最大使用内存,查找

memory_limit = 8M

         修改为

memory_limit = 32M


         修改允许最大上传尺寸,查找

upload_max_filesize = 2M

         修改为

upload_max_filesize = 8M


         允许 mysql 和 gd 模块,检查文件最后是否包含下面的代码,如果没有添加上。(默认是在配置文件最后有添加的,检查一下以防万一)

extension=mysql.so
    extension=gd.so

          保存并关闭文件。

二、配置apache

1、ubuntu 中配置文件在/etc/apache2下,apache2.conf是全局配置或者说是主配置文件,httpd.conf是用户配置文件,感觉和用php 编写程序时经常用config.php覆盖config.default.php文件中的设置是一样的,用户设置独立出来,方便管理和备份,毕竟主配置文 件很少修改,偶尔修改一两句也可以写到httpd.conf里面,备份方便

        在/etc/apache2/httpd.conf加入一行:ServerName 127.0.0.1

        命令:sudo gedit /etc/apache2/httpd.conf

2、下面这段是在官网上找下来的

        编辑/etc/apache2/apache2.conf(新安装的系统可能在/etc/apache2/conf.d/charset)文件,在改动之 前,请先将该配置文件做个备份。以便在出错的时候可以恢复。将

AddDefaultCharset ISO-8859-1

        改为

AddDefaultCharset GB2312

        当然如果你网站的编码用的是UTF-8的话,也可以改为

AddDefaultCharset UTF-8

        这样的话,我们就不会每次打开网页都是乱码了!

3、增加安全模块,以保障Apache服务的正常运行,现在我们安装mod-security。(可选)

        a. 首先安装libapache2-mod-security包(7.10之后的系统已经没有此包,可以跳过此步骤)

sudo apt-get install libapache2-mod-security

        a. 该模块默认是没激活的,我们可以在/etc/apache2/mods-available目录下看到有mod-security.load文件,但在 /etc/apache2/mods-enabled目录却没有它的软链接。我们现在激活它:

$sudo a2enmod mod-security
$sudo cp /usr/share/doc/libapache2-mod-security/examples/httpd2.conf.example-full /etc/apache2/mods-available/mod-security.conf
$sudo cp /etc/apache2/mods-available/mod-security.conf /etc/apache2/mods-available/mod-security.conf.orig
$sudo vi /etc/apache2/mods-available/mod-security.conf

==== mod-security.conf 文件内容开始====
# 检测内容长度以避免堆溢出攻击
SecFilterForceByteRange 32 254 =>SecFilterForceByteRange 32 126

# debug设置
SecFilterDebugLevel 9 =>SecFilterDebugLevel 0

# 设置缺省的动作
SecFilterDefaultAction "deny,log,status:499" =>SecFilterDefaultAction "deny,log,status:404"

# 把设置传递给子目录
SecFilterInheritance Off

# Redirect user on filter match
# 当匹配sh的时候,重新定向到一个特殊的警告页面,该页面是自行编写的,写些警告的话让攻击者知难而退,该段先不要生效,等到相关配置配好之后再失效不迟。记住在配好之后要使之生效。
#SecFilter sh redirect:http://localhost/hack/warning.htm

# Prevent OS specific keywords
#过滤一些敏感的东西,我们使用*是为了攻击者使用/etc/./passwd来绕开检测
SecFilter /etc/passwd =>SecFilter /etc/*passwd
SecFilter /bin/*sh

# Very crude filters to prevent SQL injection attacks
# 防止SQL插入(SQL Injection)攻击
SecFilter "delete[[[space|]]]+from"
SecFilter "insert[[[space|]]]+into"
SecFilter "select.+from"
SecFilter "select[[[space|]]]+from"
SecFilter "union[[[space|]]]+from"
==== mod-security.conf 文件内容结束====

sudo ln -s /etc/apache2/mods-available/mod-security.conf /etc/apache2/mods-enabled/mod-security.conf

a. 重启Apache2服务即可。

sudo /etc/init.d/apache2 restart

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值