rancher部署oneinstack Linux教程


命令:
/usr/bin/supervisord -n -c /etc/supervisord.conf
添加卷:
/data/site:/data/site
/data/soft:/data/soft
/data/docker/cndo/logs:/data/wwwlogs/
/data/docker/cndo/vhost:/usr/local/nginx/conf/vhost:ro
/data/docker/cndo/supervisord.conf:/etc/supervisord.conf:ro


1.安装oneinstack

....

2.在nginx的配置文件里加上这一行很关键,这样nginx可以在docker启动的时候在后台运行!

echo "daemon off;" >> /usr/local/nginx/conf/nginx.conf


3./usr/local/php/etc/php-fpm.conf

跟nginx里加一行的效果一样,为了启动docker时,php可以在后台运行

;daemonize = yes的注释去掉,并把yes改为no

为了同一个用户可以访问web的权限统一修改为www(宿主的web文件访问权限也是www)

修改为user=www group=www


4. 容器里安装supervisord


5.整理,删除,清理yum缓存,退出容器

cd /root/oneinstack/src
rm -fr *
make clean
yum clean all

6.设置开机启动  

chkconfig nginx on
chkconfig php-fpm  on
chkconfig supervisord on


7.vi /data/docker/cndo/supervisord.conf

[program:hhvm]
command=/usr/bin/hhvm --mode server --user www --config /etc/hhvm/server.ini --config /etc/hhvm/php.ini --config /etc/hhvm/config.hdf
numprocs=1 ; number of processes copies to start (def 1)
directory=/tmp ; directory to cwd to before exec (def no cwd)
autostart=true ; start at supervisord start (default: true)
autorestart=unexpected ; whether/when to restart (default: unexpected)
stopwaitsecs=10 ; max num secs to wait b4 SIGKILL (default 10)

or

[supervisord]
nodaemon=true
[program:nginx]
command=/usr/local/nginx/sbin/nginx
[program:php-fpm]
command=/usr/local/php/sbin/php-fpm -c /usr/local/php/etc/php.ini -y /usr/local/php/etc/php-fpm.conf


8. 验证

/usr/local/nginx/sbin/nginx -t             #检查配置文件是否正确
/usr/local/nginx/sbin/nginx -s reload #让容器里的nginx重新读取nginx配置文件
/usr/local/nginx/sbin/nginx -V      # 查看模块
/usr/local/nginx/sbin/nginx -v      # 查看版本
echo 'export PATH=$PATH:/usr/local/nginx/sbin' >> /etc/profile && source /etc/profile  #把nginx加入系统变量

9.升级nginx

/data/soft/src
wget http://nginx.org/download/nginx-1.14.0.tar.gz
tar zxvf nginx-1.14.0.tar.gz
cd nginx-1.14.0
./configure --prefix=/usr/local/nginx --user=www --group=www --with-http_stub_status_module --with-http_v2_module --with-http_ssl_module --with-http_gzip_static_module --with-http_realip_module --with-http_flv_module --with-http_mp4_module --with-openssl=../openssl-1.0.2o --with-pcre=../pcre-8.42 --with-pcre-jit --with-ld-opt=-ljemalloc --with-http_geoip_module
make; make install

vi /usr/local/nginx/conf/fastcgi.conf   # 容器里,底部新增
# GeoIP
fastcgi_param GEOIP_COUNTRY_CODE $geoip_country_code;
fastcgi_param GEOIP_COUNTRY_CODE3 $geoip_country_code3;
fastcgi_param GEOIP_COUNTRY_NAME $geoip_country_name;
fastcgi_param GEOIP_CITY_COUNTRY_CODE $geoip_city_country_code;
fastcgi_param GEOIP_CITY_COUNTRY_CODE3 $geoip_city_country_code3;
fastcgi_param GEOIP_CITY_COUNTRY_NAME $geoip_city_country_name;
fastcgi_param GEOIP_REGION $geoip_region;
fastcgi_param GEOIP_CITY $geoip_city;
fastcgi_param GEOIP_POSTAL_CODE $geoip_postal_code;
fastcgi_param GEOIP_CITY_CONTINENT_CODE $geoip_city_continent_code;
fastcgi_param GEOIP_LATITUDE $geoip_latitude;
fastcgi_param GEOIP_LONGITUDE $geoip_longitude;

service nginx restart

10.重启容器.

签名:这个人很懒,什么也没有留下!
最新回复 (0)
返回