最近公司已大牛離職引颈,本人臨時(shí)從當(dāng)了一下運(yùn)維完成后臺(tái)相關(guān)應(yīng)用從aws遷移到騰訊云上联四,由于機(jī)器不多久沒有搞自動(dòng)安裝什么的沦童。而且后臺(tái)應(yīng)用的環(huán)境并沒有統(tǒng)一仑濒,一些即將廢棄的功能都是比較老的版本,所以就沒有必要搞了偷遗,全部人肉安裝墩瞳。
一跺撼、創(chuàng)建運(yùn)行用戶組合用戶
groupadd www
useradd -g www www
創(chuàng)建了用戶組和用戶避咆,并把用戶歸到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
修改一下項(xiàng)或者直接全文替換:
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嗜憔、設(shè)置開機(jī)啟動(dòng)
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 //修改文件運(yùn)行權(quán)限
chkconfig --add nginx
chkconfig nginx on
nginx啟動(dòng)和停止方式:
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
修改一下幾項(xiàng)并去掉全面的分號(hào):
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
error_log = /tmp/php-errors.log
upload_max_filesize = 8M
date.timezone = PRC
修改php-fpm.conf,前面有分號(hào)的要去掉分號(hào)
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
設(shè)置開啟啟動(dòng)
chmod a+x php-fpm //修改文件運(yùn)行權(quán)限
chkconfig --add php-fpm
chkconfig php-fpm on
php-fpm啟動(dòng)和停止方式:
service php-fpm start
service php-fpm stop
service php-fpm restart
service php-fpm reload
安裝yaf擴(kuò)展
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擴(kuò)展
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做的框架擴(kuò)展
yaf.environ=production #運(yùn)行環(huán)境,根據(jù)網(wǎng)站需要進(jìn)行設(shè)置
yaf.use_namespace=1
yaf.cache_config=1
extension = "yaf.so"