Home  >  Article  >  php教程  >  PHP学习记录第一篇:Ubuntu14.04下LAMP环境的搭建 - dao_lee

PHP学习记录第一篇:Ubuntu14.04下LAMP环境的搭建 - dao_lee

WBOY
WBOYOriginal
2016-05-20 10:19:211336browse

 

最近一段时间会学习一下PHP全栈开发,将会写一系列的文章来总结学习的过程,以自勉。

第一篇记录一下LAMP环境的安装

0、 安装Apache Web服务器

安装之前先更新一下系统

sudo apt-get update && sudo apt-get dist-upgrade

然后安装Apache

sudo apt-get install apache2

这时在浏览器里输入localhost就可以看到 "It works!", 说明安装成功。

1、 安装MySQL数据库

sudo apt-get install mysql-server php5-mysql

然后是一些安全设置,包括root密码、远程登录等。

sudo mysql_secure_installation

根据需要自行选择有Y / n,就OK了。

2、 安装PHP

安装php5和一些有用的扩展(php5-curl,php5-imagick等):

sudo apt-get install php5 libapache2-mod-php5 php5-mcrypt php5-curl php5-imagick php5-cli

修改Apache的dir.cof文件,以让Apache优先寻找index.php:


    DirectoryIndex index.php index.html index.cgi index.pl index.xhtml index.htm

然后重启Apache web server:

sudo service apache2 restart

3、修改网站的根目录

需要修改两处配置文件

1)修改/etc/apache2/apache2.conf,找到,将/var/www/替换为自己的目录

2)修改/etc/apache2/sites-available/000-default.conf,找到DocumentRoot /var/www/html,将/var/www/html替换为自己的目录

然后重启Apache

sudo service apache2 restart

3)复制"index.html"文件到自己的根目录下

cp /var/www/html/index.html /自己的根目录

4、总结

至此,LAMP环境就安装好了,以后就可以开发属于自己的网站了。

参考链接:

[1] ZH奶酪:Ubuntu 14.04安装LAMP(Linux,Apache,MySQL,PHP)

[2] Ubuntu 14.04 安装 Apache

 

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn