ubuntu搭建nginx+wordpress+postgresql

前端之家收集整理的这篇文章主要介绍了ubuntu搭建nginx+wordpress+postgresql前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

安装依赖库

$ sudo apt install libpcre3-dev zlib1g-dev libssl-dev libxml2-dev -libxslt-dev libgd-dev libgeoip-dev

安装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
原文链接:https://www.f2er.com/ubuntu/350538.html

猜你在找的Ubuntu相关文章