ArchLinux:Nginx: Difference between revisions

From Wiki³
(Created page with "{{DISPLAYTITLE:{{TitleIcon|arch=true}} NGINX + PHP}}<metadesc>Web server setup for Arch Linux.</metadesc> <div id="tocalign">__TOC__</div> {{Back|Arch Linux}} = {{Icon24|sitem...")
 
No edit summary
Line 34: Line 34:
{{margin}}
{{margin}}
{{Console|title=postgresql.service|prompt=false|1=Environment{{=}}PGROOT{{=}}/nginx/sql<br/>PIDFile{{=}}/nginx/sql/postmaster.pid}}
{{Console|title=postgresql.service|prompt=false|1=Environment{{=}}PGROOT{{=}}/nginx/sql<br/>PIDFile{{=}}/nginx/sql/postmaster.pid}}
{{margin}}
Start and enable the systemd service.
{{Console|1=sudo systemctl enable --now postgresql.service}}
{{Console|1=sudo systemctl enable --now postgresql.service}}
Swap back over to the {{mono|postgresql}} user account.
{{Console|1=sudo -iu postgres}}
Create a new postgres user account.
{{Console|1=createuser -P --interactive<br/>Enter name of role to add: {{cyanBold|username}}<br/>Enter password for new role: {{cyanBold|********}}<br/>Enter it again: {{cyanBold|********}}<br/>Shall the new role be a superuser? (y/n) {{cyanBold|n}}<br/>Shall the new role be allowed to create databases? (y/n) {{cyanBold|y}}<br/>Shall the new role be allowed to create more new roles? (y/n) {{cyanBold|n}}}}
== {{Icon|notebook}} MariaDB ==
== {{Icon|notebook}} MariaDB ==
If {{mono|mariadb}} is to be used for the back-end, the following will be required.
If {{mono|mariadb}} is to be used for the back-end, the following will be required.
Line 45: Line 50:
{{margin}}
{{margin}}
{{Console|1=mariadb-install-db --user{{=}}mysql --basedir{{=}}/usr --datadir{{=}}/nginx/sql}}
{{Console|1=mariadb-install-db --user{{=}}mysql --basedir{{=}}/usr --datadir{{=}}/nginx/sql}}
{{margin}}
{{Console|1=echo -e "" | tee /etc/my.cnf.d/server.cnf




[[Category:Arch Linux]]
[[Category:Arch Linux]]

Revision as of 10:10, 28 April 2021

Icon Introduction

Icon NGINX

Beforehand be sure to determine weather the web server will be using MySQL (ie. MariaDB) or PostreSQL.

# pikaur -S composer curl minify nginx php-fpm sassc wget
 
# pikaur -S php-gd php-geoip php-imagic php-intl php-memcache php-pgsql php-sqlite php-sodium xdebug

Next create the environment for the web server.

# sudo mkdir -p /nginx/conf.d /nginx/https /nginx/logs /nginx/sql /nginx/ssl /nginx/vhosts.d
 
# sudo chmod -R 770 /nginx
 
# sudo chmod 750 /nginx/sql
 
# sudo gpasswd -a username http

Icon PostgreSQL

Using postgresql as a back-end will require the following setup and configuration.

# pikaur -S postgresql
 
# sudo chown postgres:postgres /nginx/sql
 
# sudo gpasswd -a username postgres

Swap over to the postgresql user account.

# sudo -iu postgres

Run the database initialization.

# initdb --locale en_US.UTF-8 -E UTF8 -D '/nginx/sql/data'

Return to the normal user account.

# exit

Modify the systemd service file to reflect the new data directory.

# sudo systemctl edit postgresql.service
 
filename: postgresql.service
Environment=PGROOT=/nginx/sql
PIDFile=/nginx/sql/postmaster.pid

Start and enable the systemd service.

# sudo systemctl enable --now postgresql.service

Swap back over to the postgresql user account.

# sudo -iu postgres

Create a new postgres user account.

# createuser -P --interactive
Enter name of role to add: username
Enter password for new role: ********
Enter it again: ********
Shall the new role be a superuser? (y/n) n
Shall the new role be allowed to create databases? (y/n) y
Shall the new role be allowed to create more new roles? (y/n) n

Icon MariaDB

If mariadb is to be used for the back-end, the following will be required.

# pikaur -S mariadb
 
# sudo chown mysql:mysql /nginx/sql
 
# sudo gpasswd -a username mysql
 
# mariadb-install-db --user=mysql --basedir=/usr --datadir=/nginx/sql
 

{{Console|1=echo -e "" | tee /etc/my.cnf.d/server.cnf