CentOS 6.2 項目管理軟件Redmine SVN 集成之LNMP平臺準備(上)

Redmine是用Ruby開發的基於web的項目管理軟件,是用ROR框架開發的一套跨平臺項目管理系統,據說是源於Basecamp的ror版而來,支持多種數據庫,有不少自己獨特的功能,例如提供wiki、新聞臺等,還可以集成其他版本管理系統和BUG跟蹤系統,例如SVN、CVS、TD等等。這種 Web 形式的項目管理系統通過“項目(Project)”的形式把成員、任務(問題)、文檔、討論以及各種形式的資源組織在一起,大家參與更新任務、文檔等內容來推動項目的進度,同時系統利用時間線索和各種動態的報表形式來自動給成員彙報項目進度

這東西相對Mantis來說,我覺得看相還是不錯的,但是由於是ruby寫的,同時我又不是程序員,不好去評價一個東西的好壞,但是這東西就是有人用,開工,我會盡量弄詳細點,赫赫.....

1、編譯PHP所需要的庫

libiconv庫爲需要做轉換的應用提供了一個iconv()的函數,以實現一個字符編碼到另一個字符編碼的轉換

[root@ErpServer script]# tar zxf libiconv-1.13.1.tar.gz
[root@ErpServer script]# cd libiconv-1.13.1
[root@ErpServer libiconv-1.13.1]# ./configure --prefix=/usr/local 
[root@ErpServer libiconv-1.13.1]# make && make install

libmcrypt是加密算法擴展庫。支持DES, 3DES, RIJNDAEL, Twofish, IDEA, GOST, CAST-256, ARCFOUR, SERPENT, SAFER+等算法。

[root@ErpServer script]# tar zxf libmcrypt-2.5.8.tar.gz
[root@ErpServer script]# cd libmcrypt-2.5.8/ 
[root@ErpServer libmcrypt-2.5.8]# ./configure 
[root@ErpServer libmcrypt-2.5.8]# make && make install 
[root@ErpServer libmcrypt-2.5.8]# /sbin/ldconfig 
[root@ErpServer libmcrypt-2.5.8]# cd libltdl/
[root@ErpServer libltdl]# ./configure --enable-ltdl-install 
[root@ErpServer libltdl]# make && make install

Mhash爲PHP提供了多種哈希算法,如MD5,SHA1,GOST 等。你可以通過MHASH_hashname()來查看支持的算法有哪些。

[root@ErpServer script]# tar jxf mhash-0.9.9.9.tar.bz2 
[root@ErpServer script]# cd mhash-0.9.9.9
[root@ErpServer mhash-0.9.9.9]# ./configure 
[root@ErpServer mhash-0.9.9.9]# make && make install
[root@ErpServer mhash-0.9.9.9]# echo "/usr/local/lib" >>/etc/ld.so.conf && /sbin/ldconfig

Mcrypt庫支持20多種加密算法和8種加密模式,具體可以通過函數mcrypt_list_algorithms()和mcrypt_list_modes()來顯示

[root@ErpServer script]# tar zxf mcrypt-2.6.8.tar.gz 
[root@ErpServer script]# cd mcrypt-2.6.8
[root@ErpServer mcrypt-2.6.8]# /sbin/ldconfig 
[root@ErpServer mcrypt-2.6.8]# ./configure && make && make install

編譯安裝mysql,有關mysql的編譯參數以及使用,請參考我前面的文章

[root@ErpServer script]# tar zxf mysql-5.1.68.tar.gz 
[root@ErpServer script]# cd mysql-5.1.68
[root@ErpServer mysql-5.1.68]# /usr/sbin/groupadd mysql 
[root@ErpServer mysql-5.1.68]# /usr/sbin/useradd -g mysql mysql 
[root@ErpServer mysql-5.1.68]# ./configure --prefix=/software/mysql --enable-assembler --with-extra-charsets=complex --enable-thread-safe-client --with-big-tables --with-readline --with-ssl --with-embedded-server --enable-local-infile 
[root@ErpServer mysql-5.1.68]# make && make install 
[root@ErpServer mysql-5.1.68]# chown -R mysql:mysql /software/mysql/
[root@ErpServer mysql-5.1.68]# chmod u+w /software/mysql/
[root@ErpServer mysql-5.1.68]# mkdir -p /data/database
[root@ErpServer mysql-5.1.68]# chown -R mysql:mysql /data/database/

以mysql用戶帳號的身份建立數據表:

[root@ErpServer mysql-5.1.68]# /software/mysql/bin/mysql_install_db --basedir=/software/mysql/ --datadir=/data/database/ --user=mysql

創建mysql配置文件

[root@ErpServer mysql-5.1.68]# cat /software/mysql/my.cnf
[client]
port = 3306
socket = /tmp/mysql.sock
[mysql]
no-auto-rehash
[mysqld]
user = mysql
port = 3306
socket = /tmp/mysql.sock
basedir = /software/mysql
datadir = /data/database
open_files_limit = 600
back_log = 20
max_connections = 1000
max_connect_errors = 200
table_cache = 60
external-locking = FALSE
max_allowed_packet = 16M
sort_buffer_size = 128K
join_buffer_size = 128K 
thread_cache_size = 10
thread_concurrency = 8
query_cache_size = 2M
query_cache_limit = 2M
query_cache_min_res_unit = 2k
default_table_type = MyISAM
thread_stack = 192K
transaction_isolation = READ-UNCOMMITTED
tmp_table_size = 512K
max_heap_table_size = 32M
long_query_time = 1
log_long_format
server-id = 1
#log-bin = /data/soft/mysql/binlog
binlog_cache_size = 2M
max_binlog_cache_size = 4M
max_binlog_size = 512M
expire_logs_days = 7
key_buffer_size = 4M
read_buffer_size = 1M
read_rnd_buffer_size = 2M
bulk_insert_buffer_size = 2M
myisam_sort_buffer_size = 4M
myisam_max_sort_file_size = 10G
myisam_max_extra_sort_file_size = 10G
myisam_repair_threads = 1
myisam_recover
[mysqldump]
quick
max_allowed_packet = 16M

修改mysqld腳本

[root@ErpServer mysql-5.1.68]# cp /software/mysql/share/mysql/mysql.server /etc/init.d/mysqld
[root@ErpServer mysql-5.1.68]# vi /etc/init.d/mysqld 
basedir=/software/mysql
datadir=/data/database

啓動mysql

[root@ErpServer mysql-5.1.68]# service mysqld start
[root@ErpServer mysql-5.1.68]# lsof -i:3306
COMMAND   PID  USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
mysqld  28805 mysql    3u  IPv4  87995      0t0  TCP *:mysql (LISTEN)
[root@ErpServer mysql-5.1.68]# netstat -pant | grep 3306
tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN      28805/mysqld

測試登錄mysql 並設置數據庫密碼

[root@ErpServer mysql-5.1.68]# /software/mysql/bin/mysql -u root -p
mysql> DELETE FROM mysql.user WHERE host='localhost' AND user='';
mysql> FLUSH PRIVILEGES; #設置root密碼,quit退出
mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('chenyi');

自啓動

[root@ErpServer mysql-5.1.68]# chkconfig --add mysqld
[root@ErpServer mysql-5.1.68]# chkconfig mysqld on
[root@ErpServer mysql-5.1.68]# chkconfig --list | grep mysqld
mysqld         	0:off	1:off	2:on	3:on	4:on	5:on	6:off

編譯安裝PHP(FastCGI)

[root@ErpServer script]# tar zxf php-5.2.17.tar.gz
[root@ErpServer script]# gzip -cd php-5.2.17-fpm-0.5.14.diff.gz | patch -d php-5.2.17 -p1
[root@ErpServer script]# cd php-5.2.17
[root@ErpServer php-5.2.17]# patch -p1 <../php-5.2.17-max-input-vars.patch 
[root@ErpServer php-5.2.17]# sed -i "s/\!png_check_sig (sig, 8)/png_sig_cmp (sig, 0, 8)/" ext/gd/libgd/gd_png.c

編譯參數:

[root@ErpServer php-5.2.17]# ./configure --prefix=/software/php --with-config-file-path=/software/php/etc --with-mysql=/software/mysql --with-mysqli=/software/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

如果是64位系統 由於庫原因會出現 configure: error: libjpeg.(a|so) not found. 解決方法如下:

[root@localhost php-5.2.17]# cp -frp /usr/lib64/libjpeg.* /usr/lib/
[root@localhost php-5.2.17]# cp -frp /usr/lib64/libpng* /usr/lib/
[root@localhost php-5.2.17]# cp -frp /usr/lib64/libldap* /usr/lib/

繼續編譯

[root@ErpServer php-5.2.17]# make ZEND_EXTRA_LIBS='-liconv' 
[root@localhost php-5.2.17]# make install
[root@ErpServer php-5.2.17]# cp php.ini-dist /software/php/etc/php.ini

Memcache是一個高性能的分佈式的內存對象緩存系統,通過在內存裏維護一個統一的巨大的hash表,它能夠用來存儲各種格式的數據,包括圖像、視頻、文件以及數據庫檢索的結果等。簡單的說就是將數據調用到內存中,然後從內存中讀取,從而大大提高讀取速度。

[root@ErpServer script]# tar zxf memcache-2.2.6.tgz
[root@ErpServer script]# cd memcache-2.2.6/
[root@ErpServer memcache-2.2.6]# /software/php/bin/phpize 
[root@ErpServer memcache-2.2.6]# ./configure --with-php-config=/software/php/bin/php-config 
[root@ErpServer memcache-2.2.6]# make && make install

eAccelerator是一個自由開放源碼php加速器,優化和動態內容緩存,提高了php腳本的緩存性能,使得PHP腳本在編譯的狀態下,對服務器的開銷幾乎完全消除。 它還有對腳本起優化作用,以加快其執行效率。使您的PHP程序代碼執效率能提高1-10倍;

[root@ErpServer script]# tar jxf eaccelerator-0.9.6.1.tar.bz2 
[root@ErpServer script]# cd eaccelerator-0.9.6.1/ 
[root@ErpServer eaccelerator-0.9.6.1]# /software/php/bin/phpize 
[root@ErpServer eaccelerator-0.9.6.1]# ./configure --enable-eaccelerator=shared --with-php-config=/software/php/bin/php-config --without-eaccelerator-use-inode
[root@ErpServer eaccelerator-0.9.6.1]# make && make install

PDO版驅動

[root@ErpServer eaccelerator-0.9.6.1]# tar zxf PDO_MYSQL-1.0.2.tgz 
[root@ErpServer eaccelerator-0.9.6.1]# cd PDO_MYSQL-1.0.2
[root@ErpServer PDO_MYSQL-1.0.2]# /software/php/bin/phpize 
[root@ErpServer PDO_MYSQL-1.0.2]# ./configure --with-php-config=/software/php/bin/php-config --with-pdo-mysql=/software/mysql/
[root@ErpServer PDO_MYSQL-1.0.2]# make && make install

位圖圖形,出圖用的, 現在多半使用了gd了

[root@ErpServer script]# tar zxf ImageMagick-6.7.0-8.tar.gz 
[root@ErpServer script]# cd ImageMagick-6.7.0-8
[root@ErpServer ImageMagick-6.7.0-8]# ./configure && make && make install

同上

[root@ErpServer script]# tar zxf imagick-3.0.1.tgz 
[root@ErpServer script]# cd imagick-3.0.1
[root@ErpServer imagick-3.0.1]# /software/php/bin/phpize
[root@ErpServer imagick-3.0.1]# ./configure --with-php-config=/software/php/bin/php-config 
[root@ErpServer imagick-3.0.1]# make && make install

修改配置,如無特殊需要,你複製粘貼一般能解決問題,赫赫

[root@ErpServer imagick-3.0.1]# sed -i "s/output_buffering = Off/output_buffering = On/" /software/php/etc/php.ini 
[root@ErpServer imagick-3.0.1]# sed -i "s/extension_dir =/; extension_dir =/" /software/php/etc/php.ini 
[root@ErpServer imagick-3.0.1]# sed -i "s/; cgi.fix_pathinfo=0/cgi.fix_pathinfo=0/" /software/php/etc/php.ini
[root@ErpServer imagick-3.0.1]# sed -i 's%;open_basedir =%open_basedir ="/tmp/:/data/www/"%' /software/php/etc/php.ini
[root@ErpServer imagick-3.0.1]# sed -i "s/disable_functions =/disable_functions = popen,pentl_exec,passthru,exec,system,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_alter,ini_restore,dl,pfsockopen,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,show_source,escapeshellcmd,escapeshellarg,curl_exec,curl_multi_exec,parse_ini_file,assert/" /software/php/etc/php.ini
[root@ErpServer imagick-3.0.1]# sed -i "s/expose_php = On/expose_php = Off/" /software/php/etc/php.ini
[root@ErpServer imagick-3.0.1]# sed -i "s/display_errors = On/display_errors = Off/" /software/php/etc/php.ini
[root@ErpServer imagick-3.0.1]# sed -i "s/log_errors = Off/log_errors = On/" /software/php/etc/php.ini

在php.ini最後添加如下:

extension_dir = "/software/php/lib/php/extensions/no-debug-non-zts-20060613/"
extension = "memcache.so"
extension = "pdo_mysql.so"
extension = "imagick.so"
[eaccelerator]
zend_extension="/software/php/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so"
eaccelerator.shm_size="1"
eaccelerator.cache_dir="/software/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"
eaccelerator.keys = "disk_only"
eaccelerator.sessions = "disk_only"
eaccelerator.content = "disk_only"

創建eAccelerator緩存目錄

[root@ErpServer imagick-3.0.1]# mkdir /software/eaccelerator_cache

創建php-fpm.conf文件

[root@ErpServer imagick-3.0.1]# rm /software/php/etc/php-fpm.conf 
[root@ErpServer imagick-3.0.1]# cat /software/php/etc/php-fpm.conf


[root@ErpServer imagick-3.0.1]# cat /software/php/etc/php-fpm.conf
<?xml version="1.0" ?>   
<configuration>   

  All relative paths in this config are relative to php's install prefix   

  <section name="global_options">   

	Pid file   
	<value name="pid_file">/software/php/logs/php-fpm.pid</value>   

	Error log file   
	<value name="error_log">/software/php/logs/php-fpm.log</value>   

	Log level   
	<value name="log_level">notice</value>   

	When this amount of php processes exited with SIGSEGV or SIGBUS ...   
	<value name="emergency_restart_threshold">10</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="emergency_restart_interval">1m</value>   

	Time limit on waiting child's reaction on signals from master   
	<value name="process_control_timeout">5s</value>   

	Set to 'no' to debug fpm   
	<value name="daemonize">yes</value>   

  </section>   

  <workers>   

	<section name="pool">   

	  Name of pool. Used in logs and stats.   
	  <value name="name">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="listen_address">127.0.0.1:9000</value>   

	  <value name="listen_options">   

		Set listen(2) backlog   
		<value name="backlog">-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="owner"></value>   
		<value name="group"></value>   
		<value name="mode">0666</value>   
	  </value>   

	  Additional php.ini defines, specific to this pool of workers.   
	  <value name="php_defines">   
		<value name="sendmail_path">/usr/sbin/sendmail -t -i</value>   
		<value name="display_errors">1</value>   
	  </value>   

	  Unix user of processes   
	  <value name="user">www</value>   

	  Unix group of processes   
	  <value name="group">www</value>   

	  Process manager settings   
	  <value name="pm">   

		Sets style of controling worker process count.   
		Valid values are 'static' and 'apache-like'   
		<value name="style">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="max_children">8</value>   

		Settings group for 'apache-like' pm style   
		<value name="apache_like">   

		  Sets the number of server processes created on startup.   
		  Used only when 'apache-like' pm_style is selected   
		  <value name="StartServers">20</value>   

		  Sets the desired minimum number of idle server processes.   
		  Used only when 'apache-like' pm_style is selected   
		  <value name="MinSpareServers">5</value>   

		  Sets the desired maximum number of idle server processes.   
		  Used only when 'apache-like' pm_style is selected   
		  <value name="MaxSpareServers">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="request_terminate_timeout">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="request_slowlog_timeout">0s</value>   

	  The log file for slow requests   
	  <value name="slowlog">logs/slow.log</value>   

	  Set open file desc rlimit   
	  <value name="rlimit_files">65535</value>   

	  Set max core size rlimit   
	  <value name="rlimit_core">0</value>   

	  Chroot to this directory at the start, absolute path   
	  <value name="chroot"></value>   

	  Chdir to this directory at the start, absolute path   
	  <value name="chdir"></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="catch_workers_output">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="max_requests">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="allowed_clients">127.0.0.1</value>   

	  Pass environment variables like LD_LIBRARY_PATH   
	  <value name="environment">   
		<value name="PATH">/usr/local/bin:/usr/bin:/bin</value>   
		<value name="TMP">/tmp</value>   
		<value name="TMPDIR">/tmp</value>   
		<value name="TEMP">/tmp</value>   
		<value name="OSTYPE">$OSTYPE</value>   
		<value name="MACHTYPE">$MACHTYPE</value>   
		<value name="MALLOC_CHECK_">2</value>   
	  </value>   

	</section>   

  </workers>   

</configuration>

創建www用戶及啓動php-fpm並加入啓動腳本

[root@ErpServer imagick-3.0.1]# /usr/sbin/groupadd www 
[root@ErpServer imagick-3.0.1]# /usr/sbin/useradd -g www www 
[root@ErpServer imagick-3.0.1]# mkdir /data/www
[root@ErpServer imagick-3.0.1]# chown -R www:www /data/www 
[root@ErpServer imagick-3.0.1]# chmod +w /data/www 
[root@ErpServer imagick-3.0.1]# ulimit -SHn 65535
[root@ErpServer imagick-3.0.1]# /software/php/sbin/php-fpm start 
Starting php_fpm  done

rc.local,還用多說什麼。。。

[root@ErpServer imagick-3.0.1]# echo "ulimit -SHn 65535" >> /etc/rc.local 
[root@ErpServer imagick-3.0.1]# echo "/software/php/sbin/php-fpm start" >> /etc/rc.local

編譯安裝Nginx-1.0.1

[root@ErpServer script]# tar zxf pcre-8.21.tar.gz
[root@ErpServer script]# cd pcre-8.21
[root@ErpServer pcre-8.21]# ./configure && make && make install

安裝nginx

[root@ErpServer script]# tar zxf nginx-1.2.7.tar.gz 
[root@ErpServer script]# cd nginx-1.2.7
[root@ErpServer nginx-1.2.7]# ./configure --user=www --group=www --prefix=/software/nginx --with-http_ssl_module --with-http_stub_status_module --with-http_gzip_static_module --with-http_realip_module --with-http_dav_module --with-http_flv_module --with-http_addition_module --with-http_sub_module
[root@ErpServer nginx-1.2.7]# make && make install

創建nginx配置文件

[root@ErpServer script]# rm -rf /software/nginx/conf/nginx.conf
[root@ErpServer script]# cat /software/nginx/conf/nginx.conf
user  www www;   
worker_processes 1;   
error_log  /software/nginx/logs/error.log  crit;   
pid        /software/nginx/conf/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 10240;   
}   
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;   
	include server/*.txt;   
	server   
	{   
		listen 80;   
		server_name default;   
		index index.php;   
		root  /data/www/test;   
		location ~ .*\.(php|php5)?$   
		{   
			fastcgi_pass 127.0.0.1:9000;   
			fastcgi_index index.php;   
			include fastcgi.conf;   
		}   
	}   
}

啓動nginx並進行測試

[root@ErpServer script]# /software/nginx/sbin/nginx -t
nginx: the configuration file /software/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /software/nginx/conf/nginx.conf test is successful
[root@ErpServer script]# /software/nginx/sbin/nginx 
[root@ErpServer script]# mkdir /data/www/test
[root@ErpServer script]# echo "<?php phpinfo();?>" > /data/www/test/index.php 
[root@ErpServer script]# echo "/data/soft/nginx/sbin/nginx" >> /etc/rc.local



PHPinfo

時間問題,不繼續發了,先發張成果圖在這供大家參考下(單擊放大):

Redmine後臺



QQ交流羣:41405569

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章