首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 服务器 > Apache >

ubuntu上安装LAMP How-to Install LAMP Server[Apache, MySQL, Php]

2012-09-13 
ubuntu下安装LAMP How-to Install LAMP Server[Apache, MySQL, Php]Linux LAMP servers are also popular,

ubuntu下安装LAMP How-to Install LAMP Server[Apache, MySQL, Php]

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 Linux Apache Mysql Php, 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.

?

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.

?

ubuntu上安装LAMP How-to Install LAMP Server[Apache, MySQL, Php]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

?

<?phpphpinfo();?>
?

Now open http://127.0.0.1/phpinfo.php

?

ubuntu上安装LAMP How-to Install LAMP Server[Apache, MySQL, Php]sudo apt-get install phpmyadmin?

ubuntu上安装LAMP How-to Install LAMP Server[Apache, MySQL, Php]

?

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].

?

ubuntu上安装LAMP How-to Install LAMP Server[Apache, MySQL, Php]sudo cp /etc/phpmyadmin/apache.conf /etc/apache2/conf.d?

Now you have to restart your apache server

sudo /etc/init.d/apache2 restart
?

Now open http://127.0.0.1/phpmyadmin

?

ubuntu上安装LAMP How-to Install LAMP Server[Apache, MySQL, Php]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服务器后再测试)。

?

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/


Ubuntu PHP 编辑器

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

?

来源: 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.

热点排行