ubuntu server 搭建 LAMP + SVN 《专题》

1、安装ssh,通过远程xshell访问

   使用apt-get命令前,更新下。sudo apt-get update

   更新报错,解决办法

   $ sudo -i

   # apt-get clean

   # cd /var/lib/apt

   # mv lists lists.old

   # mkdir -p lists/partial

   # apt-get clean

   # apt-get update 

   安装ssh命令:sudo apt-get install openssh-server

   安装错误,解决方法一

   安装ssh client

   sudo apt-get openssh-client

   安装报错:Unable to locate package php5-mysql

   解决办法,是因为源的问题,root用户和普通用户之间切换,安装。

2、安装php

     命令:sudo apt-get install php5

    查看php版本:php -v

3、安装apache

   sudo apt-get install apache2

   安装过后,在Firefox中打开:
   http://localhost/,提示成功说明安装成功。

   注意:修改/var/www权限,供外部访问 sudo chmod 777 /var/www

    sudo service apache2 start

    sudo service apache2 stop

    sudo service apache2 restart

   版本查看:apache2 -v

  查看php和apache是否关联成功,执行命令:cat /etc/apache2/mods-enabled/php5.load

  如果不存在,安装关联包

  命令:sudo apt-get install libapache2-mod-php5

4、安装mysql

   命令:sudo apt-get install mysql-server/mysql-server5

   

   查看php和mysql是否关联,执行命令:cat /etc/php5/config.d/mysql.ini

   如果没有关联,安装关联包

   命令:sudo apt-get install php5-mysql

  傻瓜式一键安装 sudo tasksel install lamp-server,或apt-get 后面加多个包

  链接mysql命令:mysql -uuser-ppasword

  退出mysql:quit;

  显示版本:select version();

  

5、配置文件

   ubuntu配置文件:/etc

   各组件配置文件的位置

     

     apache 的配置文件路径 /etc/apache2/apache2.conf
      php.ini 路径 /etc/php5/php5/php5.ini
      mysql配置文件 路径 /etc/mysql/my.cnf

ubuntu server 搭建 LAMP + SVN 《专题》

 ubuntu server 搭建 LAMP + SVN 《专题》

ubuntu server 搭建 LAMP + SVN 《专题》

6、ubuntu下apache虚拟主机配置

     第一步:手动模拟DNS,修改host,域名指向服务器

     bbs.stelin.com 172.16.220.130

     news.stelin.com 172.16.220.130

     m.stelin.com 172.16.220.130

     第二步:ubuntu任何目录下新建三个文件夹存放项目代码

     mkdir /var/wwwroot/bbs

     mkdri /var/wwwroot/news

     mkdir /var/wwwroot/m

    第三步:apache目录,

    /etc/apache2/sites-available/下面新增可以用的虚拟主机配置

    命令:sudo cp default bss

    

   修改复制的  /etc/apache2/sites-available/bbs文件,红色3个地方

   

<VirtualHost *:80>
        ServerName bbs.stelin.com
	ServerAdmin webmaster@localhost

	DocumentRoot /var/wwwroot/bbs
	<Directory />
		Options FollowSymLinks
		AllowOverride None
	</Directory>
	<Directory /var/wwwroot/bbs/>
		Options Indexes FollowSymLinks MultiViews
		AllowOverride None
		Order allow,deny
		allow from all
	</Directory>

	ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
	<Directory "/usr/lib/cgi-bin">
		AllowOverride None
		Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
		Order allow,deny
		Allow from all
	</Directory>

	ErrorLog ${APACHE_LOG_DIR}/error.log

	# Possible values include: debug, info, notice, warn, error, crit,
	# alert, emerg.
	LogLevel warn

	CustomLog ${APACHE_LOG_DIR}/access.log combined

    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory>

</VirtualHost>

    

    /etc/apache2/sites-enabled/目录下面新增软连接(关联sites-available下文件),bbs文件

   命令:sudo ln -s ../sites-available/bbs 000-bbs

   

  修改/var/wwwroot 目录权限,命令:chmod 777 /var/wwroot

  

   重启apache测试。其它m news同样配置

 7、配置phpmyadmin

      第一种:apt-get

                    安装phpmyadmin命令:sudo apt-get install phpmyadmin

                    默认是安装在/usr/share/phpmyadmin目录下面

                    关联wwwroot(apache2配置目录)到phpmyadmin,命令:

                    sudo ln -s /usr/share/phpmyadmin /var/wwwroot/phpmyadmin

                   修改phpmyadmin权限,phpmyadmin设置虚拟主机或放到某个项目下面

      第二种:手动上传

                     上传phpmyadmin文件到某个目录也可以直接是apache项目部署目录,或者其他任意目录通过                         关联文件运行。

 8、配置mysql远程访问,通过工具(sql yog),默认mysql只能本地访问(phpmyadmin)

      修改mysql配置,命令:sudo vi /etc/mysql/my.cnf 

      

#
# The MySQL database server configuration file.
#
# You can copy this to one of:
# - "/etc/mysql/my.cnf" to set global options,
# - "~/.my.cnf" to set user-specific options.
#
# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html

# This will be passed to all mysql clients
# It has been reported that passwords should be enclosed with ticks/quotes
# escpecially if they contain "#" chars...
# Remember to edit /etc/mysql/debian.cnf when changing the socket location.
[client]
port            = 3306
socket          = /var/run/mysqld/mysqld.sock

# Here is entries for some specific programs
# The following values assume you have at least 32M ram

# This was formally known as [safe_mysqld]. Both versions are currently parsed.
[mysqld_safe]
socket          = /var/run/mysqld/mysqld.sock
nice            = 0

[mysqld]
#
# * Basic Settings
#
user            = mysql
pid-file        = /var/run/mysqld/mysqld.pid
socket          = /var/run/mysqld/mysqld.sock
port            = 3306
basedir         = /usr
datadir         = /var/lib/mysql
tmpdir          = /tmp
lc-messages-dir = /usr/share/mysql
skip-external-locking
#
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
# bind-address          = 127.0.0.1
#
# * Fine Tuning
#
key_buffer              = 16M
max_allowed_packet      = 16M
thread_stack            = 192K
thread_cache_size       = 8

    注释掉地址绑定这行(bind-address),前面加“#”

   登录phpmyadmin,“权限”菜单中,添加可以远程访问的用户,并且赋予用户适当的权限,

   新建用户的时候,要注意选择任意主机,选择后输入框不用填写,root用户默认只能在ubuntu上访问

   ubuntu中重启,msyql服务:sudo service mysql restart

   使用远程工具链接mysql,端口号默认(或用修改后的)测试

8、mysql数据库存储目录迁移

9、SVN版本控制器的安装

    首先安装svn,命令:sudo apt-get install subversion

    新建存放svn代码目录:sudo mkdir /usr/share/svn

    新建代码仓库:sudo svnadmin create mycode

   修改代码权限配置:sudo chmod -R 777 svn

   修改配置文件:sudo vi mycode/config/svnserve.conf

  
ubuntu server 搭建 LAMP + SVN 《专题》
 去掉这两处注释,注意前面不能留有空格,修改anon-access = none,匿名用户不能访问,默认匿名用户可以读取

    新增访问svn用户:sudo vi mycode/config/password

   
ubuntu server 搭建 LAMP + SVN 《专题》
 

   查看svn服务是否开启:ps -e

   若开启关闭服务重新开启:sudo kill id(进程id)

   开启命令:sudo svnserve -d -T -r /usr/share/svn

  

  远程通过访问路径:svn://172.16.220.131/mycode,下载代码,输入刚password中任意一个用户名和密码     即可操作

  /var/www/目录,服务器上下载代码命令:svn checkout svn://172.16.220.131/mycode,输入用户名和密     码,www会新增一个mycode目录,

  mycode目录下任意处,可以:sudo svn up(update)更新代码。

  

相关推荐