p { margin-bottom: 0.08in; }h1 { margin-bottom: 0.08in; }h1.western { font-family: "Times New Roman",serif; }h1.cjk { font-family: "DejaVu Sans"; }h1.ctl { font-family: "DejaVu Sans"; }h3 { margin-bottom: 0.08in; }pre.cjk { font-family: "DejaVu Sans",monospace; }a:link { }code.cjk { font-family: "DejaVu Sans",monospace; }
ubuntu Linux 安装配置
LAMP环境
PHP开发和服务器运行环境首选
LAMP
组合,即
Linux+Apache+MySQL+Php/Perl
/Python,能最优化服务器性能。如何在本地电脑
Ubuntu
中安装和配置
LAMP环境?
Ubuntu10.04本身就是基于
Linux内核,所以
Linux是现成的了。使用
Ubuntu
LAMP Server软件包可以很简单地实现
Linux下
Apache,
MySQL
和
Php的统一安装和配置,也不再需要一个一个来安装配置了。
Ubuntu环境下如何安装
LAMP组件
1,使用
Ubuntu新立得管理器
系统
->系统管理
->新立得软件包管理器
->编辑
->使用任务标记分组软件包
->LAMP
Server(勾选
)->确定
->返回到上一个窗口点击应用
(
System->Administration->Synaptic Package Manager->Edit->Mark
packages by Task->LAMP
Server->OK)。然后系统会自动下载安装
lamp环境软件包,几分钟就下载搞定。安装过程中会要求设置
MySQL root帐号的密码,设置好了记住。另外当
Ubuntu系统升级时
lamp环境组件也会同时更新到最新版本。
安装完毕测试
:打开
Firefox浏览器在地址栏输入
http://127.0.0.1,显示
It
works!表明
Apache服务器已经开始工作了,
LAMP安装
也就这样完成了。
2,使用命令行
当然不使用
Gnome,使用终端命令也很简单:
直接一条命令
:
apt-get
install apache2 mysql-server mysql-client php5 php5-gd php5-mysql
或者:
Install Apache
To start off we will install Apache.
1. Open up the Terminal (Applications > Accessories >
Terminal).
2. Copy/Paste the following line of code into Terminal and then
press enter:
sudo apt-get install apache2
3. The Terminal will then ask you for you're password, type it and
then press enter.
Testing Apache
To make sure everything installed correctly we will now test
Apache to ensure it is working properly.
1. Open up any web browser and then enter the following into the
web address:
http://localhost/
You should see a folder entitled apache2-default/. Open it and you
will see a message saying "It works!" , congrats to you!
Install PHP
In this part we will install PHP 5.
Step 1. Again open up the Terminal (Applications > Accessories
> Terminal).
Step 2. Copy/Paste the following line into Terminal and press
enter:
sudo apt-get install php5 libapache2-mod-php5
Step 3. In order for PHP to work and be compatible with Apache we
must restart it. Type the following code in Terminal to do this:
sudo /etc/init.d/apache2 restart
Test PHP
To ensure there are no issues with PHP let's give it a quick test
run.
Step 1. In the terminal copy/paste the following line:
sudo gedit /var/www/testphp.php
This will open up a file called phptest.php.
Step 2. Copy/Paste this line into the phptest file:
<?php phpinfo(); ?>
Step 3. Save and close the file.
Step 4. Now open you're web browser and type the following into
the web address:
http://localhost/testphp.php
nstall MySQL
To finish this guide up we will install MySQL. (Note - Out of
Apache and PHP, MySQL is the most difficult to set up. I will provide
some great resources for anyone having trouble at the end of this
guide.)
Step 1. Once again open up the amazing Terminal and then
copy/paste this line:
sudo apt-get install mysql-server
Step 2 (optional). In order for other computers on your network to
view the server you have created, you must first edit the "Bind
Address". Begin by opening up Terminal to edit the my.cnf file.
gksudo gedit /etc/mysql/my.cnf
Change the line
bind-address = 127.0.0.1
And change the 127.0.0.1 to your IP address.
Step 3. This is where things may start to get tricky. Begin by
typing the following into Terminal:
mysql -u root
Following that copy/paste this line:
mysql> SET PASSWORD FOR 'root'@'localhost' =
PASSWORD('yourpassword');
(Make sure to change yourpassword to a password of your choice.)
Step 4. We are now going to install a program called phpMyAdmin
which is an easy tool to edit your databases. Copy/paste the
following line into Terminal:
sudo apt-get install libapache2-mod-auth-mysql php5-mysql
phpmyadmin
After that is installed our next task is to get PHP to work with
MySQL. To do this we will need to open a file entitled php.ini. To
open it type the following:
gksudo gedit /etc/php5/apache2/php.ini
Now we are going to have to uncomment the following line by taking
out the semicolon (;).
Change this line:
;extension=mysql.so
To look like this:
extension=mysql.so
Now just restart Apache and you are all set!
sudo /etc/init.d/apache2 restart
The End
Quick note to anyone who encountered problems with setting up the
MySQL password, please refer to this page: MysqlPasswordReset
I applaud everyone who has taken the time to read this guide. This
guide is also my first ever so I would love to hear back from the
public on what you guys think! Just don't be too harsh. ;)
If you have questions about installing any part of LAMP just drop
them in the comment box and I will do my best to help you out.
设置
Ubuntu文件执行读写权限
LAMP组建安装好之后,
PHP网络服务器根目录默认设置是在:
/var/www。由于
Linux系统的安全性原则,改
目录下的文件读写权限是只允许
root用户操作的,所以我们不能在
www文件夹中新建
php文件,也不能修改和删除,必须要先修改
/var/www目录的
读写权限。在界面管理器中通过右键属性不能修改文件权限,得执行
root终端命令:
sudo
chmod 777 /var/www
。然后就可以写入
html或
php文件了。
如何安装
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。
可能会显然如下错误:
Cannot
load mcrypt extension. Please check your PHP configuration.
解决方法:
sudo
apt-get install php5-mcrypt
sudo /etc/init.d/apache2 restart
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服务器后再试一下。
解决
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
PHP CGI :
sudo /var/www/cgi-bin/
Ubuntu PHP 编辑器
最后
LAMP配置
就完成了,在
Ubuntu下进行简单的
php代码编辑,用
Gedit就可以了。
Gedit支持
HTML,
PHP,
Javascsript等近几十种语言的代码高亮功能。如果是
PHP项目开发,建议使用
PHP
IDE编辑器,比如
Zend
Studio
,
Eclipse。据说文本编辑
VIM也很不错。
PS:如果是
Windows XP 下要搭建
LAMP
环境,建议大家试试
xampp
快速安装配置法,使用也很方便快捷,点击前面的超级链接或
Google一下就知道怎么用了。
分享到:
相关推荐
Ubuntu下LAMP(linux+apache+mysql+php)环境的配置与安装.pdf
主要为大家详细介绍了Ubuntu下图形化LAMP环境配置,感兴趣的小伙伴们可以参考一下
这篇文档介绍如何在Ubuntu下安装配置Lamp环境
据说搞好LAMP也就是Linux+Apache+Mysql+php就已经相当于一个中级php程序猿的水平,当然你的php要得会才行,之后就是搞好各种框架。...一、LAMP的下载、安装与配置 在你装好Ubuntu之后,Ubuntu的安装具体请看:《图
ubuntu,LAMP安装笔记.ubuntu,LAMP安装笔记...
Ubuntu下LAMP(linux+apache+mysql+php)环境的配置与安装参考.pdf
有了开发环境和生产环境的配置区分了。 详细的以后慢慢了解了。 貌似增强了很多功能。 从 phpinfo() 里看出来的。 放出一张刚测试出的phpinfo()截图, 后面张贴一下本次编译的命令记录。 看看编译的一堆命令。 有...
为新手提供可靠 思路清晰 易懂的LAMP(LINUX APACHE MYSQL PHP)环境配置教程。
TuxLite, Debian或者Ubuntu的完整 LAMP 和LNMP设置脚本 TuxLite自述文件TuxLite是一个免费的shell 脚本集合,用于快速部署用于Debian和Ubuntu的LAMP 和LNMP栈( Linux,apache/Nginx,MySQL和 PHP ) 。你认为从共享...
此文基于自己手动编译apache-2.2.11,mysql-5.1.36和php-5.3.0, 环境是在ubuntu 9.04
在这篇文章中,我将描述如何在 Ubuntu Server 16.04 LTS 上安装 LAMP,众所周知 Ubuntu 是一个基于 Linux 的操作系统,因此它构成了 LAMP 的第一个部分,在接下来的操作中,我将默认你已经安装了 Ubuntu Server ...
Linux,Apache,PHP和MySQL设置(灯组) lampset是一个LAMP堆栈配置脚本,专门针对基于Ubuntu的发行版,例如VirtualBox上的Linux Mint , Ubuntu Server和Ubuntu Server 。产品特点( L )inux:基于Ubuntu的发行版...
Linux+Apache+MySQL+PHP搭建web服务器详细图文教程 整体在ubuntu12.04LTS版本下完成
1 支持lamp(linux+apache+php+mysql),lnmp(linux+nginx+php+mysql)环境快速安装部署上线 2 支持lnamp,即支持nginx+apache组合环境的应用,也即是nginx前端处理静态,图片等,apche处理后台php脚本程序。nginx在处理...
基于Linux+appache+Mysql+php的安装配置。
8.1linux上配置环境并启动 8.2Nginx配置https证书 xshell系列问题 .linuxSRE架构图 ubuntu换国内源 加密和安全 搭建DNS服务器 Linux防火墙 WEB服务器APACHE LAMP架构 日志服务管理 网络文件共享服务 备份硬盘数据 ...
无家可归的盒子Ubuntu 18.04 LAMP 使用Ubuntu 18.04 LAMP堆栈制作一个Vagrant盒,并对其进行配置以进行开发。 主机:Linux或Mac。 访客:Ubuntu 18.04,Apache 2.4,MariaDB 10.3,PHP 7.2,Git 2.18。概要在主机...
Ubuntu Server 菜鸟配置手册+Ubuntu 官方文档中文翻译版 适合初学者架设服务器