Page 1 of 1

GNUWorld Website Setup on FreeBSD 13.2 server

Posted: Mon Aug 21, 2023 3:46 pm
by ZioN
Hello,
Bellow you can find all the steps needed to be done in order to build the GNWuorld (X and UWorld) Modules using FreeBSD 13.2 server.
Please keep in mind that the IP Address of the machine used for this HOWTO is 192.168.1.133 and it should be changed with the IP address of the machine where you want to have gnuworld installed.
OK, now let`s proceed....

1. We need to make sure that the server is update - to - date:
  • freebsd-update fetch
  • freebsd-update install
Install needed packages with FreeBSD package manager
  • pkg update -f
  • pkg install nano
  • pkg install plocate
  • updatedb
  • pkg install apache24 php82 php82-gd php82-pgsql php82-xml php82-readline php82-mbstring php82-sqlite3 php82-zip php82-zlib php82-curl php82-phar php82-filter php82-session readline-8.2.1 flex-2.6.4_2 git byacc bison openssl-1.1.1v,1 wget gmake-4.3_2 automake oath-toolkit-2.6.7_3
Before you boot Apache, you must enable it as root:
  • sysrc apache24_enable=yes
Then enter the command below to launch Apache:
  • service apache24 start
httpd.conf is located in : /usr/local/etc/apache24/
Install PHP82 module for apache:
  • pkg install mod_php82
Copy php.ini:
  • cp /usr/local/etc/php.ini-production /usr/local/etc/php.ini
  • nano /usr/local/etc/php.ini
change short_open_tag = Off to short_open_tag = On
Save the file and close it.

Run PHP as root:
  • sysrc php_fpm_enable=yes
  • service php-fpm start
Configure Apache PHP module
  • nano /usr/local/etc/apache24/modules.d/001_mod-php.conf
Then add the following entries to the file:
<IfModule dir_module>
DirectoryIndex index.php index.html
<FilesMatch "\.php$">
SetHandler application/x-httpd-php
</FilesMatch>
<FilesMatch "\.phps$">
SetHandler application/x-httpd-php-source
</FilesMatch>
</IfModule>
Test out the Apache Configuration with the command below:
  • apachectl configtest
To have the configurated changes apply, restart Apache with the following command:
  • apachectl restart

2. Now we proceed with installing composer as root:
  • curl -sS https://getcomposer.org/installer | php && mv composer.phar /usr/local/bin/composer
Skip Step 3 if local_db was already built when X was build and Webpage is on the same machine as X.
3. Install Postgresql 15 package as root:
  • pkg install postgresql15-contrib postgresql15-server
Enable Postgresql in rc.conf by running the following command.
  • sysrc postgresql_enable="YES"
Once the installation is complete, initialize the PostgreSQL database with the following command:
  • /usr/local/etc/rc.d/postgresql initdb -A trust -E=SQL_ASCII
Start the postgres using this command:
  • /usr/local/etc/rc.d/postgresql start
  • /usr/local/etc/rc.d/postgresql status
pg_ctl: server is running (PID: 36458)
/usr/local/bin/postgres "-D" "/var/db/postgres/data15"

/var/db/postgres/data15 - is the data folder, hosting new db-s and current running pg_hba.conf file.
  • nano /var/db/postgres/data15/pg_hba.conf
Add the following line:
  • Host all all 192.168.1.133/32 trust
Save and close file
Open postgresql conf file and set the host/ip that pgsql runs under:
  • nano /var/db/postgres/data15/postgresql.conf
listen_addresses='192.168.1.133'
Save and close the file
Restart pgsql server:
  • service postgresql restart
Now enable service on boot
  • service postgresql enable
  • su - postgres
  • psql
We create the user gnuworld in PgSQL:
  • create user gnuworld;
Now from pgsql console we create the databases with access on user gnuworld:
  • CREATE DATABASE local_db with OWNER='gnuworld' ENCODING='SQL_ASCII' LC_COLLATE='en_US.UTF-8' LC_CTYPE='en_US.UTF-8' TEMPLATE=template0;
We type "\l" to see database information:
postgres=# \l
List of databases
Name | Owner | Encoding | Collate | Ctype | ICU Locale | Locale Provider | Access privileges
-----------+----------+-----------+-------------+-------------+------------+-----------------+-----------------------
local_db | gnuworld | SQL_ASCII | en_US.UTF-8 | en_US.UTF-8 | | libc |
postgres | postgres | SQL_ASCII | C | C.UTF-8 | | libc |



4 .We get the webpage source code from UnderNet Official GitHub under user gnuworld:
  • su - gnuworld
  • git clone https://github.com/UndernetIRC/cservice-web
  • cd cservice-web/
  • composer install
  • cd php_includes/
  • cp config.inc.dist config.inc #edit the file with your own values
  • cp cmaster.inc.dist cmaster.inc
#replace all containing "localhost" with IP of the currrent running PGSQL server.
  • cp blackhole.inc.dist blackhole.inc
Skip Step 4.1 if local_db was already built when X was build and Webpage is on the same machine as X.
4.1 We get the gnuworld source code from UnderNet Official GitHub under user gnuworld:
  • su - gnuworld
  • git clone https://github.com/UndernetIRC/gnuworld
  • cd gnuworld/doc
## Building local_db (Website) database !!!
  • psql -h 192.168.1.133 -U gnuworld local_db < local_db.sql
5. Now to create the live shortcut for the webpage:
  • cd /usr/local/www/apache24/data/
- if is hosted under apache root folder.
  • chmod 711 ~gnuworld
  • chmod 711 ~gnuworld/cservice-web
  • chmod 755 ~gnuworld/cservice-web/php_includes
  • chmod 644 ~gnuworld/cservice-web/php_includes/config.inc
  • chmod 755 ~gnuworld/cservice-web/docs/gnuworld/
  • ln -s /home/gnuworld/cservice-web/docs/gnuworld live


6. There are two options to solve (IPR) restriction, bellow you can find how to on both.
  • su - gnuworld
6.1 - Fix (IPR) by inserting your ip into Admin account direct on database cservice.
  • pico ipr.sql
  • insert into ip_restrict (id, user_id, added_by, added, type, expiry, value) values (1, 1, 1, now()::abstime::int4, 1, 0, ‘192.168.0.93’);
##replace " 192.168.0.93 " with the ip address shown on whois on you on irc. !!!
  • /usr/local/pgsql/bin/psql -h 192.168.1.133 cservice < ipr.sql
##replace " 192.168.1.133 " with a real ip address of the machine hosting the cservice db.

6.2 - Fix (IPR) by disableing IPR option in config.inc file
  • su - gnuworld
  • cd gnuworld
  • pico cservice_web/php_includes/config.inc
  • change define("IPR_REQUIRED",1); to define("IPR_REQUIRED",0);
Save the file and close

7 In order to permit login on CService Web from local IP address like 192.168.xx.xx or 10.0.0.xx the following changes must be made:

nano /home/gnuworld/cservice-web/php_includes/config.inc
# Replace define("DISALLOW_RESERVED_BLOCKS",1); to define("DISALLOW_RESERVED_BLOCKS",0);

Now login using * accounts from local IP address is possible.



This HOWTO was last updated by ZioN
21 Aug 2023