最近公司已大牛离职,本人临时从当了一下运维完成后台相关应用从aws迁移到腾讯云上,由于机器不多久没有搞自动安装什么的。而且后台应用的环境并没有统一,一些即将废弃的功能都是比较老的版本,所以就没有必要搞了,全部人肉安装。
一、创建运行用户组合用户
groupadd www
useradd -g www www
创建了用户组和用户,并把用户归到www组中
二、安装依赖工具
yum -y install gcc automake autoconf libtool make gcc gcc-c++
yum -y install libmcrypt-devel mhash-devel libxslt-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel pcre pcre-devel
三、安装nginx
1、安装
wget http://nginx.org/download/nginx-1.12.2.tar.gz
tar -zxvf nginx-1.12.2.tar.gz
cd nginx-1.12.2
./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-pcre --with-pcre-jit --with-http_stub_status_module --with-stream
make
make install
2、修改配置文件
vi /usr/local/nginx/conf/nginx.conf
修改一下项或者直接全文替换:
user www www;
worker_processes auto;
pid /usr/local/nginx/logs/nginx.pid;
error_log /dev/null;
worker_rlimit_nofile 51200;
events
{
use epoll;
worker_connections 51200;
}
http
{
include /usr/local/nginx/conf/mime.types;
default_type application/octet-stream;
charset utf-8;
log_format main '$remote_addr - $remote_user [$time_local] $request ' '"$status" $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"';
access_log /dev/null;
server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_body_buffer_size 8m; #256k
server_tokens off;
ignore_invalid_headers on;
recursive_error_pages on;
server_name_in_redirect off;
sendfile on;
keepalive_timeout 60;
tcp_nopush on;
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;
fastcgi_hide_header X-Powered-By;
client_max_body_size 50m;
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;
proxy_temp_path /dev/shm/proxy_temp;
fastcgi_temp_path /dev/shm/fastcgi_temp;
client_body_temp_path /dev/shm/client_body_temp;
upstream web {
server 127.0.0.1:80;
}
upstream php {
server 127.0.0.1:9000 max_fails=0;
}
fastcgi_next_upstream error timeout invalid_header http_500;
include vhosts/*.conf;
}
3、设置开机启动
vi /etc/init.d/nginx
#! /bin/bash
# chkconfig: - 85 15
PATH=/usr/local/nginx
DESC="nginx daemon"
NAME=nginx
DAEMON=$PATH/sbin/$NAME
CONFIGFILE=$PATH/conf/$NAME.conf
PIDFILE=$PATH/logs/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME
set -e
[ -x "$DAEMON" ] || exit 0
do_start() {
$DAEMON -c $CONFIGFILE || echo -n "nginx already running"
}
do_stop() {
$DAEMON -s stop || echo -n "nginx not running"
}
do_reload() {
$DAEMON -s reload || echo -n "nginx can't reload"
}
case "$1" in
start)
echo -n "Starting $DESC: $NAME"
do_start
echo "."
;;
stop)
echo -n "Stopping $DESC: $NAME"
do_stop
echo "."
;;
reload|graceful)
echo -n "Reloading $DESC configuration..."
do_reload
echo "."
;;
restart)
echo -n "Restarting $DESC: $NAME"
do_stop
do_start
echo "."
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|reload|restart}" >&2
exit 3
;;
esac
exit 0
保存
chmod a+x nginx //修改文件运行权限
chkconfig --add nginx
chkconfig nginx on
nginx启动和停止方式:
service nginx start
service nginx stop
service nginx restart
service nginx reload
四、安装php5.6
wget http://cn2.php.net/distributions/php-5.6.32.tar.gz
tar -zxvf php-5.6.32.tar.gz
cd php-5.6.32
./configure --prefix=/usr/local/php-5.6.32 --with-config-file-path=/usr/local/php-5.6.32/etc --with-curl --with-freetype-dir --with-gd --with-gettext --with-iconv-dir --with-kerberos --with-libdir=lib64 --with-libxml-dir --with-mysql --with-mysqli --with-openssl --with-pcre-regex --with-pdo-mysql --with-pdo-sqlite --with-pear --with-png-dir --with-xmlrpc --with-xsl --with-zlib --enable-fpm --enable-bcmath --enable-libxml --enable-inline-optimization --enable-gd-native-ttf --enable-mbregex --enable-mbstring --enable-opcache --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvsem --enable-xml --enable-zip
make
make install
cp /usr/local/php-5.6.32/bin/php /usr/bin
cp php.ini-development /usr/local/php-5.6.32/etc/php.ini
cp ./sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
修改php.ini
vi /usr/local/php-5.6.32/etc/php.ini
修改一下几项并去掉全面的分号:
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
error_log = /tmp/php-errors.log
upload_max_filesize = 8M
date.timezone = PRC
修改php-fpm.conf,前面有分号的要去掉分号
vi /usr/local/php-5.6.32/etc/php-fpm.conf
[global]
pid = /usr/local/php-5.6.32/var/run/php-fpm.pid
error_log = /usr/local/php-5.6.32/var/log/php-fpm.log
log_level = notice
emergency_restart_threshold = 10
emergency_restart_interval = 1m
process_control_timeout = 5s
daemonize = yes
[www]
listen = 127.0.0.1:9000
listen.backlog = 512
listen.allowed_clients = 127.0.0.1
user = www
group = www
pm = static
pm.max_children = 256
pm.start_servers = 20
pm.min_spare_servers = 5
pm.max_spare_servers = 35
pm.max_requests = 128
pm.status_path = /php_status
request_terminate_timeout = 0s
request_slowlog_timeout = 5s
slowlog = logs/slow.log
rlimit_files = 65535
rlimit_core = 0
chroot =
chdir =
catch_workers_output = yes
env[HOSTNAME] = $HOSTNAME
env[PATH] = /usr/local/bin:/usr/bin:/bin
env[TMP] = /tmp
env[TMPDIR] = /tmp
env[TEMP] = /tmp
设置开启启动
chmod a+x php-fpm //修改文件运行权限
chkconfig --add php-fpm
chkconfig php-fpm on
php-fpm启动和停止方式:
service php-fpm start
service php-fpm stop
service php-fpm restart
service php-fpm reload
安装yaf扩展
php版本为7的必须是3以上的,5.6的必须是2的版本
wget http://pecl.php.net/get/yaf-2.3.5.tgz
tar -zxvf yaf-2.3.5.tgz
cd yaf-2.3.5 && /usr/local/php-5.6.32/bin/phpize
./configure --with-php-config=/usr/local/php-5.6.32/bin/php-config
make
make install
安装redis扩展
wget http://pecl.php.net/get/redis-3.1.4.tgz
tar -zxvf redis-3.1.4.tgz
cd redis-3.1.4
/usr/local/php-5.6.32/bin/phpize
./configure --with-php-config=/usr/local/php-5.6.32/bin/php-config
make
make install
修改php.ini在文件尾部增加:
[redis]
extension = "redis.so"
[yaf]
yaf.library="/hood/" #hood是基于yaf做的框架扩展
yaf.environ=production #运行环境,根据网站需要进行设置
yaf.use_namespace=1
yaf.cache_config=1
extension = "yaf.so"
网友评论