远播
环境:
centos6.5_64bit
httpd-2.4.1.tar.gz
nginx-1.9.4.tar.gz
php-5.5.25.tar.gz
mysql-5.6.26
PS程序版本非必需,如果您的程序中已经安装好以上程序,以下安装步骤非必须
安装环境
#Specify the environment variable export data_dir="/data" export app_user="appadmin" #Create users and groups groupadd ${app_user} useradd ${app_user} -g ${app_user} #if unzip not support yum install -y unzip #if gcc not support yum install -y gcc gcc-c++ 创建目录 #环境软件安装目录 mkdir -p ${data_dir}/fistsoft #配置文件目录 mkdir -p ${data_dir}/services/etc #日志文件目录 mkdir -p ${data_dir}/services/logs #执行脚本目录 mkdir -p ${data_dir}/services/bin #软件进程目录(pid文件) mkdir -p ${data_dir}/services/run chgrp ${app_user} -R /data/services/run #临时目录 mkdir -p ${data_dir}/tmp chmod 777 -R /data/tmp #备份目录 mkdir -p ${data_dir}/backup #系统文件软链接 rm -rf /tmp ln -s /data/tmp /tmp ln -s /data/fistsoft /usr/local/fistsoft ##########更新内核配置文件 cp /etc/sysctl.conf{,_bak} cat > /etc/sysctl.conf <<EOF kernel.sysrq = 0 kernel.core_uses_pid = 1 #net.bridge.bridge-nf-call-ip6tables = 0 #net.bridge.bridge-nf-call-iptables = 0 #net.bridge.bridge-nf-call-arptables = 0 kernel.msgmnb = 65536 kernel.msgmax = 65536 kernel.shmmax = 68719476736 kernel.shmall = 4294967296 net.ipv4.ip_forward = 1 net.ipv4.conf.default.rp_filter = 1 net.ipv4.conf.default.accept_source_route = 0 net.ipv4.tcp_syncookies = 1 net.ipv4.tcp_tw_reuse = 1 net.ipv4.tcp_keepalive_time = 30 net.ipv4.tcp_tw_recycle = 1 net.ipv4.tcp_fin_timeout = 1 net.ipv4.tcp_window_scaling = 0 net.ipv4.tcp_max_syn_backlog = 8192 net.ipv4.tcp_synack_retries = 1 net.ipv4.tcp_max_tw_buckets = 5000 net.ipv4.tcp_syn_retries = 1 net.ipv4.tcp_retries2 = 3 net.ipv4.tcp_fack = 0 net.ipv4.tcp_sack = 1 net.ipv4.tcp_timestamps = 0 net.ipv4.tcp_keepalive_intvl = 30 net.ipv4.tcp_keepalive_probes = 3 net.ipv4.tcp_rmem = 4096 87380 16777216 net.ipv4.tcp_wmem = 4096 65536 16777216 net.ipv4.tcp_mem = 8388608 8388608 16777216 net.ipv4.tcp_abort_on_overflow = 1 net.core.somaxconn = 2048 net.core.netdev_max_backlog = 3000 net.core.rmem_max = 16777216 net.core.wmem_max = 16777216 net.core.rmem_default = 2097152 net.core.wmem_default = 2097152 #for openvz kernel net.ipv6.conf.default.forwarding = 1 net.ipv6.conf.all.forwarding = 1 net.ipv4.conf.default.proxy_arp = 0 net.ipv4.conf.default.forwarding=1 net.ipv4.conf.all.forwarding=1 net.ipv4.conf.all.rp_filter = 1 kernel.sysrq = 1 net.ipv4.conf.default.send_redirects = 1 net.ipv4.conf.all.send_redirects = 0 EOF ##使配置生效 sysctl -p #修改unlimit cp /etc/profile{,_bak} cat >>/etc/profile <<EOF ulimit -SHn 65535 EOF #修改系统参数限制 cp /etc/security/limits.conf{,_bak} cat >> /etc/security/limits.conf <<EOF ${app_user} soft nproc 2047 ${app_user} hard nproc 16384 ${app_user} soft nofile 4096 ${app_user} hard nofile 65536 EOF ##安装组件 yum install -y zlib-devel openssl-devel cd ${data_dir}/software tar zxvf pcre-8.35.tar.gz -C /usr/src cd /usr/src/pcre-8.35 ./configure --prefix=/usr/local/pcre make && make install ##安装nginx cd ${data_dir}/software tar zxvf nginx-1.9.4.tar.gz -C /usr/src cd /usr/src/nginx-1.9.4 ./configure --prefix=/usr/local/fistsoft/nginx --conf-path="${data_dir}/services/etc/nginx/nginx.conf" --pid-path="${data_dir}/services/run/nginx.pid" --error-log-path="${data_dir}/services/logs/nginx_error.log" --with-pcre=/usr/src/pcre-8.35 make && make install ##安装apr cd ${data_dir}/software tar zxvf apr-1.4.6.tar.gz -C /usr/src cd /usr/src/apr-1.4.6 sed -i '/RM='\'\$RM\''/s#$RM#$RM -f#' ./configure ./configure --prefix=/usr/local/apr make && make install ##安装apr-util cd ${data_dir}/software tar zxvf apr-util-1.4.1.tar.gz -C /usr/src cd /usr/src/apr-util-1.4.1 ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/ make && make install ##安装httpd cd ${data_dir}/software tar zxvf httpd-2.4.1.tar.gz -C /usr/src cd /usr/src/httpd-2.4.1 ./configure --prefix=/usr/local/fistsoft/httpd/ --sysconfdir="${data_dir}/services/etc/httpd/" --enable-module=so --with-mpm=event --enable-mods-shared=all --enable-deflate --enable-expires --enable-rewrite --enable-headers --enable-cache --disable-cgid --disable-cgi --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-pcre=/usr/local/pcre make && make install ##安装libmcrypt cd ${data_dir}/software tar zxvf libmcrypt-2.5.8.gz -C /usr/src cd /usr/src/libmcrypt-2.5.8 ./configure make && make install cd /usr/src/libmcrypt-2.5.8/libltdl/ ./configure --enable-ltdl-install make && make install ##clear lib cache echo "/usr/local/lib" >>/etc/ld.so.conf ldconfig #安装php cd ${data_dir}/software yum install -y libxml2-devel openssl-devel curl-devel gd-devel libjpeg-devel libpng-devel freetype-devel openldap openldap-devel tar zxvf php-5.5.25.tar.gz -C /usr/src cd /usr/src/php-5.5.25 ./configure --with-apxs2=/usr/local/fistsoft/httpd/bin/apxs --prefix=/usr/local/fistsoft/php --with-zlib-dir=/usr --with-curl=/usr --with-gd --with-libxml-dir=/usr --with-jpeg-dir=/usr --with-png-dir=/usr --with-freetype-dir=/usr --with-mcrypt=/usr --with-openssl=/usr --with-mhash=/usr --with-xmlrpc --with-ldap --with-config-file-path="${data_dir}/services/etc/php" --enable-fpm --enable-static --with-pear --enable-mbstring --enable-gd-native-ttf --enable-ftp --enable-soap --enable-sockets --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --enable-maintainer-zts --with-libdir=lib64 make && make install ###########安装php扩展 ##安装zip扩展 cd /${data_dir}/software tar zxvf zip-1.12.5.tgz -C /usr/src cd /usr/src/zip-1.12.5 /usr/local/fistsoft/php/bin/phpize ./configure --with-php-config=/usr/local/fistsoft/php/bin/php-config make && make install #安装mysql (yum或源代码安装都可)
环境安装完成
配置nginx,apache
nginx中添加vhost配置
# cat 80_yuanbo.conf ##upstream upstream php_yuanbo_backend{ server 127.0.0.1:9008; } server { listen 80; server_name 10.0.0.1(您的公网地址或域名); location ~ .* { root htdocs_yuanbo; proxy_set_header Host $host:$server_port; #proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header x-Forwarded-Server $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_connect_timeout 60s; proxy_read_timeout 300s; proxy_send_timeout 300s; proxy_pass http://php_yuanbo_backend; } }
# apache中添加vhost配置
Listen 9008 <VirtualHost 127.0.0.1:9008> DocumentRoot "/usr/local/inonesoft/nginx/htdocs_yuanbo/" ServerName 127.0.0.1 ErrorLog "/data/services/logs/web_yuanbo.error.log" <Directory "/usr/local/inonesoft/nginx/htdocs_yuanbo/"> Options FollowSymLinks DirectoryIndex index.php AllowOverride ALL Require all granted </Directory> CustomLog "/data/services/logs/web_yuanbo.access.log" common </VirtualHost>
解压程序文件到目录:/usr/local/inonesoft/nginx/
tar zxvf htdocs_yuanbo_20160902.tar.gz -C /usr/local/inonesoft/nginx/
导入初始化数据库
mysql>create yuanbo; mysql>use yuanbo; mysql>source /data/backup/yuanbo_20160902.sql;
更改程序的数据库连接
vim /data/inonesoft/nginx/htdocs_yuanbo/data/config.php
更改下面配置
$config['db']['master']['host'] = 'xxxxx'; $config['db']['master']['username'] = 'username'; $config['db']['master']['password'] = 'password'; $config['db']['master']['port'] = '3306'; $config['db']['master']['database'] = 'yuanbo';
保存退出!
启动apache 和 nginx
/usr/local/inonesoft/httpd/bin/apachectl -k start
/usr/local/inonesoft/nginx/sbin/nginx
ps:如果您已经安装lamp 程序,只需做如下四步:
1.解压程序文件
2.导入数据库
3.添加apache 配置
4.修改程序配置文件
码农小明