URLOS实战入门—制作LNP网站环境

文档首页

URLOS实战入门—制作LNP网站环境

1、制作LNP镜像

1.1.用ssh登录自己的宿主机器,创建Dockerfile文件,并填充以下内容

 FROM php:7.3.3-fpm-alpine3.9
 ENV TIME_ZONE Asiz/Shanghai
 RUN sed -i 's@dl-cdn.alpinelinux.org@mirrors.aliyun.com@' /etc/apk/repositories \
  && apk add autoconf g++ make nginx \ 
  && apk add libxml2-dev icu-dev freetype-dev libjpeg-turbo-dev libpng-dev libzip-dev \ 
  && docker-php-ext-install zip bcmath intl mbstring mysqli pdo_mysql exif sockets \
  && docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
  && docker-php-ext-install gd \
  # 安装redis 扩展
  && cd /var/www/html && wget https://pecl.php.net/get/redis-4.3.0.tgz \
  && tar xf redis-4.3.0.tgz && cd redis-4.3.0 \ 
  && phpize && ./configure && make && make install \
  && rm -rf /var/www/html/* \
  ##
   # 安装memcached扩展
  && cd /var/www/html && wget https://pecl.php.net/get/memcached-3.1.3.tgz \
  && apk add libmemcached-dev && tar xf memcached-3.1.3.tgz \
  && cd memcached-3.1.3 && phpize && ./configure && make && make install \
  && rm -rf /var/www/html/* \
  ##
  ## 安装composer
  && cd /var/www/html/ && php -r "copy('https://install.phpcomposer.com/installer', 'composer-setup.php');" \ 
  && php composer-setup.php \
  && php -r "unlink('composer-setup.php');" \
  && mv composer.phar /usr/bin/composer\ 
  ##
  && apk del g++ make

1.2.执行以下命令,生成镜像

 docker build -t urlos4/php:7.3.3-fpm-alpine3.9 .

1.3.运行镜像并进入容器

 docker run -itd --name test001 -p 8080:80 urlos4/php:7.3.3-fpm-alpine3.9
 docker exec -it test001 sh

1.4.设置nginx 虚拟站点配置

 vi /etc/nginx/conf.d/default.conf

配置内容如下:

 server {
    listen 80 default_server;
    root /var/www/html/;
    index index.php index.html;
    location / {
    }
    location ~ \.(php|phtml)$ {
        include fastcgi.conf;
        fastcgi_pass 127.0.0.1:9000;
    }
 }

1.5.在/var/www/html目录下创建index.php ,并填充以下内容

  echo "<?php phpinfo();" > /var/www/html/index.php

1.6.启动 nginx 和 php,使用浏览器访问http://ip:8080

 mkdir -p /run/nginx
 nginx
 php-fpm -D

1.7.测试无误后,将镜像上传到docker云端

 docker login # 已登录可忽略
 docker push urlos4/php:7.3.3-fpm-alpine3.9


2、基于URLOS创建LNP应用

2.1.登录URLOS, https://ip:9966/。未安装URLOS的,请使用以下命令执行安装

 curl -LO www.urlos.com/iu && sh iu 

2.2.添加镜像,如图:

点击提交,保存到URLOS。

2.3.使用复制应用的方式快速创建LNP应用,如图:


点击提交,保存应用数据。


3、创建LNP应用的模板

3.1.进入LNP应用管理模板页面。如图:


php.ini具体内容如下:

[PHP]
engine = On
short_open_tag = {w:PHP_short_open_tag:w}
asp_tags = Off
precision = 14
output_buffering = 4096
zlib.output_compression = Off
implicit_flush = Off
unserialize_callback_func =
serialize_precision = 17
disable_functions =
disable_classes =
zend.enable_gc = On
expose_php = On
max_execution_time = 30
max_input_time = 60
memory_limit = {w:PHP_memory_limit:w}
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
display_errors = Off
display_startup_errors = Off
log_errors = On
log_errors_max_len = 1024
ignore_repeated_errors = Off
ignore_repeated_source = Off
report_memleaks = On
track_errors = Off
html_errors = On
variables_order = "GPCS"
request_order = "GP"
register_argc_argv = Off
auto_globals_jit = On
post_max_size = {w:upload_max_filesize:w}
auto_prepend_file =
auto_append_file =
default_mimetype = "text/html"
default_charset = "UTF-8"
doc_root =
user_dir =
enable_dl = Off
file_uploads = On
upload_max_filesize = {w:upload_max_filesize:w}
max_file_uploads = 20
allow_url_fopen = On
allow_url_include = Off
default_socket_timeout = 60
extension=gd.so
extension=memcached.so
extension=redis.so
extension=sockets.so
extension=mysqli.so
extension=exif.so
extension=pdo_mysql.so
extension=bcmath.so
extension=zip.so
[CLI Server]
cli_server.color = On
[Date]
[filter]
[iconv]
[intl]
[sqlite3]
[Pcre]
[Pdo]
[Pdo_mysql]
pdo_mysql.cache_size = 2000
pdo_mysql.default_socket=
[Phar]
[mail function]
SMTP = localhost
smtp_port = 25
mail.add_x_header = On
[SQL]
sql.safe_mode = Off
[ODBC]
odbc.allow_persistent = On
odbc.check_persistent = On
odbc.max_persistent = -1
odbc.max_links = -1
odbc.defaultlrl = 4096
odbc.defaultbinmode = 1
[Interbase]
ibase.allow_persistent = 1
ibase.max_persistent = -1
ibase.max_links = -1
ibase.timestampformat = "%Y-%m-%d %H:%M:%S"
ibase.dateformat = "%Y-%m-%d"
ibase.timeformat = "%H:%M:%S"
[MySQL]
mysql.allow_local_infile = On
mysql.allow_persistent = On
mysql.cache_size = 2000
mysql.max_persistent = -1
mysql.max_links = -1
mysql.default_port =
mysql.default_socket =
mysql.default_host =
mysql.default_user =
mysql.default_password =
mysql.connect_timeout = 60
mysql.trace_mode = Off
[MySQLi]
mysqli.max_persistent = -1
mysqli.allow_persistent = On
mysqli.max_links = -1
mysqli.cache_size = 2000
mysqli.default_port = 3306
mysqli.default_socket =
mysqli.default_host =
mysqli.default_user =
mysqli.default_pw =
mysqli.reconnect = Off
[mysqlnd]
mysqlnd.collect_statistics = On
mysqlnd.collect_memory_statistics = Off
[OCI8]
[PostgreSQL]
pgsql.allow_persistent = On
pgsql.auto_reset_persistent = Off
pgsql.max_persistent = -1
pgsql.max_links = -1
pgsql.ignore_notice = 0
pgsql.log_notice = 0
[Sybase-CT]
sybct.allow_persistent = On
sybct.max_persistent = -1
sybct.max_links = -1
sybct.min_server_severity = 10
sybct.min_client_severity = 10
[bcmath]
bcmath.scale = 0
[browscap]
[Session]
session.save_handler = files
session.use_strict_mode = 0
session.use_cookies = 1
session.use_only_cookies = 1
session.name = PHPSESSID
session.auto_start = 0
session.cookie_lifetime = 0
session.cookie_path = /
session.cookie_domain =
session.cookie_httponly =
session.serialize_handler = php
session.gc_probability = 1
session.gc_divisor = 1000
session.gc_maxlifetime = 1440
session.referer_check =
session.cache_limiter = nocache
session.cache_expire = 180
session.use_trans_sid = 0
session.hash_function = 0
session.hash_bits_per_character = 5
url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=fakeentry"
[MSSQL]
mssql.allow_persistent = On
mssql.max_persistent = -1
mssql.max_links = -1
mssql.min_error_severity = 10
mssql.min_message_severity = 10
mssql.compatibility_mode = Off
mssql.secure_connection = Off
[Assertion]
[COM]
[mbstring]
[gd]
[exif]
[Tidy]
tidy.clean_output = Off
[soap]
soap.wsdl_cache_enabled=1
soap.wsdl_cache_dir="/tmp"
soap.wsdl_cache_ttl=86400
soap.wsdl_cache_limit = 5
[sysvshm]
[ldap]
ldap.max_links = -1
[mcrypt]
[dba]
[opcache]
[curl]
[openssl]

点击提交,保存模板数据。


4、创建LNP应用的扩展变量

进入应用的管理扩展变量列表,如图:


5、安装LNP应用并测试

点击提交,保存数据。URLOS会自动部署。

部署完成后,打开浏览器访问,如图: