http://www.2cto.com/os/201505/401588.html

Ubuntu+Apache+PHP+Mysql环境搭建(完整版)

一、操作系统
Ubuntu 14.04 64位,阿里云服务器

二、Apache

1、安装Apache,安装命令:sudo apt-get install apache2

2、环境配置:

1)配置文件:路径为/etc/apache2,配置文件是apache2.conf,而没有http.conf。

2)默认网站根目录:/var/www/html,使用浏览器访问http://localhost 即可打开;

3)修改网站根目录:

A、“sudo vim /etc/apache2/apache2.conf"-->找到""的位置-->更改"/var/www/"为新的根目录“/home/www”即可

B、"sudo vi/etc/apache2/sites-available/000-default.conf"-->找到"DocumentRoot /var/www/html"的位置-->更改"/var/www/html"为新的根目录“/home/www”即可。

4)重启Apache服务器: sudo /etc/init.d/apache2 restart

三、PHP

1、更新源列表,否则安装php会失败:

命令行输入: vim /etc/apt/source.list

在最前面添加以下内容:

deb http://mirrors.aliyun.com/ubuntu/ precise main restricteduniverse multiverse

deb http://mirrors.aliyun.com/ubuntu/ precise-security mainrestricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ precise-updates mainrestricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ precise-proposed mainrestricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ precise-backports mainrestricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ precise mainrestricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ precise-securitymain restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ precise-updatesmain restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ precise-proposedmain restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ precise-backportsmain restricted universe multiverse

********************************************************************************

源的版本2

deb http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse

apt-get update //更新一下列表

2、安装PHP,安装命令:sudoapt-get install php5

3、让Apache支持php,安装命令:sudo apt-get install libapache2-mod-php5

4、安装php5-gd模块,安装命令:sudoapt-get install php5-gd

5、让PHP支持curl

1)首先查看php5-curl是否已安装:dpkg -l | grep 'php5-curl'
2)如果没有安装,则:apt-get install php5-curl

3)确保 extension_dir存在,并且包含curl.so,

查找extension_dir:php -i | grep extension_dir

4)确保 /etc/php5/mods-available/curl.ini存在,文件内容如下:

; configuration for php CURL module
; priority=20
extension=curl.so

PDO已是PHP的核心,无需再安装。

只需安装php5的mysql数据库扩展php5-mysql:

sudo apt-get install php5-mysql

这样就可以使用PDO了,不需要修改php.ini。需要重启服务器。

5)如果以上步骤均确定,重启服务器。

四、Mysql

1、安装Mysql,安装命令:sudoapt-get install mysql-server,安装过程中设置密码

2、允许root远程登录:

1)从所有主机:grant all privileges on *.* to root@"%" identified by "passw0rd" with grant option;

2)can't connect to mysql server解决方法:修改配置文件,路径为/etc/mysql/my.cnf,注释掉bind-address = 127.0.0.0

即:#bind-address = 127.0.0.1

五、FTP

1、安装FTP,安装命令:sudoapt-get install vsftpd

2、查看是否安装成功:输入"sudo service vsftpdrestart"重启vsftpd服务

3、建立FTP目录: sudo mkdir/home/ftpfile/ftpfile

4、新建ftp用户: sudouseradd –d /home/ftpfile –s /bin/bash myftp

5、设置myftp用户密码: sudopasswd myftp ,输入两次密码

6、修改ftp配置文件,路径为/etc/vsftpd.conf,

1)配置修改如下:

anonymous_enable=NO

local_enable=YES

write_enable=YES

chroot_local_user=YES

chroot_list_enable=YES

chroot_list_file=/etc/vsftpd.chroot_list

2)在/etc/目录中新建vsftpd.chroot_list文件,添加ftp用户名:myftp。或直接:

echo “myftp” >> /etc/vsftpd.chroot_list 即可。

六、SVN

1、安装SVN,安装命令:sudo apt-get install subversion

2、创建SVN工程:sudo svnadmin create /home/svn/kyssp

3、修改svn配置: vim /home/svn/kyssp_pub/conf/svnserve.conf

anon-access = read

auth-access = write

password-db = passwd

4、设置访问用户以及密码: 编辑文件vim /home/svn/kyssp_pub/conf/passwd

在最后一行添加:用户名 = 密码

5、启动svn:svnserve -d-r /home/svn/

6、使用SVN的post-commithooks 同步推送代码到生产环境

1)进入/home/svn/kyssp/hooks目录,cp post-commit.tmpl post-commit

2)在最后,添加如下:

REPOS="$1"

REV="$2"

#TXN_NAME="$3"

WEB_PATH="/home/www/kyssp"

#"$REPOS"/hooks/mailer.py commit "$REPOS"$REV "$REPOS"/mailer.conf

#export LANG=zh_CN.UTF-8

export LANG=en_US.UTF-8

#

#svn co --username zrs --password zrs@tzuo.cnsvn://112.74.**.**/kyssp_pub /home/www/kyssp

svn update --username zrs --password zrs@tzuo.cn /home/www/kyssp

其中:

svn co --username zrs --password zrs@tzuo.cnsvn://112.74.**.**/kyssp /home/software/www/kyssp 下载工程代码

svn update --username z** --password z*** /home/software/www/kyssp 更新工程代码

最新文章

  1. java 单例(懒汉式)
  2. python-实现生产者消费者模型
  3. This Node源码分析
  4. HTML5+jquery整屏页面切换效果
  5. php计算时间差
  6. 把数据保存到数据库附加表 `dede_addonarticle` 时出错,请把相关信息提交给DedeCms官方。Duplicate entry
  7. PAT乙级 1013. 数素数 (20)
  8. 分页 page
  9. linux命令之more
  10. 95秀-异步http请求完整过程
  11. LeeCode-Linked List Cycle
  12. struts2整合json要注意的问题
  13. NEWS-包名-baseTest-类名-baeseDao
  14. 学习笔记—MySQL基础
  15. [Swift]LeetCode335. 路径交叉 | Self Crossing
  16. 快速查看linux命令的用法----------TLDR
  17. 仅仅有五行的Floyd最短路算法
  18. java调用url
  19. UVA10341 Solve It
  20. 几种梯度下降方法对比(Batch gradient descent、Mini-batch gradient descent 和 stochastic gradient descent)

热门文章

  1. CodeForces - 627A
  2. 20190829 [ Night ] - 玻
  3. 公司-广告-WPP:WPP
  4. Could not parse mapping document from resource com/hs/model/StudentModel.hbm.xml
  5. 使用junit单元测试,报Cannot instantiate test(s): java.lang.SecurityException: Prohibited package name: java.com.com.test
  6. 洛谷P1080 [NOIP2012提高组D1T2]国王游戏 [2017年5月计划 清北学堂51精英班Day1]
  7. js计算精度问题(浮点数误差,大数计算出错)
  8. 公司mysql问题三
  9. python 爬取段子网段子写入文件
  10. 生成mysql数据字典