一、系統約定
軟件源代碼包存放位置
|
/usr/local/src
|
/usr/local/software_name
|
|
腳本以及維護程序存放位置
|
/usr/local/sbin
|
/usr/local/mysql/data(可按情況設置)
|
|
Nginx 網站根目錄
|
/home/www/wwwroot(可按情況設置)
|
Nginx 虛擬主機日誌根目錄
|
/home/www/logs(可按情況設置)
|
Nginx 運行賬戶
|
www:www
|
使用 yum 程序安裝所需開發包(以下爲標準的 RPM 包名稱)
# yum -y install ntp make openssl openssl-devel pcre pcre-devel libpng libpng-devel libjpeg-6b libjpeg-devel-6b freetype freetype-devel gd gd-devel zlib zlib-devel gcc gcc-c++ libXpm libXpm-devel ncurses ncurses-devel libmcrypt libmcrypt-devel libxml2 libxml2-devel imake autoconf automake screen sysstat compat-libstdc++-33 curl curl-de
#yum -y install cmake
28 wget ftp://mirror.switch.ch/mirror/mysql/Downloads/MySQL-5.5/mysql-5.5.20.tar.gz
30 /usr/sbin/groupadd mysql
31 /usr/sbin/useradd -g mysql mysql
32 tar -zxvf mysql-5.5.20.tar.gz
33 cd mysql-5.5.20
34 cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/data -DEXTRA_CHARSETS=all
35 make
36 make install
37 cp /usr/local/src/mysql-5.5.20/support-files/my-huge.cnf /usr/local/mysql/my.cnf
38 > /usr/local/mysql/my.cnf
39 vi /usr/local/mysql/my.cnf
40 chmod +w /usr/local/mysql
41 chown -R mysql:mysql /usr/local/mysql
42 cp /usr/local/src/mysql-5.5.20/support-files/mysql.server /etc/init.d/mysql
43 chmod +x /etc/init.d/mysql
44 /sbin/chkconfig --add mysql
45 /sbin/chkconfig mysql on
46 /usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql
47 /usr/local/mysql/bin/mysqld_safe --defaults-file=/usr/local/mysql/my.cnf &
48 /usr/local/mysql/bin/mysqladmin -u root password 'password'
49 /usr/local/mysql/bin/mysqladmin -h 127.0.0.1 -ppassword version
50 mysql -uroot -h 127.0.0.1 -ppassword
51 rm -fr /etc/my.cnf
52 service mysqld start
53 /usr/local/mysql/bin/mysql -u root -p
54 show databases;
/usr/local/mysql/my.cnf 如下
[client]
port= 3306
socket= /tmp/mysql.sock
[mysqld]
port= 3306
socket= /tmp/mysql.sock
skip-external-locking
key_buffer_size = 384M
max_allowed_packet = 1M
table_open_cache = 512
sort_buffer_size = 2M
read_buffer_size = 2M
read_rnd_buffer_size = 8M
myisam_sort_buffer_size = 64M
thread_cache_size = 8
query_cache_size = 32M
thread_concurrency = 8
log-bin=mysql-bin
server-id= 1
innodb_data_home_dir = /usr/local/mysql/data
innodb_data_file_path = ibdata1:2000M;ibdata2:10M:autoextend
innodb_log_group_home_dir = /usr/local/mysql/data
buffer_pool_size = 384M
innodb_additional_mem_pool_size = 20M
innodb_log_file_size = 100M
innodb_log_buffer_size = 8M
innodb_flush_log_at_trx_commit = 1
innodb_lock_wait_timeout = 50
[mysqldump]
quick
max_allowed_packet = 16M
[mysql]
no-auto-rehash
[myisamchk]
key_buffer_size = 256M
sort_buffer_size = 256M
read_buffer = 2M
write_buffer = 2M
[mysqlhotcopy]
interactive-timeoutvel
service mysqld start
# bin/mysqladmin -u root password password
其中紅色的password是要設置的root密碼
[root@localhost mysql]# bin/mysql -u root -p
mysql> show databases;
證明安裝成功。
2. 編譯安裝Nginx
# cd /usr/local/src/
# tar zxvf nginx-1.0.11.tar.gz
# cd nginx-1.0.11
# ./configure --prefix=/usr/local/nginx --conf-path=/usr/local/nginx/conf/nginx.conf --with-http_realip_module --with-http_addition_module --with-http_gzip_static_module --with-http_random_index_module --with-http_stub_status_module --with-http_sub_module --with-http_dav_module
# make
# make install clean
# /usr/local/nginx/sbin/nginx
#/usr/local/nginx/sbin/nginx >>/etc/init
# cp /usr/local/src/nginx /etc/init.d/nginx
# chmod 755 /etc/init.d/nginx
# chkconfig --add nginx
# chkconfig nginx on
/usr/local/nginx/sbin/nginx –t nginx測試
/usr/nginx/sbin/nginx -s reload nginx重啓
3. 編譯安裝PHP 所需的支持庫
Libiconv
# cd /usr/local/src/
# tar zxvf libiconv-1.13.1.tar.gz
# cd libiconv-1.13.1/
# ./configure --prefix=/usr/local
# make
# make install
# cd ..
Libmcrypt
# 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 /usr/local/src/
Mhash
# 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
4. 編譯安裝PHP
# cd /usr/local/src
# tar zxvf php-5.3.10.tar.gz
# gzip -cd php-5.2.13-fpm-0.5.14.diff.gz | patch -d php-5.2.13 -p1
# cd php-5.3.10
# ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/etc/cgi --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-iconv-dir=/usr/local --with-freetype-dir=/usr --with-jpeg-dir=/usr --with-png-dir=/usr --with-zlib --with-libxml-dir=/usr --with-xmlrpc --enable-xml --enable-mbstring --enable-ftp --with-gd --enable-magic-quotes --with-pear --enable-sockets --with-ttf --enable-gd-native-ttf --enable-sysvsem --enable-sysvshm --enable-shmop --enable-force-cgi-redirect --enable-fastcgi --enable-zip --enable-fpm --with-mhash --with-mcrypt --enable-discard-path --enable-bcmath --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --with-openssl
# make ZEND_EXTRA_LIBS='-liconv'
# make install
錯誤提示1 error while loading shared libraries: libiconv.so.2: cannot open shared object file: No such file or directory
解決1.在/etc/ld.so.conf中加一行/usr/local/lib,
2.然後運行/sbin/ldconfig
錯誤提示2 cp: cannot stat `ext/phar/phar.phar': No such file or directory
cd ext/phar/
cp ./phar.php ./phar.phar
#
# cp php.ini-production /usr/local/php/etc/php.ini
# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
# cp sapi/fpm/php-fpm.conf /usr/local/php/etc/php-fpm.conf
sed -i 's#short_open_tag = Off#short_open_tag = On#g' /usr/local/php/etc/php.ini
sed -i 's#;pid = run/php-fpm.pid#pid = run/php-fpm.pid#g' /usr/local/php/etc/php-fpm.conf
sed -i 's#pm.max_children = 5#pm.max_children = 32#g' /usr/local/php/etc/php-fpm.conf
sed -i 's#pm.start_servers = 2#pm.start_servers = 16#g' /usr/local/php/etc/php-fpm.conf
sed -i 's#pm.min_spare_servers = 1#pm.min_spare_servers = 8#g' /usr/local/php/etc/php-fpm.conf
sed -i 's#pm.max_spare_servers = 3#pm.max_spare_servers = 32#g' /usr/local/php/etc/php-fpm.conf
sed -i 's#;pm.max_requests = 500#pm.max_requests = 120#g' /usr/local/php/etc/php-fpm.conf
#chmod 755 /etc/init.d/php-fpm
#chkconfig --add php-fpm
#chkconfig --level 345 php-fpm on
#/etc/init.d/php-fpm start