- 论坛徽章:
- 0
|
三.安装数据库服务器 3.1 Install MySQL 3.1.1.安装libevent # tar zxvf libevent-2.0.12-stable.tar.gz # cd libevent-2.0.12-stable # ./configure --prefix=/usr/local/libevent # make && make install # ln -s /usr/local/libevent/lib/libevent-1.4.so.2 /usr/lib
3.1.2 安装cmake # tar zxvf cmake-2.8.5.tar.gz # cd cmake-2.8.5 # ./bootstrap # make && make install 3.1.3.安装MySQL # groupadd mysql # useradd -g mysql -s /sbin/nologin mysql # mkdir -p /storage/db/mysql_data # mkdir -p /software/mysql # mkdir -p /etc/mysql # tar zxvf mysql-5.5.15.tar.gz # cd mysql-5.5.15 # cmake . -DCMAKE_INSTALL_PREFIX=/software/mysql/ -DMYSQL_DATADIR=/storage/db/mysql_data -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DEXTRA_CHARSETS=all -DWITH_SSL=system -DWITH_ZLIB=system -DWITH_EMBEDDED_SERVER=1 -DENABLED_LOCAL_INFILE=1 -DWITH_MYISAM_STORAGE_ENGINE=1 -DSYSCONFDIR=/etc/mysql -DMYSQL_TCP_PORT=7454 -DWITH_DEBUG=0 -DMYSQL_UNIX_ADDR=/tmp/mysqld.sock -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_FEDERATED_STORAGE_ENGINE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 # make && make install # cp ./support-files/my-innodb-heavy-4G.cnf /etc/mysql/my.cnf # chown -R mysql.mysql /storage/db/mysql_data/ # chown -R mysql,mysql /storage/ # /software/mysql/scripts/mysql_install_db --basedir=/software/mysql/ --user=mysql --datadir=/storage/db/mysql_data/ # cp /opt/mysql-5.5.15/support-files/mysql.server /etc/init.d/mysqld # chmod 755 /etc/init.d/mysqld # vim /etc/init.d/mysqld basedir=/software/mysql datadir=/storage/db/mysql_data # /etc/init.d/mysqld start Starting MySQL[ OK ] # netstat -an |grep 7454 tcp 0 0 0.0.0.0:7454 0.0.0.0:* LISTEN # ps -ef |grep mysql root 4616 1 0 03:11 pts/0 00:00:00 /bin/sh /software/mysql//bin/mysqld_safe --datadir=/storage/db/mysql_data/ --pid-file=/storage/db/mysql_data//mail.jieshiyeskey.com.pid mysql 5261 4616 1 03:11 pts/0 00:00:01 /software/mysql/bin/mysqld --basedir=/software/mysql --datadir=/storage/db/mysql_data/ --plugin-dir=/software/mysql/lib/plugin --user=mysql --log-error=/storage/db/mysql_data//mail.jieshiyeskey.com.err --open-files-limit=8192 --pid-file=/storage/db/mysql_data//mail.jieshiyeskey.com.pid --socket=/tmp/mysqld.sock --port=7454 root 5348 1 1 03:12 pts/0 00:00:00 /bin/sh /software/mysql//bin/mysqld_safe --datadir=/storage/db/mysql_data/ --pid-file=/storage/db/mysql_data//mail.jieshiyeskey.com.pid mysql 5995 5348 6 03:12 pts/0 00:00:01 /software/mysql/bin/mysqld --basedir=/software/mysql --datadir=/storage/db/mysql_data/ --plugin-dir=/software/mysql/lib/plugin --user=mysql --log-error=/storage/db/mysql_data//mail.jieshiyeskey.com.err --open-files-limit=8192 --pid-file=/storage/db/mysql_data//mail.jieshiyeskey.com.pid --socket=/tmp/mysqld.sock --port=7454 root 6036 2242 0 03:12 pts/0 00:00:00 grep mysql # vim /etc/profile export PATH=$PATH:/software/mysql/bin # source /etc/profile # mysql Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.5.14-log Source distribution Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> # chkconfig mysqld on # chkconfig --level 24 mysqld off # chkconfig --list mysqld mysqld 0:off 1:off 2:off 3:on 4:off 5:on 6:off # vim /etc/ld.so.conf /software/mysql/lib # ldconfig -v |grep mysql /software/mysql/lib: libmysqlclient.so.18 -> libmysqlclient_r.so.18.0.0 3.1.4.安装memcached # tar zxvf memcached-1.4.7.tar.gz # cd memcached-1.4.7 # ./configure --prefix=/usr/local/memcached --with-libevent=/usr/local/libevent # make && make install # /usr/local/memcached/bin/memcached -d -m 2048 -u root -p 11211 # netstat -an |grep 11211 tcp 0 0 0.0.0.0:11211 0.0.0.0:* LISTEN tcp 0 0 :::11211 :::* LISTEN udp 0 0 0.0.0.0:11211 0.0.0.0:* udp 0 0 :::11211 :::*
# vim /etc/rc.local /usr/local/memcached/bin/memcached -d -m 2048 -u root -p 11211 3.1.5.安装libunwind # tar zxvf libunwind-0.99.tar.gz
# cd libunwind-0.99 # CFLAGS=-fPIC ./configure # make CFLAGS=-fPIC # make CFLAGS=-fPIC install 3.1.6.安装google-perftools # tar zxvf google-perftools-1.8.2.tar.gz # cd google-perftools-1.8.2 # ./configure && make && make install # echo "/usr/local/lib" > /etc/ld.so.conf.d/usr_local_lib.conf # /sbin/ldconfig –v 3.2安装PHP 3.2.1 安装PHP依赖包 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 gd gd-devel 3.2.2 安装libiconv # cd google-perftools-1.8.2 # ./configure && make && make install # echo "/usr/local/lib" > /etc/ld.so.conf.d/usr_local_lib.conf # /sbin/ldconfig –v 3.2.3 安装libmcrypt # tar jxvf libmcrypt-2.5.8.tar.gz # cd libmcrypt-2.5.8 # ./configure && make && make install # cd libltdl # /sbin/ldconfig # cd libltdl/ # ./configure --enable-ltdl-install # make && make install # /sbin/ldconfig –v 3.2.4 安装mhash # tar jxvf mhash-0.9.9.9.tar.bz2 # cd mhash-0.9.9.9 # ./configure && make && make install # 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 3.2.5 安装mcrypt # tar zxvf mcrypt-2.6.8.tar.gz # cd mcrypt-2.6.8 # /sbin/ldconfig # ./configure && make && make install 3.2.6 安装PHP # mkdir /php # tar jxvf php-5.3.6.tar.bz2 # cd php-5.3.6 # ./configure --prefix=/php --with-config-file-path=/php/etc --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-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-fpm --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 --with-mysqli=/mysqldb/bin/mysql_config --with-mysql=/mysqldb --with-oci8=instantclient,/usr/lib/oracle/11.2/client64/lib/ # make ZEND_EXTRA_LIBS='-liconv' # make install # cp php.ini-development /php/etc/php.ini 3.2.7 安装memcache # tar zxvf memcache-3.0.6.tgz # cd memcache-3.0.6 # /php/bin/phpize Configuring for: PHP Api Version: 20090626 Zend Module Api No: 20090626 Zend Extension Api No: 220090626 # ./configure --with-php-config=/php/bin/php-config # make && make install 3.2.8 安装eaccelerator # unzip eaccelerator-0.9.6.1.zip # cd eaccelerator-0.9.6.1 # /php/bin/phpize Configuring for: PHP Api Version: 20090626 Zend Module Api No: 20090626 Zend Extension Api No: 220090626 # ./configure --with-php-config=/php/bin/php-config # make && make install 3.2.9 安装PDO_MYSQL # tar zxvf PDO_MYSQL-1.0.2.tgz # cd PDO_MYSQL-1.0.2 # /php/bin/phpize # ./configure --with-php-config=/php/bin/php-config --with-pdo-mysql=/mysqldb # make && make install 3.2.10 安装ImageMagick # tar zxvf ImageMagick-6.6.7-10.tar.gz # cd ImageMagick-6.6.7-10/ # ./configure # make && make install 3.2.11 安装imagick # tar zxvf imagick-3.1.0b1.tgz # cd imagick-3.1.0b1 # /php/bin/phpize Configuring for: PHP Api Version: 20090626 Zend Module Api No: 20090626 Zend Extension Api No: 220090626 # ./configure --with-php-config=/php/bin/php-config # make && make install 3.2.12 配置PHP扩展包 # mkdir -p /eaccelerator_cache # vim /php/etc/php.ini 添加: date.timezone = Asia/Shanghai extension_dir = /php/lib/php/extensions/no-debug-non-zts-20090626/ extension = "memcache.so" extension = "pdo_mysql.so" extension = "imagick.so" output_buffering Default Value: On Development Value: 4096 Production Value: 4096 [eaccelerator] zend_extension="/php/lib/php/extensions/no-debug-non-zts-20090626/eaccelerator.so" eaccelerator.shm_size="64" eaccelerator.cache_dir="/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" # pwd /php/etc # cp php-fpm.conf.default php-fpm.conf 修改: pid = /php/var/run/php-fpm.pid error_log = /php/var/log/php-fpm.log log_level = notice listen = 127.0.0.1:9000 user = sfmon group = sfmon pm = dynamic pm.max_children = 50 pm.start_servers = 20 pm.min_spare_servers = 5 pm.max_spare_servers = 35 # pwd /opt/software/php-5.3.6/sapi/fpm # cp init.d.php-fpm /etc/init.d/phpfpm # chmod 755 /etc/init.d/phpfpm # /etc/init.d/phpfpm start # ps -ef |grep www vweb 3328 3327 0 03:23 ? 00:00:00 php-fpm: pool www vweb 3329 3327 0 03:23 ? 00:00:00 php-fpm: pool www vweb 3330 3327 0 03:23 ? 00:00:00 php-fpm: pool www vweb 3331 3327 0 03:23 ? 00:00:00 php-fpm: pool www vweb 3332 3327 0 03:23 ? 00:00:00 php-fpm: pool www vweb 3333 3327 0 03:23 ? 00:00:00 php-fpm: pool www vweb 3334 3327 0 03:23 ? 00:00:00 php-fpm: pool www vweb 3335 3327 0 03:23 ? 00:00:00 php-fpm: pool www vweb 3336 3327 0 03:23 ? 00:00:00 php-fpm: pool www vweb 3337 3327 0 03:23 ? 00:00:00 php-fpm: pool www vweb 3338 3327 0 03:23 ? 00:00:00 php-fpm: pool www vweb 3339 3327 0 03:23 ? 00:00:00 php-fpm: pool www vweb 3340 3327 0 03:23 ? 00:00:00 php-fpm: pool www vweb 3341 3327 0 03:23 ? 00:00:00 php-fpm: pool www vweb 3342 3327 0 03:23 ? 00:00:00 php-fpm: pool www vweb 3343 3327 0 03:23 ? 00:00:00 php-fpm: pool www vweb 3344 3327 0 03:23 ? 00:00:00 php-fpm: pool www vweb 3345 3327 0 03:23 ? 00:00:00 php-fpm: pool www vweb 3346 3327 0 03:23 ? 00:00:00 php-fpm: pool www vweb 3347 3327 0 03:23 ? 00:00:00 php-fpm: pool www # chkconfig phpfpm on # chkconfig --level 24 phpfpm off # chkconfig --list phpfpm phpfpm 0:off 1:off 2:off 3:on 4:off 5:on 6:off 四.安装应用服务器 4.1.安装nginx 4.1.1.安装pcre # tar jxvf pcre-8.12.zip # cd pcre-8.12 # ./configure # make && make install 4.1.2.安装nginx # mkdir -p /software/www # groupadd www # useradd -g www -s /sbin/nologin www # chmod +w /software/www # chown -R www.www /software/www/ # tar zxvf nginx-1.1.0.tar.gz # cd nginx-1.1.0 # ./configure --user=www --group=www --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --pid-path=/var/run/nginx.pid --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --with-http_stub_status_module --with-http_ssl_module --lock-path=/var/lock/subsys/nginx # make && make install # vim /etc/sysconfig/nginx NGINX_CONF_FILE=/etc/nginx/nginx.conf # vim /etc/init.d/nginx #!/bin/sh # # nginx - this script starts and stops the nginx daemon # # chkconfig: - 85 15 # description: Nginx is an HTTP(S) server, HTTP(S) reverse \ # proxy and IMAP/POP3 proxy server # processname: nginx # config: /etc/nginx/nginx.conf # config: /etc/sysconfig/nginx # pidfile: /var/run/nginx.pid # Source function library. . /etc/rc.d/init.d/functions # Source networking configuration. . /etc/sysconfig/network # Check that networking is up. [ "$NETWORKING" = "no" ] && exit 0 nginx="/usr/sbin/nginx" prog=$(basename $nginx) NGINX_CONF_FILE="/etc/nginx/nginx.conf" [ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx lockfile=/var/lock/subsys/nginx start() { [ -x $nginx ] || exit 5 [ -f $NGINX_CONF_FILE ] || exit 6 echo -n $"Starting $prog: " daemon $nginx -c $NGINX_CONF_FILE retval=$? echo [ $retval -eq 0 ] && touch $lockfile return $retval } stop() { echo -n $"Stopping $prog: " killproc $prog retval=$? echo [ $retval -eq 0 ] && rm -f $lockfile return $retval } restart() { configtest_q || configtest || return 6 stop start } reload() { configtest_q || configtest || return 6 echo -n $"Reloading $prog: " killproc $nginx -HUP echo } configtest() { $nginx -t -c $NGINX_CONF_FILE } configtest_q() { configtest >/dev/null 2>&1 } rh_status() { status $prog } rh_status_q() { rh_status >/dev/null 2>&1 } # Upgrade the binary with no downtime. upgrade() { local pidfile="/var/run/${prog}.pid" local oldbin_pidfile="${pidfile}.oldbin" configtest_q || configtest || return 6 echo -n $"Staring new master $prog: " killproc $nginx -USR2 retval=$? echo sleep 1 if [[ -f ${oldbin_pidfile} && -f ${pidfile} ]]; then echo -n $"Graceful shutdown of old $prog: " killproc -p ${oldbin_pidfile} -QUIT retval=$? echo return 0 else echo $"Something bad happened, manual intervention required, maybe restart?" return 1 fi } case "$1" in start) rh_status_q && exit 0 $1 ;; stop) rh_status_q || exit 0 $1 ;; restart|configtest) $1 ;; force-reload|upgrade) rh_status_q || exit 7 upgrade ;; reload) rh_status_q || exit 7 $1 ;; status|status_q) rh_$1 ;; condrestart|try-restart) rh_status_q || exit 7 restart ;; *) echo $"Usage: $0 {start|stop|reload|configtest|status|force-reload|upgrade|restart}" exit 2 esac # chmod 755 /etc/init.d/nginx # /etc/init.d/nginx s Usage: /etc/init.d/nginx {start|stop|reload|configtest|status|force-reload|upgrade|restart} # chkconfig nginx on # chkconfig --level 24 nginx off # chkconfig --list nginx nginx 0:off 1:off 2:off 3:on 4:off 5:on 6:off # netstat -an |grep 80 tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 4.1.3.nginx配置文件 # cat /etc/nginx/nginx.conf user www www ; worker_processes 2; error_log /var/log/nginx/error.log crit; pid /var/run/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 192.168.1.40; index index.html index.php index.htm; root /software/www/; if (!-f $request_filename){ #rewrite ^/[^^]*$ /index.php last; rewrite (.*)/index.php last; } #limit_conn crawler 20; location ~ .*\.(php|php5)?$ { #fastcgi_pass unix:/tmp/php-cgi.sock; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.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] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" $http_x_forwarded_for'; access_log /var/log/nginx/access.log access; } } # cat /software/www/index.php <?php phpinfo(); ?> # chown www.www index.php 在浏览器输入http://192.168.1.40/进行测试。
|
|