设为首页 收藏本站
查看: 893|回复: 0

在VMware中搭建LNMP环境+Svn版本控制

[复制链接]

尚未签到

发表于 2015-11-16 12:44:32 | 显示全部楼层 |阅读模式
  一、安装前准备:
DSC0000.jpg


  二、本地源制作
  1)首先在/media目录下创建一个目录cdrom并将将光盘挂载到系统/media/cdrom下
  mkdir /media/cdrom
mount /dev/cdrom /media/cdrom/2)进入到/etc/yum.repos.d目录CentOS-Base.repo重命名。
  cd /etc/yum.repos.d
mv CentOS-Base.repo CentOS-Base.repo.bak
vi CentOS-Media.repo将里面的部分相关的内容修改为

gpgcheck=0

enabled=1


  3)将所有的CentOS安装包链接到/media/CentOS
  ln -s /media/cdrom/CentOS/ /media/CentOS
  三、开始安装
  更新依赖包
yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers patch
安装mysql
/usr/sbin/groupadd mysql
/usr/sbin/useradd -g mysql mysql
cd /usr/local/soft
tar zxvf mysql-5.5.7-rc.tar.gz
cd mysql-5.5.7-rc
./configure --prefix=/usr/local/webserver/mysql/ --enable-assembler --with-extra-charsets=complex --enable-thread-safe-client --with-big-tables --with-readline --with-ssl --with-embedded-server --enable-local-infile --with-plugins=partition,innobase,myisammrg
make && make install
chmod +w /usr/local/webserver/mysql
chown -R mysql:mysql /usr/local/webserver/mysql
cd ../
创建目录
mkdir -p /data0/mysql/3306/data/
mkdir -p /data0/mysql/3306/binlog/
mkdir -p /data0/mysql/3306/relaylog/
chown -R mysql:mysql /data0/mysql/
以mysql用户帐号的身份建立数据表:
/usr/local/webserver/mysql/bin/mysql_install_db --basedir=/usr/local/webserver/mysql --datadir=/data0/mysql/3306/data --user=mysql
vi /data0/mysql/3306/my.cnf
输入
[client]
character-set-server = utf8
port    = 3306
socket  = /tmp/mysql.sock
[mysqld]
character-set-server = utf8
replicate-ignore-db = mysql
replicate-ignore-db = test
replicate-ignore-db = information_schema
user    = mysql
port    = 3306
socket  = /tmp/mysql.sock
basedir = /usr/local/webserver/mysql
datadir = /data0/mysql/3306/data
log-error = /data0/mysql/3306/mysql_error.log
pid-file = /data0/mysql/3306/mysql.pid
open_files_limit    = 10240
back_log = 600
max_connections = 5000
max_connect_errors = 6000
table_cache = 614
external-locking = FALSE
max_allowed_packet = 4M
sort_buffer_size = 1M
join_buffer_size = 1M
thread_cache_size = 300
#thread_concurrency = 8
query_cache_size = 4M
query_cache_limit = 1M
query_cache_min_res_unit = 2k
default-storage-engine = MyISAM
thread_stack = 192K
transaction_isolation = READ-COMMITTED
tmp_table_size = 4M
max_heap_table_size = 16M
long_query_time = 3
log-slave-updates
log-bin = /data0/mysql/3306/binlog/binlog
binlog_cache_size = 1M
binlog_format = MIXED
max_binlog_cache_size = 2M
max_binlog_size = 1G
relay-log-index = /data0/mysql/3306/relaylog/relaylog
relay-log-info-file = /data0/mysql/3306/relaylog/relaylog
relay-log = /data0/mysql/3306/relaylog/relaylog
expire_logs_days = 30
key_buffer_size = 8M
read_buffer_size = 1M
read_rnd_buffer_size = 2M
bulk_insert_buffer_size = 4M
myisam_sort_buffer_size = 16M
myisam_max_sort_file_size = 1G
myisam_repair_threads = 1
myisam_recover
interactive_timeout = 120
wait_timeout = 120
skip-name-resolve
#master-connect-retry = 10
slave-skip-errors = 1032,1062,126,1114,1146,1048,1396
#master-host     =   192.168.1.2
#master-user     =   username
#master-password =   password
#master-port     =  3306
server-id = 1
innodb_additional_mem_pool_size = 8M
innodb_buffer_pool_size = 64M
innodb_data_file_path = ibdata1:256M:autoextend
innodb_file_io_threads = 4
innodb_thread_concurrency = 8
innodb_flush_log_at_trx_commit = 2
innodb_log_buffer_size = 4M
innodb_log_file_size = 32M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 90
innodb_lock_wait_timeout = 120
innodb_file_per_table = 0
#log-slow-queries = /data0/mysql/3306/slow.log
#long_query_time = 10
[mysqldump]
quick
max_allowed_packet = 8M

===========================================================================
创建shell管理脚本
vi /data0/mysql/3306/mysql
输入
#!/bin/sh
mysql_port=3306
mysql_username="root"
mysql_password="12345678"
function_start_mysql()
{
printf "Starting MySQL...\n"
/bin/sh /usr/local/webserver/mysql/bin/mysqld_safe --defaults-file=/data0/mysql/${mysql_port}/my.cnf 2>&1 > /dev/null &
}
function_stop_mysql()
{
printf "Stoping MySQL...\n"
/usr/local/webserver/mysql/bin/mysqladmin -u ${mysql_username} -p${mysql_password} -S /tmp/mysql.sock shutdown
}
function_restart_mysql()
{
printf "Restarting MySQL...\n"
function_stop_mysql
sleep 5
function_start_mysql
}
function_kill_mysql()
{
kill -9 $(ps -ef | grep 'bin/mysqld_safe' | grep ${mysql_port} | awk '{printf $2}')
kill -9 $(ps -ef | grep 'libexec/mysqld' | grep ${mysql_port} | awk '{printf $2}')
}
if [ "$1" = "start" ]; then
function_start_mysql
elif [ "$1" = "stop" ]; then
function_stop_mysql
elif [ "$1" = "restart" ]; then
function_restart_mysql
elif [ "$1" = "kill" ]; then
function_kill_mysql
else
printf "Usage: /data0/mysql/${mysql_port}/mysql {start|stop|restart|kill}\n"
fi
============================================================================================================
chmod +x /data0/mysql/3306/mysql
启动mysql
/data0/mysql/3306/mysql start
登陆mysql
/usr/local/webserver/mysql/bin/mysql -u root -p -S /tmp/mysql.sock
创建用户并赋予权限
GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY '12345678';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'127.0.0.1' IDENTIFIED BY '12345678';

flush privileges;
======================================================================================
安装php
首先安装依赖库
tar zxvf libiconv-1.13.1.tar.gz
cd libiconv-1.13.1/
./configure --prefix=/usr/local
make
make install
cd ../
tar zxvf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8/
./configure
make
make install
/sbin/ldconfig
cd libltdl/
./configure --enable-ltdl-install
make
make install
cd ../../
tar zxvf mhash-0.9.9.9.tar.gz
cd mhash-0.9.9.9/
./configure
make
make install
cd ../
ln -s /usr/local/lib/libmcrypt.la /usr/lib/libmcrypt.la
ln -s /usr/local/lib/libmcrypt.so /usr/lib/libmcrypt.so
ln -s /usr/local/lib/libmcrypt.so.4 /usr/lib/libmcrypt.so.4
ln -s /usr/local/lib/libmcrypt.so.4.4.8 /usr/lib/libmcrypt.so.4.4.8
ln -s /usr/local/lib/libmhash.a /usr/lib/libmhash.a
ln -s /usr/local/lib/libmhash.la /usr/lib/libmhash.la
ln -s /usr/local/lib/libmhash.so /usr/lib/libmhash.so
ln -s /usr/local/lib/libmhash.so.2 /usr/lib/libmhash.so.2
ln -s /usr/local/lib/libmhash.so.2.0.1 /usr/lib/libmhash.so.2.0.1
ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config
tar zxvf mcrypt-2.6.8.tar.gz
cd mcrypt-2.6.8/
/sbin/ldconfig
./configure
make
make install
cd ../

tar zxvf php-5.2.14.tar.gz
gzip -cd php-5.2.14-fpm-0.5.14.diff.gz | patch -d php-5.2.14 -p1
cd php-5.2.14/
./configure --prefix=/usr/local/webserver/php --with-config-file-path=/usr/local/webserver/php/etc --with-mysql=/usr/local/webserver/mysql --with-mysqli=/usr/local/webserver/mysql/bin/mysql_config --with-iconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-discard-path --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-fastcgi --enable-fpm --enable-force-cgi-redirect --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-ldap --with-ldap-sasl --with-xmlrpc --enable-zip --enable-soap
make ZEND_EXTRA_LIBS='-liconv'
make install
cp php.ini-dist /usr/local/webserver/php/etc/php.ini
cd ../

编译扩展模块
tar zxvf memcache-2.2.5.tgz
cd memcache-2.2.5/
/usr/local/webserver/php/bin/phpize
./configure --with-php-config=/usr/local/webserver/php/bin/php-config
make
make install
cd ../
tar jxvf eaccelerator-0.9.6.1.tar.bz2
cd eaccelerator-0.9.6.1/
/usr/local/webserver/php/bin/phpize
./configure --enable-eaccelerator=shared --with-php-config=/usr/local/webserver/php/bin/php-config
make
make install
cd ../
tar zxvf PDO_MYSQL-1.0.2.tgz
cd PDO_MYSQL-1.0.2/
/usr/local/webserver/php/bin/phpize
./configure --with-php-config=/usr/local/webserver/php/bin/php-config --with-pdo-mysql=/usr/local/webserver/mysql
make
make install
cd ../
tar zxvf ImageMagick.tar.gz
cd ImageMagick-6.5.1-2/
./configure
make
make install
cd ../
tar zxvf imagick-2.3.0.tgz
cd imagick-2.3.0/
/usr/local/webserver/php/bin/phpize
./configure --with-php-config=/usr/local/webserver/php/bin/php-config
make
make install
cd ../

修改php.ini文件
  手工修改:查找/usr/local/webserver/php/etc/php.ini中的extension_dir = "./"
  修改为extension_dir = "/usr/local/webserver/php/lib/php/extensions/no-debug-non-zts-20060613/"
  并在此行后增加以下几行,然后保存:
  extension = "memcache.so"
  extension = "pdo_mysql.so"
  extension = "imagick.so"
  再查找output_buffering = Off
  修改为output_buffering = On
  再查找; cgi.fix_pathinfo=0  去掉;
  并且修改为cgi.fix_pathinfo=1    打开pathinfo支持  
  自动修改:若嫌手工修改麻烦,可执行以下shell命令,自动完成对php.ini文件的修改:
sed -i 's#extension_dir = "./"#extension_dir = "/usr/local/webserver/php/lib/php/extensions/no-debug-non-zts-20060613/"\nextension = "memcache.so"\nextension = "pdo_mysql.so"\nextension = "imagick.so"\n#' /usr/local/webserver/php/etc/php.ini
sed -i 's#output_buffering = Off#output_buffering = On#' /usr/local/webserver/php/etc/php.ini
sed -i "s#; always_populate_raw_post_data = On#always_populate_raw_post_data = On#g" /usr/local/webserver/php/etc/php.ini
sed -i "s#; cgi.fix_pathinfo=0#cgi.fix_pathinfo=1#g" /usr/local/webserver/php/etc/php.ini
配置eAccelerator加速PHP:
mkdir -p /usr/local/webserver/eaccelerator_cache
vi /usr/local/webserver/php/etc/php.ini
  文件的最末尾,加上以下配置信息:
=================================================================================================================
[eaccelerator]
zend_extension="/usr/local/webserver/php/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so"
eaccelerator.shm_size="64"
eaccelerator.cache_dir="/usr/local/webserver/eaccelerator_cache"
eaccelerator.enable="1"
eaccelerator.optimizer="1"
eaccelerator.check_mtime="1"
eaccelerator.debug="0"
eaccelerator.filter=""
eaccelerator.shm_max="0"
eaccelerator.shm_ttl="3600"
eaccelerator.shm_prune_period="3600"
eaccelerator.shm_only="0"
eaccelerator.compress="1"
eaccelerator.compress_level="9"
===================================================================================================================

创建www用户和组
/usr/sbin/groupadd www
/usr/sbin/useradd -g www www
mkdir -p /data0/htdocs/blog
chmod +w /data0/htdocs/blog
chown -R www:www /data0/htdocs/blog
mkdir -p /data0/htdocs/www
chmod +w /data0/htdocs/www
chown -R www:www /data0/htdocs/www
配置fpm
rm -f /usr/local/webserver/php/etc/php-fpm.conf
vi /usr/local/webserver/php/etc/php-fpm.conf
输入
<?xml version=&quot;1.0&quot; ?>
<configuration>
All relative paths in this config are relative to php's install prefix
<section name=&quot;global_options&quot;>
Pid file
<value name=&quot;pid_file&quot;>/usr/local/webserver/php/logs/php-fpm.pid</value>
Error log file
<value name=&quot;error_log&quot;>/usr/local/webserver/php/logs/php-fpm.log</value>
Log level
<value name=&quot;log_level&quot;>notice</value>
When this amount of php processes exited with SIGSEGV or SIGBUS ...
<value name=&quot;emergency_restart_threshold&quot;>2</value>
... in a less than this interval of time, a graceful restart will be initiated.
Useful to work around accidental curruptions in accelerator's shared memory.
<value name=&quot;emergency_restart_interval&quot;>1m</value>
Time limit on waiting child's reaction on signals from master
<value name=&quot;process_control_timeout&quot;>5s</value>
Set to 'no' to debug fpm
<value name=&quot;daemonize&quot;>yes</value>
</section>
<workers>
<section name=&quot;pool&quot;>
Name of pool. Used in logs and stats.
<value name=&quot;name&quot;>default</value>
Address to accept fastcgi requests on.
Valid syntax is 'ip.ad.re.ss:port' or just 'port' or '/path/to/unix/socket'
<value name=&quot;listen_address&quot;>127.0.0.1:9000</value>
<value name=&quot;listen_options&quot;>
Set listen(2) backlog
<value name=&quot;backlog&quot;>-1</value>
Set permissions for unix socket, if one used.
In Linux read/write permissions must be set in order to allow connections from web server.
Many BSD-derrived systems allow connections regardless of permissions.
<value name=&quot;owner&quot;></value>
<value name=&quot;group&quot;></value>
<value name=&quot;mode&quot;>0666</value>
</value>
Additional php.ini defines, specific to this pool of workers.
<value name=&quot;php_defines&quot;>
<value name=&quot;sendmail_path&quot;>/usr/sbin/sendmail -t -i</value>
<value name=&quot;display_errors&quot;>1</value>
</value>
Unix user of processes
<value name=&quot;user&quot;>www</value>
Unix group of processes
<value name=&quot;group&quot;>www</value>
Process manager settings
<value name=&quot;pm&quot;>
Sets style of controling worker process count.
Valid values are 'static' and 'apache-like'
<value name=&quot;style&quot;>static</value>
Sets the limit on the number of simultaneous requests that will be served.
Equivalent to Apache MaxClients directive.
Equivalent to PHP_FCGI_CHILDREN environment in original php.fcgi
Used with any pm_style.
<value name=&quot;max_children&quot;>2</value>
Settings group for 'apache-like' pm style
<value name=&quot;apache_like&quot;>
Sets the number of server processes created on startup.
Used only when 'apache-like' pm_style is selected
<value name=&quot;StartServers&quot;>20</value>
Sets the desired minimum number of idle server processes.
Used only when 'apache-like' pm_style is selected
<value name=&quot;MinSpareServers&quot;>5</value>
Sets the desired maximum number of idle server processes.
Used only when 'apache-like' pm_style is selected
<value name=&quot;MaxSpareServers&quot;>35</value>
</value>
</value>
The timeout (in seconds) for serving a single request after which the worker process will be terminated
Should be used when 'max_execution_time' ini option does not stop script execution for some reason
'0s' means 'off'
<value name=&quot;request_terminate_timeout&quot;>0s</value>
The timeout (in seconds) for serving of single request after which a php backtrace will be dumped to slow.log file
'0s' means 'off'
<value name=&quot;request_slowlog_timeout&quot;>0s</value>
The log file for slow requests
<value name=&quot;slowlog&quot;>logs/slow.log</value>
Set open file desc rlimit
<value name=&quot;rlimit_files&quot;>65535</value>
Set max core size rlimit
<value name=&quot;rlimit_core&quot;>0</value>
Chroot to this directory at the start, absolute path
<value name=&quot;chroot&quot;></value>
Chdir to this directory at the start, absolute path
<value name=&quot;chdir&quot;></value>
Redirect workers' stdout and stderr into main error log.
If not set, they will be redirected to /dev/null, according to FastCGI specs
<value name=&quot;catch_workers_output&quot;>yes</value>
How much requests each process should execute before respawn.
Useful to work around memory leaks in 3rd party libraries.
For endless request processing please specify 0
Equivalent to PHP_FCGI_MAX_REQUESTS
<value name=&quot;max_requests&quot;>1024</value>
Comma separated list of ipv4 addresses of FastCGI clients that allowed to connect.
Equivalent to FCGI_WEB_SERVER_ADDRS environment in original php.fcgi (5.2.2+)
Makes sense only with AF_INET listening socket.
<value name=&quot;allowed_clients&quot;>127.0.0.1</value>
Pass environment variables like LD_LIBRARY_PATH
All $VARIABLEs are taken from current environment
<value name=&quot;environment&quot;>
<value name=&quot;HOSTNAME&quot;>$HOSTNAME</value>
<value name=&quot;PATH&quot;>/usr/local/bin:/usr/bin:/bin</value>
<value name=&quot;TMP&quot;>/tmp</value>
<value name=&quot;TMPDIR&quot;>/tmp</value>
<value name=&quot;TEMP&quot;>/tmp</value>
<value name=&quot;OSTYPE&quot;>$OSTYPE</value>
<value name=&quot;MACHTYPE&quot;>$MACHTYPE</value>
<value name=&quot;MALLOC_CHECK_&quot;>2</value>
</value>
</section>
</workers>
</configuration>
=======================================================
启动
ulimit -SHn 65535
/usr/local/webserver/php/sbin/php-fpm start
安装Nginx 0.8.53
  1、安装Nginx所需的pcre库:
tar zxvf pcre-8.10.tar.gz
cd pcre-8.10/
./configure
make && make install   
cd ../

  2、安装Nginx
tar zxvf nginx-0.8.53.tar.gz
cd nginx-0.8.53/
./configure --user=www --group=www --prefix=/usr/local/webserver/nginx --with-http_stub_status_module --with-http_ssl_module
make
make install
cd ../

  3、创建Nginx日志目录
mkdir -p /data1/logs
chmod +w /data1/logs
chown -R www:www /data1/logs

  4、创建Nginx配置文件
  ①、在/usr/local/webserver/nginx/conf/目录中创建nginx.conf文件:
rm -f /usr/local/webserver/nginx/conf/nginx.conf
vi /usr/local/webserver/nginx/conf/nginx.conf
输入
user  www www;
worker_processes 2;
error_log  /data1/logs/nginx_error.log  crit;
pid        /usr/local/webserver/nginx/nginx.pid;
#Specifies the value for maximum file descriptors that can be opened by this process.
worker_rlimit_nofile 65535;
events
{
use epoll;
worker_connections 65535;
}
http
{
include       mime.types;
default_type  application/octet-stream;
#charset  gb2312;
server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_max_body_size 8m;
sendfile on;
tcp_nopush     on;
keepalive_timeout 60;
tcp_nodelay on;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 128k;
gzip on;
gzip_min_length  1k;
gzip_buffers     4 16k;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_types       text/plain application/x-javascript text/css application/xml;
gzip_vary on;
#limit_zone  crawler  $binary_remote_addr  10m;
server
{
listen       80;
server_name  www.sunny.com;
index index.html index.htm index.php;
root  /data0/htdocs/blog;
#limit_conn   crawler  20;   
location ~* .*\.php($|/){
include  fcgi.conf;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires      30d;
}
location ~ .*\.(js|css)?$
{
expires      1h;
}   
log_format  access  '$remote_addr - $remote_user [$time_local] &quot;$request&quot; '
'$status $body_bytes_sent &quot;$http_referer&quot; '
'&quot;$http_user_agent&quot; $http_x_forwarded_for';
access_log  /data1/logs/access.log  access;
}
server
{
listen       80;
server_name  mysql.sunny.com;
index index.html index.htm index.php;
root  /data0/htdocs/www;
location ~* .*\.php($|/){
include  fcgi.conf;
}
log_format  wwwlogs  '$remote_addr - $remote_user [$time_local] &quot;$request&quot; '
'$status $body_bytes_sent &quot;$http_referer&quot; '
'&quot;$http_user_agent&quot; $http_x_forwarded_for';
access_log  /data1/logs/wwwlogs.log  wwwlogs;
}

}

=====================编辑cgi配置文件==============
vi /usr/local/webserver/nginx/conf/fcgi.conf
输入:
if ($request_filename ~* (.*)\.php) {
set $php_url $1;
}
if (!-e $php_url.php) {
return 403;
}

fastcgi_pass   127.0.0.1:9000;
fastcgi_index  index.php;
set $path_info &quot;&quot;;
set $real_script_name $fastcgi_script_name;
if ($fastcgi_script_name ~ &quot;^(.+?\.php)(/.+)$&quot;) {
set $real_script_name $1;
set $path_info $2;
}
fastcgi_param SCRIPT_FILENAME $document_root$real_script_name;
fastcgi_param SCRIPT_NAME $real_script_name;
fastcgi_param PATH_INFO $path_info;
## 以上是支持pathinfo的重点部分
fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;
fastcgi_param  SERVER_SOFTWARE    nginx;
fastcgi_param  QUERY_STRING       $query_string;
fastcgi_param  REQUEST_METHOD     $request_method;
fastcgi_param  CONTENT_TYPE       $content_type;
fastcgi_param  CONTENT_LENGTH     $content_length;
#fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;
#fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;
fastcgi_param  REQUEST_URI        $request_uri;
fastcgi_param  DOCUMENT_URI       $document_uri;
fastcgi_param  DOCUMENT_ROOT      $document_root;
fastcgi_param  SERVER_PROTOCOL    $server_protocol;
fastcgi_param  REMOTE_ADDR        $remote_addr;
fastcgi_param  REMOTE_PORT        $remote_port;
fastcgi_param  SERVER_ADDR        $server_addr;
fastcgi_param  SERVER_PORT        $server_port;
fastcgi_param  SERVER_NAME        $server_name;

启动nginx
ulimit -SHn 65535
/usr/local/webserver/nginx/sbin/nginx
配置开机自启动
vi /etc/rc.local
输入
ulimit -SHn 65535
/usr/local/webserver/php/sbin/php-fpm start
/usr/local/webserver/nginx/sbin/nginx
/data0/mysql/3306/mysql start





开始搭建SVN版本控制:  1.安装svn服务器端

yum install subversion      //从镜像下载安装svn服务器端

cd /usr/local/                  //进入目录,准备创建svn目录

mkdir svn                      //创建一个svn目录

chmod -R 777 svn            //修改目录权限为777

svnadmin create /usr/local/svn/sunny  //创建一个svn版本仓库sunny(sunny可以随便起)

cd svn/sunny/conf               //进入sunny版本仓库下的配置文件目录





下面要修改这个目录下的三个配置文件

(1)vi svnserve.conf    //配置版本库信息和用户文件和用户密码文件的路径、版本库路径







# anon-access = read

# auth-access = write

# password-db = passwd

//这四行,前面的#号和空&#26684;去掉(注意去掉#要顶&#26684;写,不要留有多余空&#26684;),变成

anon-access = none      //改成none

auth-access = write

password-db = passwd

realm = sunny           //改成自己的版本库

保存





(2)vi authz     //文件,创建svn组和组用户的权限

[group]

sunny = gep,wce //创建一个sunny的组,并指定两个用户gep和wce





[/]             //制定根目录下的权限

@sunny = rw     //sunny组用户权限为读写

* = r           //其他用户只有读权限

保存退出





(3) vi passwd   //创建或修改用户密码

[users]

gep = 123456    //用户名为gep的用户的密码为123456

wce = 123456    //。。。

保存退出









启动svn:

svnserve -d -r /usr/local/svn/     //这里采用多版本库的方式启动  如果是单版本库 可以svnserve -d -r /usr/local/svn/sunny

添加一行

然后要设置自启动

vi /etc/rc.local    打开自启动文件添加

/usr/bin/svnserve -d -r /usr/local/svn/





到此为止可以从服务端检出文件了.





svn命令:

netstat -tnl |grep :3690   查看svn是否启动

ps aux |grep 'svn'  查找所有svn启动的进程

kill -9 2505    杀死2505这个查找到的svn进程









svn checkout svn://172.19.5.2/sunny /data0/htdocs/blog  //检出一份版本库文件到指定目录(这里ip地址是安装Svn的服务器)

svn up                        //更新文件





自动更新

在vi /usr/local/svn/sunny/hooks/post-commit中加入





#!/bin/sh

SVN=/usr/bin/svn  

WEB=/home/testsvn  

export LANG=en_US.UTF-8

$SVN update $WEB --username xxx --password xxx









其中SVN=右边改成 svn 命令位置 一般默认为/usr/bin/svn

        WEB=右边改成你实际的web目录

赋予可执行权限

chmod 777 /usr/local/svn/sunny/hooks/post-commit

安装完毕









=========================================================================

其他操作





#svn commit -m &quot;注释&quot; xxx.php  //提交文件

svn ci -m'aaa' test.php       //提交文件





#svn add file               //新建文件并添加到svn

svn add *.php               //(添加当前目录下所有的php文件)

svn delete test.php         //删除test.php

svn log test.php            //查看test文件的log信息

svn cleanup                 //清理当前目录







svn switch --relocate svn://192.168.1.253  svn://172.19.10.250      //重新定位SVN版本库地址





// SVN版本库起动方式,现在SVN下面有 sunny、test 两个版本库

1:单版本库起动    svnserve -d -r /usr/local/svn/sunny

2:多版本库起动    svnserve -d -r /usr/local/svn

区别在于起动svn时候的命令中的启动参数-r指定的目录。





限制不同的用户对不同的版本库操作权限,修改版本库中的conf目录下的 authz文件





以配置 sunny 版本库为例

vi authz

[groups]

teacher = sunny,sunny1

[sunny:/]             //指定版本库跟目录下的权限

@teacher = rw     //teacher组用户权限为读写

* = r           //其他用户只有读权限

保存退出





vi passwd 设置组中用户的账号和密码

[users]

sunny  = 123456

sunny1 = 123456


  




  



版权声明:本文为博主原创文章,未经博主允许不得转载。

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-139916-1-1.html 上篇帖子: 轻松获取LAMP,LNMP环境编译参数配置 2 下篇帖子: 在VMware中搭建LNMP环境+Svn版本控制
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表