安装依赖库
$ sudo apt install libpcre3-dev zlib1g-dev libssl-dev libxml2-dev -libxslt-dev libgd-dev libgeoip-dev
安装数据库
数据库二选一,要么用postgresql,要么用mysql
安装postgresql
$ sudo apt install postgresql-9.5 postgresql-9.5-client
$ sudo apt install postgresql-9.5-memcache
安装mysql
$ sudo apt install mysql-server mysql-client
安装nginx
$ sudo apt install nginx
下面这个是ubuntu上的nginx编译配置
$ ./configure --prefix=/usr/share/nginx --conf-path=/etc/nginx/nginx.conf --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --lock-path=/var/lock/nginx.lock --pid-path=/run/nginx.pid --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --with-debug --with-pcre-jit --with-ipv6 --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-http_auth_request_module --with-http_addition_module --with-http_dav_module --with-http_geoip_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_image_filter_module --with-http_v2_module --with-http_sub_module --with-http_xslt_module --with-stream --with-stream_ssl_module --with-mail --with-mail_ssl_module --with-threads
修改nginx配置
在目录/etc/nginx/site-available/
下,新建你的网站配置文件,如jenkin.conf
$ sudo vim /etc/nginx/site-available/jenkin.conf
配置文件内容
server {
listen 80;
server_name jenkin.oschina.net;
root /var/www/html;
index index.php index.html index.htm index.nginx-debian.html;
location / {
try_files $uri $uri/ =404;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location =/50x.html {
root /var/www/html;
}
location ~ \.php$ {
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
创建链接
$ sudo ln -s /etc/nginx/sites-available/jenkin.conf /etc/nginx/sites-enabled/jenkin.conf
安装php
当前默认php版本为7.0,如果使用mysql,则安装php-mysql
,如果使用postgresql,则安装php-pgsql
。
$ sudo apt install php-fpm php
$ sudo apt install php-pgsql
$ sudo apt install php-mysql
创建数据库
$ sudo su - postgres
$ psql
postgres=# CREATE USER wordpress WITH PASSWORD 'wordpress';
postgres=# CREATE DATABASE wordpress OWNER wordpress;
postgres=# GRANT ALL PRIVILEGES ON DATABASE wordpress to wordpress;
postgres=# \q
配置php-fpm
在/etc/php/7.0/fpm/php.ini
文件中,做以下修改:
;cgi.fix_pathinfo=1 --> cgi.fix_pathinfo=0
安装wordpress
下载地址: https://cn.wordpress.org/
下载完成后,通过scp命令拷贝到主机上。
$ scp -p 22 wordpress-4.9.tar.gz jenkin@192.168.1.33:/home/jenkin/
将wordpress解压到/var/www/html/
目录下,将pg4wd目录拷贝到/var/www/html/wordpress/wp-content/
目录下。
创建wp-config.php
$ sudo cp /var/www/html/wordpress/wp-config-sample.php /var/www/html/wordpress/wp-config.php
注意,postgresql还需要安装pg4wp插件,如果用mysql,则不需要这个。
$ git clone https://github.com/kevinoid/postgresql-for-wordpress.git
$ sudo ln -s /var/www/html/wordpress/wp-content/pg4wp/db.php /var/www/html/wordpress/wp-content/db.php
修改其中的
define('DB_NAME', 'wordpress');
define('DB_USER', 'wordpress');
define('DB_PASSWORD', 'wordpress');
还有很重要的一步,将wordpress目录修改为www-data所有者
$ sudo chown www-data:www-data -R /var/www/html/*
最后重启服务即可(或者重启电脑)
$ sudo systemctl restart nginx
$ sudo systemctl restart php