Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision | |||
| vendors:cisco:uc:ece:chatapiserver-ubuntu [2023/04/12 16:49] – removed - external edit (Unknown date) 127.0.0.1 | vendors:cisco:uc:ece:chatapiserver-ubuntu [2023/04/12 16:49] (current) – ↷ Page moved and renamed from code:redis to vendors:cisco:uc:ece:chatapiserver-ubuntu gerardorourke | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ====== Chat API on Ubuntu ====== | ||
| + | |||
| + | This page needs reviewing and correcting. | ||
| + | The Redhat version is valid and up to date. | ||
| + | |||
| + | ===== Redis ===== | ||
| + | |||
| + | * https:// | ||
| + | * https:// | ||
| + | * https:// | ||
| + | * https:// | ||
| + | |||
| + | ===== PHP ===== | ||
| + | |||
| + | *https:// | ||
| + | *https:// | ||
| + | *https:// | ||
| + | |||
| + | ===== Redis on Ubuntu ===== | ||
| + | |||
| + | *Install PHP Redis Module | ||
| + | < | ||
| + | |||
| + | *Install Curl Module | ||
| + | < | ||
| + | |||
| + | *Install XML Module | ||
| + | < | ||
| + | |||
| + | *Apache Logging | ||
| + | < | ||
| + | |||
| + | *Enable SSL | ||
| + | *https:// | ||
| + | *Create CSR | ||
| + | *https:// | ||
| + | |||
| + | ===Certs and Keys === | ||
| + | *Store the private key in the / | ||
| + | *Store the CA Cert on the / | ||
| + | *Store the signed cert in the above folder | ||
| + | *Update the apache site conf file | ||
| + | |||
| + | ==== Enable CORS ==== | ||
| + | |||
| + | < | ||
| + | |||
| + | ==== Load Test ===== | ||
| + | * Apache Bench (AB) | ||
| + | * https:// | ||
| + | * https:// | ||
| + | |||
| + | |||
| + | < | ||
| + | eceadmin@ubuntu100:/ | ||
| + | [1] 124932 | ||
| + | eceadmin@ubuntu100:/ | ||
| + | Copyright 1996 Adam Twiss, Zeus Technology Ltd, http:// | ||
| + | Licensed to The Apache Software Foundation, http:// | ||
| + | |||
| + | Benchmarking api.ubuntu100.lab1.mydomain.com (be patient) | ||
| + | Completed 500 requests | ||
| + | Completed 1000 requests | ||
| + | Completed 1500 requests | ||
| + | Completed 2000 requests | ||
| + | Completed 2500 requests | ||
| + | Completed 3000 requests | ||
| + | Completed 3500 requests | ||
| + | Completed 4000 requests | ||
| + | Completed 4500 requests | ||
| + | Completed 5000 requests | ||
| + | Finished 5000 requests | ||
| + | |||
| + | |||
| + | Server Software: | ||
| + | Server Hostname: | ||
| + | Server Port: 443 | ||
| + | SSL/TLS Protocol: | ||
| + | Server Temp Key: X25519 253 bits | ||
| + | TLS Server Name: api.ubuntu100.lab1.mydomain.com | ||
| + | |||
| + | Document Path: / | ||
| + | Document Length: | ||
| + | |||
| + | Concurrency Level: | ||
| + | Time taken for tests: | ||
| + | Complete requests: | ||
| + | Failed requests: | ||
| + | Total transferred: | ||
| + | HTML transferred: | ||
| + | Requests per second: | ||
| + | Time per request: | ||
| + | Time per request: | ||
| + | Transfer rate: 171.14 [Kbytes/ | ||
| + | |||
| + | Connection Times (ms) | ||
| + | min mean[+/-sd] median | ||
| + | Connect: | ||
| + | Processing: | ||
| + | Waiting: | ||
| + | Total: | ||
| + | |||
| + | Percentage of the requests served within a certain time (ms) | ||
| + | 50% 1028 | ||
| + | 66% 1054 | ||
| + | 75% 1074 | ||
| + | 80% 1091 | ||
| + | 90% 1140 | ||
| + | 95% 1165 | ||
| + | 98% 1200 | ||
| + | 99% 1213 | ||
| + | | ||
| + | |||
| + | [1]+ Done ab -n 5000 -c 500 https:// | ||
| + | |||
| + | </ | ||
| + | |||
| + | ==== Example Apache Benmakr against the CCE Business Hours API ==== | ||
| + | |||
| + | The below has Verbosity set to 4 - so you can see the response for each request. | ||
| + | |||
| + | < | ||
| + | |||
| + | ===== Enable Root SSH ==== | ||
| + | |||
| + | *Set root password < | ||
| + | *Edit / | ||
| + | < | ||
| + | *restart sshd < | ||
| + | |||
| + | |||
| + | ====== Installing Apache, PHP and Redis on Ubuntu ====== | ||
| + | |||
| + | The core components are: | ||
| + | *Apache Web Server | ||
| + | *PHP | ||
| + | *Redis - for caching (for X seconds) the API responses | ||
| + | |||
| + | ===== Installing Apache ===== | ||
| + | |||
| + | Reference: https:// | ||
| + | |||
| + | *Check what packages are currently installed. | ||
| + | *< | ||
| + | * Install Apache - < | ||
| + | * Enable for Auto startup < | ||
| + | * Open Firewall on port 80 < | ||
| + | * Reload Firewall < | ||
| + | * Start Apache Service < | ||
| + | * Root Folder is located here: **/ | ||
| + | * Make sure any directories you create have r and x permissions for all. | ||
| + | * Make sure any web files you create have read permissions for all | ||
| + | * View Log files written | ||
| + | * < | ||
| + | * open access logs < | ||
| + | * open error logs < | ||
| + | |||
| + | ==== Enabling HTTPS ==== | ||
| + | |||
| + | Reference1: https:// | ||
| + | Reference2: https:// | ||
| + | |||
| + | Redhat 8 Security guide - https:// | ||
| + | |||
| + | //The mod_ssl configuration file is located at / | ||
| + | // | ||
| + | |||
| + | * Install the SSL for httpd - < | ||
| + | * Restart apache - < | ||
| + | |||
| + | The SSL module install will have created it own SSL Cert with just the hostname and not the FQDN.\\ | ||
| + | So you will need to create your CSR (and if you want a temp Self Signed Cert). | ||
| + | The SSL Conf - **ssl.conf** file is located in **/ | ||
| + | You must also open the Firewall on port 443 and then reload the Firewall - as per below commands: | ||
| + | |||
| + | < | ||
| + | sudo firewall-cmd --permanent --add-port=443/ | ||
| + | sudo firewall-cmd --reload | ||
| + | sudo firewall-cmd --list-all | ||
| + | </ | ||
| + | |||
| + | === Create a Self Signed Cert === | ||
| + | < | ||
| + | Enter the details of your Self Signed Cert - making sure to include the FQDN when asked. Then update the ssl.conf file to utilise this certificate and restart the apache server. | ||
| + | < | ||
| + | SSLCertificateFile / | ||
| + | SSLCertificateKeyFile / | ||
| + | </ | ||
| + | |||
| + | === Create a CSR Certificate === | ||
| + | Below command saves the CSR file to the / | ||
| + | < | ||
| + | |||
| + | === Import Certifcates to Trusted Store === | ||
| + | Copy it to the cert to **/ | ||
| + | < | ||
| + | ===== Install Redis ===== | ||
| + | |||
| + | *install redis - < | ||
| + | *Enable auto startup - < | ||
| + | *Start Redis - < | ||
| + | *Check Statis - < | ||
| + | |||
| + | ===== Install PHP ===== | ||
| + | |||
| + | Install PHP 7.4 instead of the default PHP 7.2 - (7.2 is the default with RHE 8) | ||
| + | < | ||
| + | < | ||
| + | |||
| + | * Install PHP < | ||
| + | |||
| + | The core PHP install also by default installed the following modules (some output removed): | ||
| + | < | ||
| + | Installing: | ||
| + | | ||
| + | Installing dependencies: | ||
| + | | ||
| + | | ||
| + | | ||
| + | Installing weak dependencies: | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | </ | ||
| + | |||
| + | Hence you should not need to install Curl (Common), XML or JSON modules. | ||
| + | * Install PHP Curl Module< | ||
| + | * Install PHP XML Module< | ||
| + | * Install PHP JSON Module< | ||
| + | |||
| + | But you will need to install the Redis modules: | ||
| + | * Install PHP REDIS Module< | ||
| + | |||
| + | However this module was NOT available in the repository.... so an alternative approach is to download and install the module manually using the **pecl** | ||
| + | |||
| + | * Install PHP Pear - < | ||
| + | * pecl also requires the **php-devel** module - to be able to compile and install the extension - so we also need to install this@ | ||
| + | * < | ||
| + | * Download the redis php extension from pecl (PHP Extension Community Library - https:// | ||
| + | * Copy the extension to the machine (e.g. redis-5.3.7.tgz in this example) and then run the pecl install command as follows: | ||
| + | * < | ||
| + | |||
| + | However this pecl command didn't work - because of the following error: | ||
| + | < | ||
| + | shtool at '/ | ||
| + | Make sure that the file exists and is executable and then rerun this script. | ||
| + | </ | ||
| + | |||
| + | No exec privileges was confirmed with the following command: | ||
| + | < | ||
| + | [myuser@servername ~]$ mount -l | grep "/ | ||
| + | / | ||
| + | </ | ||
| + | |||
| + | To enable exec privilegdes run the following: | ||
| + | < | ||
| + | |||
| + | Once finished don't forget to REMOVE exec preivildges using this command: | ||
| + | < | ||
| + | |||
| + | When running the pecl command - it also failed - as **make** was not installed - so install this using | ||
| + | < | ||
| + | Following by < | ||
| + | < | ||
| + | ... | ||
| + | Build process completed successfully | ||
| + | Installing '/ | ||
| + | install ok: channel:// | ||
| + | configuration option " | ||
| + | You should add " | ||
| + | </ | ||
| + | |||
| + | Now revert back **exec** privileges - < | ||
| + | and edit the php file and restart php.\\ | ||
| + | |||
| + | However - do not configure the extension via php.ini as per above, since php also checks the following directory after the ini file. | ||
| + | **/ | ||
| + | |||
| + | So create a new file (chmod a+r) with a higher number than the json file, e.g. | ||
| + | < | ||
| + | < | ||
| + | ; Enable redis extension module | ||
| + | extension=redis | ||
| + | </ | ||
| + | |||
| + | Also edit each of the other extensions in this folder and disable them if not required. | ||
| + | |||
| + | |||
| + | |||
| + | |||
| + | < | ||
| + | |||
| + | Add the following lines at the end of the file - (note you need to load json BEFORE redis - as it required for redis to work | ||
| + | < | ||
| + | extension=json | ||
| + | extension=redis | ||
| + | </ | ||
| + | Restart PHP < | ||
| + | |||
| + | ==== SE Linux ==== | ||
| + | By default SELinux does not allow Apache to make socket connections. | ||
| + | To enable socket connections - use the following command: | ||
| + | < | ||
| + | |||
| + | For More information can be found [[https:// | ||
| + | [[https:// | ||
| + | |||
| + | When using setsebool with the -P to make the boolean change persistent, this updates the policy\\ | ||
| + | Use < | ||
| + | |||
| + | ====PHP TIPS ==== | ||
| + | |||
| + | *Confirm no warnings or errors on php by using the following < | ||
| + | *PHP-specific configuration for httpd - < | ||
| + | *All info on PHP install - < | ||
| + | *Location of php.ini file < | ||
| + | *If you make changes to the php.ini file - you need to restart php-fpm (note - no need to restart apache) - < | ||
| + | |||
| + | ===== Firewall Tips ===== | ||
| + | The **firewall-cmd --list-all** command shows you all the UDP/TCP ports opened - in below example - you can see only port 80 has been opened. | ||
| + | |||
| + | < | ||
| + | #sudo firewall-cmd --list-all | ||
| + | public (active) | ||
| + | target: default | ||
| + | icmp-block-inversion: | ||
| + | interfaces: eth0 | ||
| + | sources: | ||
| + | services: cockpit dhcpv6-client ssh | ||
| + | ports: 80/tcp | ||
| + | protocols: | ||
| + | forward: no | ||
| + | masquerade: no | ||
| + | forward-ports: | ||
| + | source-ports: | ||
| + | icmp-blocks: | ||
| + | rich rules: | ||
| + | </ | ||
| + | |||
| + | ===== Apache Tips ===== | ||
| + | |||
| + | * Check out what Modules are installed < | ||