mirror of
https://github.com/typecho/typecho.git
synced 2025-04-19 09:14:35 +02:00
fix install issue
add Dockerfile
This commit is contained in:
parent
820828757a
commit
e25022ecc1
@ -453,9 +453,9 @@ Typecho_Cookie::set('__typecho_lang', $lang);
|
||||
}
|
||||
}
|
||||
$adapter = _r('dbAdapter', $firstAdapter);
|
||||
list ($type) = explode('_', $adapter);
|
||||
$parts = explode('_', $adapter);
|
||||
|
||||
$type = $type == 'Mysqli' ? 'Mysql' : $type;
|
||||
$type = $adapter == 'Mysqli' ? 'Mysql' : array_pop($parts);
|
||||
?>
|
||||
<form method="post" action="?config" name="config">
|
||||
<h1 class="typecho-install-title"><?php _e('确认您的配置'); ?></h1>
|
||||
|
69
tools/Dockerfile
Normal file
69
tools/Dockerfile
Normal file
@ -0,0 +1,69 @@
|
||||
# define constants
|
||||
|
||||
FROM daocloud.io/ubuntu:16.04
|
||||
MAINTAINER Joyqi <magike.net@gmail.com>
|
||||
|
||||
ARG ubuntu_mirror=archive.ubuntu.com
|
||||
ARG php_mirror=cn2
|
||||
ARG php_version=7.0.14
|
||||
ARG php_timezone=Asia/Shanghai
|
||||
ARG nginx_version=1.10.2
|
||||
|
||||
# install base lib
|
||||
RUN sed -i 's/archive.ubuntu.com/'$ubuntu_mirror'/g' /etc/apt/sources.list && \
|
||||
apt-get update && \
|
||||
apt-get -y upgrade && \
|
||||
apt-get install -y autoconf wget vim build-essential git libxml2-dev pkg-config && \
|
||||
apt-get install -y libxml2-dev libcurl3-dev librecode-dev libjpeg-dev libpng12-dev libsasl2-2 sasl2-bin libsasl2-2 libsasl2-dev libsasl2-modules libfreetype6-dev libreadline-dev libpcre3-dev libssl-dev libcurl4-openssl-dev
|
||||
|
||||
# install mysql
|
||||
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y mysql-server && \
|
||||
sed -i -e "s/^bind-address\s*=\s*127.0.0.1/bind-address = 0.0.0.0/" /etc/mysql/mysql.conf.d/mysqld.cnf && \
|
||||
sed -i 's/^\(log_error\s.*\)/# \1/' /etc/mysql/my.cnf && \
|
||||
echo "mysqld_safe &" > /tmp/mysql_config && \
|
||||
echo "mysqladmin --silent --wait=30 ping || exit 1" >> /tmp/mysql_config && \
|
||||
echo "mysql -e 'GRANT ALL PRIVILEGES ON *.* TO \"root\"@\"%\" IDENTIFIED BY \"123456\" WITH GRANT OPTION;'" >> /tmp/mysql_config && \
|
||||
bash /tmp/mysql_config && \
|
||||
rm -f /tmp/mysql_config
|
||||
|
||||
VOLUME ["/etc/mysql", "/var/lib/mysql"]
|
||||
|
||||
# install nginx
|
||||
RUN mkdir /nginx && cd /nginx && \
|
||||
wget http://nginx.org/download/nginx-$nginx_version.tar.gz && \
|
||||
tar zxf nginx-$nginx_version.tar.gz && \
|
||||
cd nginx-$nginx_version && \
|
||||
./configure --prefix=/nginx && make && make install && \
|
||||
cd .. && rm -rf nginx-$nginx_version.tar.gz && rm -rf nginx-$nginx_version
|
||||
|
||||
ADD fastcgi_params /nginx/conf/fastcgi_params.modified
|
||||
ADD default_site /nginx/conf/nginx.conf
|
||||
VOLUME ["/nginx/conf", "/nginx/logs"]
|
||||
|
||||
# install php
|
||||
RUN mkdir /php && cd /php && \
|
||||
wget http://$php_mirror.php.net/distributions/php-$php_version.tar.gz && \
|
||||
tar zxf php-$php_version.tar.gz && \
|
||||
cd php-$php_version && \
|
||||
./configure --prefix=/php --with-config-file-path=/php/etc --with-config-file-scan-dir=/php/etc/conf.d --disable-cgi --enable-mysqlnd --with-curl --with-pcre-regex --with-readline --with-recode --with-zlib --enable-fpm --with-fpm-user=www-data --with-fpm-group=www-data --with-pdo-mysql --with-gd --with-jpeg-dir=/usr --with-png-dir=/usr --enable-mbstring --enable-phar=shared --enable-gd-native-ttf --with-freetype-dir=/usr/include/freetype2 --with-openssl && \
|
||||
make && make install && cp php.ini-production /php/etc/php.ini && mv /php/etc/php-fpm.conf.default /php/etc/php-fpm.conf && mv /php/etc/php-fpm.d/www.conf.default /php/etc/php-fpm.d/www.conf && \
|
||||
echo "date.timezone="$php_timezone >> /php/etc/php.ini && \
|
||||
sed -i 's/error_reporting = /#error_reporting = /g' /php/etc/php.ini && \
|
||||
sed -i 's/display_errors = /#display_errors = /g' /php/etc/php.ini && \
|
||||
sed -i -e 's/pdo_mysql.default_socket\s*=/pdo_mysql.default_socket = /var/run/mysqld/mysqld.sock/g' /php/etc/php.ini && \
|
||||
echo "always_populate_raw_post_data=-1" >> /php/etc/php.ini && \
|
||||
echo "error_reporting=E_ALL" >> /php/etc/php.ini && \
|
||||
echo "display_errors=On" >> /php/etc/php.ini && \
|
||||
echo "listen.owner = www-data" >> /php/etc/php-fpm.d/www.conf && \
|
||||
echo "listen.group = www-data" >> /php/etc/php-fpm.d/www.conf && \
|
||||
sed -i 's/listen = 127.0.0.1:9000/listen = var\/run\/php-fpm.sock/g' /php/etc/php-fpm.d/www.conf
|
||||
|
||||
VOLUME ["/php/var/log"]
|
||||
|
||||
# grant all privileges to www-data
|
||||
RUN usermod -u 1000 www-data
|
||||
|
||||
EXPOSE 80
|
||||
EXPOSE 3306
|
||||
|
||||
CMD /php/sbin/php-fpm && /nginx/sbin/nginx && mysqld_safe
|
36
tools/default_site
Normal file
36
tools/default_site
Normal file
@ -0,0 +1,36 @@
|
||||
user www-data;
|
||||
worker_processes 2;
|
||||
|
||||
events {
|
||||
worker_connections 1024;
|
||||
}
|
||||
|
||||
http {
|
||||
include mime.types;
|
||||
default_type application/octet-stream;
|
||||
|
||||
sendfile off;
|
||||
tcp_nopush on;
|
||||
tcp_nodelay on;
|
||||
|
||||
keepalive_timeout 65;
|
||||
|
||||
server {
|
||||
listen 80 default_server;
|
||||
server_name _;
|
||||
|
||||
root /www;
|
||||
index index.html index.php;
|
||||
|
||||
if (!-e $request_filename) {
|
||||
rewrite ^(.*)$ /index.php$1 last;
|
||||
}
|
||||
|
||||
location ~ [^/]\.php(/|$) {
|
||||
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
|
||||
fastcgi_pass unix:/php/var/run/php-fpm.sock;
|
||||
fastcgi_index index.php;
|
||||
include fastcgi_params.modified;
|
||||
}
|
||||
}
|
||||
}
|
25
tools/fastcgi_params
Normal file
25
tools/fastcgi_params
Normal file
@ -0,0 +1,25 @@
|
||||
fastcgi_param QUERY_STRING $query_string;
|
||||
fastcgi_param REQUEST_METHOD $request_method;
|
||||
fastcgi_param CONTENT_TYPE $content_type;
|
||||
fastcgi_param CONTENT_LENGTH $content_length;
|
||||
|
||||
fastcgi_param SCRIPT_FILENAME $request_filename;
|
||||
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
|
||||
fastcgi_param REQUEST_URI $request_uri;
|
||||
fastcgi_param DOCUMENT_URI $document_uri;
|
||||
fastcgi_param DOCUMENT_ROOT $document_root;
|
||||
fastcgi_param SERVER_PROTOCOL $server_protocol;
|
||||
|
||||
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
|
||||
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
|
||||
|
||||
fastcgi_param REMOTE_ADDR $remote_addr;
|
||||
fastcgi_param REMOTE_PORT $remote_port;
|
||||
fastcgi_param SERVER_ADDR $server_addr;
|
||||
fastcgi_param SERVER_PORT $server_port;
|
||||
fastcgi_param SERVER_NAME $server_name;
|
||||
|
||||
fastcgi_param HTTPS $https if_not_empty;
|
||||
|
||||
# PHP only, required if PHP was built with --enable-force-cgi-redirect
|
||||
fastcgi_param REDIRECT_STATUS 200;
|
@ -31,7 +31,7 @@ class Typecho_Db_Adapter_Mysqli implements Typecho_Db_Adapter
|
||||
*/
|
||||
public static function isAvailable()
|
||||
{
|
||||
return function_exists('mysqli_connect');
|
||||
return extension_loaded('mysqli');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -55,6 +55,17 @@ class Typecho_Db_Adapter_Mysqli implements Typecho_Db_Adapter
|
||||
throw new Typecho_Db_Adapter_Exception(@$this->_dbLink->error);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取数据库版本
|
||||
*
|
||||
* @param mixed $handle
|
||||
* @return string
|
||||
*/
|
||||
public function getVersion($handle)
|
||||
{
|
||||
return 'ext:mysqli ' . $this->_dbLink->server_version;
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行数据库查询
|
||||
*
|
||||
@ -117,7 +128,7 @@ class Typecho_Db_Adapter_Mysqli implements Typecho_Db_Adapter
|
||||
*/
|
||||
public function quoteColumn($string)
|
||||
{
|
||||
return '`' . $string . '`';
|
||||
return $resource->real_escape_string($string);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user