`
天梯梦
  • 浏览: 13708193 次
  • 性别: Icon_minigender_2
  • 来自: 洛杉矶
社区版块
存档分类
最新评论

Linux/ubuntu下安装LAMP (开启重写模块apache rewrite) How-to Install LAMP Server

 
阅读更多

Linux LAMP servers are also popular, flexible and reliable as WAMP server. The installation of both servers are very easy and differ from each other. LAMP means L inux A pache M ysql P hp, and WAMP is for Windows. WAMP server installs automatically(installer),you are able to use server without touching setting files. While LAMP server installs with commands. Here, I am going to show how to install LAMP server through Terminal on Ubuntu.

 

LAMP Installation:

To install LAMP server, open up a Terminal window(Ctrl+Alt+t ), and type the following commands.

All commands have written in italic words and remember Terminal commands are case sensitive!!

 

To install Apache:

sudo apt-get install apache2

 

Now to confirm the installation of Apache2 open http://127.0.0.1 in your web browser, you will see It Works! default page of Apache.

 

 

To install Mysql:

sudo apt-get install mysql-server

 

At the installation you be will asked to provide a root password for Mysql.

 

To install php:

sudo apt-get install php5 libapache2-mod-php5

 

After this installation restart Apache [sudo /etc/init.d/apache2 restart ] don’t write brackets.

Now make a phpinfo.php file and save that in /var/www to do this use [sudo gedit /var/www/phpinfo.php ] write a code in this file

 

<?php
phpinfo();
?>

 

Now open http://127.0.0.1/phpinfo.php

 

 

To install phpmyadmin:

sudo apt-get install phpmyadmin

 

 

Two option window will open in installation one for web server reconfigure automatically[ select apache2] and second for configure database for phpmyadmin with dbconfig-common [ select No] .

 

lamp-server-installation-ubuntu-10.10

 

You will need to copy the apache.conf to /etc/apache2/conf.d/ from /etc/phpmyadmin/ or the page will return a 404 error. To copy Run-

sudo cp /etc/phpmyadmin/apache.conf /etc/apache2/conf.d

 

13.10之后可以尝试

sudo ln -s /etc/phpmyadmin/apache.conf /etc/apache2/conf-enabled/phpmyadmin.conf

 

Now you have to restart your apache server

sudo /etc/init.d/apache2 restart

 

此时如果出现“apache2: Could not reliably determine the server's fully qualified domain name” 这样的错误,你可以打开文件/etc/apache2/apache2.conf 末尾添加代码 ServerName localhost 即可,详情看本文下方。

 

Now open http://127.0.0.1/phpmyadmin

 

 

Read : Lamp Installation through Tasksel

 

If you want to start blogging and interested in the field of earning money online. Then you should install WordPress CMS to make blog or site. For WordPress installation you should see my tutorial of WordPress installation .

 

Hope this will helpful for you, for any query or help post comments. Your feedback helps us.

 

来源:http://tech.mobiletod.com/how-to-install-lamp-serverapache-mysql-php-on-ubuntu-10-10/

 

Ubuntu LAMP 如何配置Apache

1. 修改文件夹读写权限

PHP网络服务器根目录默认位置:/var/www,默认属性只允许root用户执行操作,但是在Ubuntu中因为安全性的考虑默认关闭了 root账户。为了可以在这个文件夹新建修改php、html文件等等,可以通过终端命令行修改文件夹的这个属性:

sudo chmod 777 /var/www

 

2. 启用 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服务器后再测试)。

 

如何测试是否已经开启地址重写?查看这里

 

如果还是不行的话,可以考虑编辑  /etc/apache2/apache2.conf

<Directory /your/path>
AllowOverride All
</Directory>

 

同时还需要考虑的文件是:your site virtual host file or edit the 000-default in the /etc/apache2/sites-enabled/

 

Add this lines:

<Directory /var/www/mysite/>
AllowOverride all
</Directory>
 
after this block:
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>

 

If you get a 500 type of error trying to view your site don’t panic!

This happens because the rewrite module doesn’t come enabled by default for security reasons.

Create a new file called rewrite.conf in _/etc/apache2/mods-enabled_
in the file put this line LoadModule rewrite_module /usr/lib/apache2/modules/mod_rewrite.so

Reload one more time the server.

 

3. 设置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 即可。

 

解决Firefox浏览器显示中文乱码等问题

上面在FireFox浏览器中打开mysql_test.php或phpmyadmin测试时,如果出现了中文乱码,则是默认语言设置问题,解决方法如下:

打开apache配置文件: udo gedit /etc/apache2/apache2.conf,在最后面加上:AddDefaultCharset UTF-8 ,如果还是乱码的,再将UTF-8改用gb2312。
重启Apache:sudo /etc/init.d/apache2 restart  再刷新mysql_test.php 中文乱码没有了。

如果要人工启动mysql:mysql -u root -p,根据提示输入密码。
如果重启Apache时出现:
* Restarting web server apache2
apache2: Could not reliably determine the server’s fully qualified domain name, using 127.0.1.1 for ServerName
apache2: Could not reliably determine the server’s fully qualified domain name, using 127.0.1.1 for ServerName

则还是修改apache配置文件:sudo gedit /etc/apache2/apache2.conf,在文件最后设置:ServerName 127.0.0.1

 

LAMP组件经常使用的几个终端命令

#重启 apache:
sudo /etc/init.d/apache2 restart

#重启mysql:
sudo /etc/init.d/mysql restart

#配置 php.ini:
sudo gedit /etc/php5/apache2/php.ini

#配置 apache2.conf:
sudo gedit /etc/apache2/apache2.conf

#配置 my.cnf:
sudo gedit /etc/mysql/my.cnf

#PHP CGI :
sudo /var/www/cgi-bin/

 

修改phpmyadmin/phpmygoodadmin导入文件大小限制

找到php.ini文件
#sudo gedit /etc/php5/apache2/php.ini
upload_max_filesize = 50M
post_max_size = 50M
memory_limit = 128M
#sudo /etc/init.d/apache2 restart

 

Ubuntu PHP 编辑器

最后LAMP配置就完成了,在Ubuntu下进行简单的php代码编辑,用Gedit就可以了。Gedit支持HTML,PHP,Javascsript等近几十种语言的代码高亮功能。如果是PHP项目开发,建议使用PHP IDE编辑器,比如Zend Studio,Eclipse。据说文本编辑VIM也很不错。

 

Could not reliably determine the server's fully qualified domain name?

Restarting web server apache2
apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
... waiting apache2:
Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName

 

This is just a friendly warning and not really a problem (as in that something does not work).

If you insert a

ServerName localhost
 

 

in either httpd.conf or apache2.conf in /etc/apache2 and restart apache the notice will disappear.

If you have a name inside /etc/hostname you can also use that name instead of localhost.


And it uses 127.0.1.1 if it is inside your /etc/hosts:

127.0.0.1 localhost
127.0.1.1 myhostname

Preferred method

Troubleshooting Apache

If you get this error:

apache2: Could not determine the server's fully qualified domain name, 
using 127.0.0.1 for ServerName

then use a text editor such as "sudo nano" at the command line or "gksudo gedit" on the desktop to create a new file,

sudo nano /etc/apache2/conf.d/fqdn

or

gksu "gedit /etc/apache2/conf.d/fqdn"

then add

ServerName localhost

to the file and save. This can all be done in a single command with the following:

echo "ServerName localhost" | sudo tee /etc/apache2/conf.d/fqdn

But on Ubuntu 14.04:

echo "ServerName localhost" | sudo tee /etc/apache2/conf-available/fqdn.conf
sudo ln -s /etc/apache2/conf-available/fqdn.conf /etc/apache2/conf-enabled/fqdn.conf

Don't forget the ".conf" (without will not work).

 

来源: http://farlee.info/archives/linux-ubuntu-lamp-apache-mysql-php-phpmyadmin-install-configuration.html

 

 

分享到:
评论
1 楼 G.x.c 2012-06-21  
very good!  like it.

相关推荐

    Ubuntu下LAMP(linux+apache+mysql+php)环境的配置与安装.pdf

    在Ubuntu下安装和配置LAMP环境可以按照以下步骤进行: 1. 安装Apache:使用以下命令安装Apache:`sudo apt-get install apache2` 2. 安装MySQL:使用以下命令安装MySQL:`sudo apt-get install mysql-server` 3. ...

    How-to-install-apache-on-ubuntu.rar_Ubuntu!

    在Ubuntu中,你可以通过编辑 `/etc/apache2/apache2.conf` 或者 `/etc/apache2/sites-available/` 目录下的特定配置文件来进一步自定义Apache的设置。例如,添加虚拟主机、修改端口、调整日志级别等。 此外,了解...

    ubuntu下lamp的部署

    ### Ubuntu 下 LAMP 的部署详解 #### 一、概述 LAMP 是一套常见的 Web 开发环境,由 Linux、Apache、MySQL 和 PHP 组成。在本篇内容中,我们将详细介绍如何在 Ubuntu 操作系统上搭建 LAMP 环境。通过这一过程,读者...

    linux下安装apache

    Linux 下安装 Apache Linux 下安装 Apache 是一个复杂的过程,需要安装多个依赖项,包括 APR、APR-UTIL 和 PCRE。在本文中,我们将详细介绍 Linux 下安装 Apache 遇到的问题,以及解决办法。 一、安装前准备 在...

    Linux下lamp安装教程

    ### Linux 下 LAMP 环境安装教程 #### 核心知识点概述 本文将详细介绍如何在 CentOS 5.5 版本的 Linux 系统上安装 LAMP (Linux, Apache, MySQL, PHP) 环境。LAMP 是一套常用的开源软件组合,广泛应用于 Web 开发...

    ubuntu,LAMP安装笔记

    ### Ubuntu LAMP环境安装知识点详解 #### 一、概述 在Ubuntu系统上搭建LAMP(Linux、Apache、MySQL、PHP)环境是常见的Web服务器配置方式之一。本文将根据提供的安装笔记,详细介绍各组件的安装步骤及注意事项。 #...

    linux离线安装apache

    在Linux环境下离线安装Apache服务器涉及多个步骤,包括但不限于安装必要的开发工具如GCC、G++等,以及配置相关的库文件如PCRE、OpenSSL等。本文将详细介绍整个流程,并针对特定的操作步骤提供指导。 #### 二、准备...

    LINUX下的LAMP编译安装(apache+php+mysql).pdf

    ./configure --prefix=/usr/local/apache2 --enable-so --enable-rewrite --with-pcre yangr make yangr make install ``` 配置Apache并启动服务: ```bash yangr vi /usr/local/apache2/conf/httpd.conf ``` 在配置...

    ubuntu 安装配置apache2+tomcat6+mysql5 全功略.pdf

    * ./configure --prefix=/home/apache2 --enable-so --enable-rewrite=share --enable-proxy=share --enable-proxy-ajp=share --enable-dav=share --with-apr=/home/apr --with-apr-util=/home/apr-util * make * ...

    LAMP(linux,apache,mysql,php)的配置文档

    - `--prefix=/web/apache` 指定安装路径。 - `--with-ssl` 和 `--enable-ssl` 启用 SSL 支持。 - `--enable-so` 允许加载模块。 - `--enable-rewrite` 启用 URL 重写功能。 - `--disable-cgid` 和 `--disable-...

    Apache安装httpd-2.4.16.tar.gz

    这个教程将详细讲解如何在Linux环境下安装`httpd-2.4.16`版本。Apache 2.4系列是一个重要的版本,引入了许多性能优化和安全改进,使得它成为服务器管理者的首选。 **一、Apache HTTPD介绍** Apache HTTPD是一个...

    asp伪静态化/asp静态化/ASPURL重写/IIS Rewrite/RewriteRule/

    RewriteRule是Apache服务器上的mod_rewrite模块的一部分,用于执行URL重写和重定向。在IIS Rewrite中,RewriteRule的概念同样适用,它是定义重写规则的核心语法。例如,`RewriteRule ^index\.asp$ /index.html [L]`...

    apache-web-server-lm.zip_Apache Web_Apache Web Server_apache

    这个名为"apache-web-server-lm.zip"的压缩包包含了关于Apache Web Server的配置手册,旨在帮助用户更好地搭建和管理自己的网站。让我们深入探讨一下Apache Web Server的主要特点、配置方法以及如何利用提供的手册...

    Linux系列实验之[编译安装LAMP]

    本篇文章将详细介绍如何在Linux环境下从源代码编译安装LAMP环境。 #### 二、LAMP概述 **LAMP** 是一组用于搭建动态网站或Web应用服务器的开源软件集合,具体包括: 1. **L** - Linux 操作系统:作为底层支撑的...

    linux上svn、apache安装

    在Linux环境下安装Apache主要分为以下几个步骤: 1. **安装 APR (Apache Portable Runtime)** APR是为Apache开发的一组库,它提供了跨平台API,使得Apache能够更加高效地运行。 ```bash # 下载并解压 APR tar...

    LINUX下的LAMP编译安装(apache+php+mysql)[参照].pdf

    ./configure --prefix=/usr/local/apache2 --enable-so --enable-rewrite yangr make yangr make install ``` 配置Apache并启动服务: ```bash yangr cp /usr/local/apache2/conf/httpd.conf /etc/httpd....

    Apache_2.4.23-x64-openssl-1.0.2h.zip

    1. **模块化设计**:Apache服务器的核心被设计为高度模块化,允许用户根据需求选择安装和配置特定功能模块,如mod_rewrite(URL重写)、mod_security(安全防护)等。 2. **性能优化**:此版本引入了多项性能提升...

    LAMP配置过程-2012-05-18

    3. 下载并编译安装Apache:`./configure --prefix=/usr/local/apache --enable-so --enable-rewrite --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util` #### MySQL安装与配置 虽然文档中未明确提及...

    Apache2 for Linux

    Apache的配置主要位于`/etc/apache2`(Ubuntu/Debian)或`/etc/httpd`(CentOS/RHEL)目录下的配置文件中。主配置文件通常是`httpd.conf`或`apache2.conf`。 1. **修改默认站点**: Apache安装后会有一个默认的站点...

Global site tag (gtag.js) - Google Analytics