Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Clear out junk files and repair common Windows errors3Fix the driver behind crashes, sound loss and screen glitchesiTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more
Antihost offers Linux VPS plans with full root access, unlimited traffic on a 1 Gbps port and a 14-day free trial.
To store PHP sessions in Redis on Ubuntu, install the Redis server and the php-redis extension, set session.save_handler = redis and a Redis session.save_path in the php.ini used by your web SAPI, then restart PHP-FPM or Apache. Verify the connection with redis-cli monitor before putting the application into service.
The exact php.ini path, package availability, authentication syntax and locking behavior depend on your Ubuntu release, PHP version and phpredis build. Treat the examples below as a working baseline and confirm parameter names against the phpredis documentation installed for your version.
What this setup changes
PHP normally uses its configured session handler, often files on the local machine. With phpredis enabled, PHP sends session reads and writes to Redis instead. That gives multiple web servers a common session store when they all point to the same Redis service, rather than leaving each server with a separate set of session files.
Redis is a separate service, so the application now depends on a network endpoint, credentials (if configured), key naming and Redis availability. Session expiration, concurrent-request locking and behavior during a Redis outage must be tested on your own versions; they are not controlled solely by the two PHP directives.
#1 Best Overall
- Powerful Turbo Fan:CAGIWIRU Electric Air Duster have reached speed up to 130000RPM,Can efficient remove dust and debris.With LED light and Three Adjustable Speed to meet with different cleaning tasks.
- With Attached USB C Fasting Charging cable.Charing 3 hours,Enjoy up to 240 minutes of use on the lowest setting, For third speed can use for 25mins.with four charging options to meet with your needs.
- Wide Application:Upgraded attached 5 different nozzles,making it suitable for a variety of scenes, such as car,pet, pc, keyboards, and other electronic devices. It also serves for office and home clean duster.
- Handy Design & Portable:Cordless air duster electric nozzle is Light weight and small size, design and comfortable to hold and space saving, convenient to carry around. You can put it in your room or inside the car without taking up space.
- Warranty & Support: Our Electric air duster comes with 5 years warranty and 24/7 customer service. During this period, if you have any questions,pls kindly feel free to contact us.
Prerequisites and decisions
- An Ubuntu host on which you can install packages and edit system configuration.
- A PHP installation used by the web application. The command-line PHP version is not necessarily the same SAPI or version used by PHP-FPM or Apache.
- A decision about whether Redis runs on the same host (
127.0.0.1in the examples) or on a protected separate host. - If more than one application will use the Redis instance, a distinct database number or key prefix for each application.
- A plan for Redis authentication and network restrictions before exposing the service beyond localhost.
The package names used by the Ubuntu tutorials are redis-server and php-redis. Package names and available PHP module builds can vary by Ubuntu release, so check that those packages match your release and PHP version before installing.
1. Install Redis and the PHP extension
- Refresh Ubuntu’s package index:
sudo apt update - Install the Redis server and phpredis extension:
sudo apt install redis-server php-redis - Confirm that the PHP SAPI which will serve the site can load the extension. For the command-line SAPI, this is a useful first check:
php -m | grep -i redisIf the command returns
redis, the CLI module is loaded. A different PHP-FPM pool or Apache module can use a different PHP version and configuration, so this check alone does not prove that the web request can load it.
Do not assume a particular Redis or php-redis package version from the installation command. One Ubuntu tutorial associates Ubuntu 24.04 with Redis 7.x, but that package-version claim is not independently confirmed here; use apt policy redis-server php-redis on your host to see what your configured repositories provide.
Recommended Free Tools
2. Find the php.ini used by the web request
PHP reads configuration per SAPI. Editing the CLI file while the site runs under PHP-FPM is a common reason the setting appears to have no effect.
PHP-FPM
A typical path is:
/etc/php/8.3/fpm/php.ini
Replace 8.3 with the PHP version actually used by the FPM pool. The path is an example, not a universal Ubuntu location.
Apache with mod_php
A typical Apache path is:
/etc/php/8.3/apache2/php.ini
Again, use the directory for the PHP version loaded by Apache.
Confirm from the running application
For a temporary diagnostic page, display phpinfo() and check the “Loaded Configuration File” value and the PHP version. Remove or restrict that page immediately after checking it because phpinfo exposes environment details. Alternatively, inspect the service configuration and the output of php --ini, while remembering that the latter describes the CLI SAPI.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Rank #2
- Screen Cleaner is Your Screen’s New Bestfriend! - EVEO is proud to present a screen cleaner that’s perfectly suited for your TV. Meet your new screen cleaner, computer screen cleaner, laptop cleaner, iPad cleaner, Macbook,tv cleaner or any other electronic device. Our screen cleaner spray and wipe along with the included plush microfiber cloth, easily removes dust, fingerprints & other smudges on the screen’s surface. Clean effectively for a streak-free screen
- Gentle on your Screens - Our screen cleaner spray and wipes is compatible to be used even for the most sensitive LCD, LED, CRT, and OLED screens in proper use. Be at ease knowing that this product is compatible with all the major brands: LG, SONY, Samsung, Sharp, iPad, iPhone, Android screens, Kindle, PC monitors - we’ve got you covered! Can be used as LCD screen cleaner, tv cleaner, smart tv screen cleaner, and more
- Premium Super Soft Plush Microfiber Cloth - Included in this efficient screen cleaning kit. This screen cleaner spray and wipe has our signature plush microfiber cloth specially designed to comply with screens and monitors and leave them streak-free. Has been shown to effectively absorbs stubborn stains, zero streaks, and no fiber shedding. Always use this together with our screen cleaner for the best results
- Easy-to-Use Screen Cleaner Kit + microfiber cleaning cloth - The EVEO Screen Cleaning Kit will easily be your new favorite tool when it comes to taking care of the things you love most, quick and easy solution for a streak-free screen. Simply screw on the sprayer gun on the screen cleaner bottle. Spray the cleaning liquid onto the microfiber cloth, then wipe the screen until desired cleanliness & shine is achieved.
- Quality Screen Care Kit Worth Purchasing - Enjoy a convenient Screen Cleaner anytime, anywhere you need it. Your satisfaction is our top priority. We stand behind the quality of our products and that’s why, you shouldn’t be worrying at all. We manufacture the Best Screen Cleaner. and can be used for laptop cleaning kit, laptop screen cleaner, tv screen cleaner for smart tv. MacBook screen cleaner, monitor cleaner or screen cleaner spray for electronic devices with microfiber cleaning cloth
3. Set the Redis session directives
Open the SAPI-specific php.ini and add or change these directives:
session.save_handler = redis
session.save_path = "tcp://127.0.0.1:6379"
The first line selects phpredis as the session handler. The second specifies a TCP connection to Redis on the local machine’s default port. Keep the value quoted, especially when you later add a query string.
| Directive | Purpose | Example |
|---|---|---|
session.save_handler |
Selects the PHP session storage implementation. | redis |
session.save_path |
Gives phpredis the Redis endpoint and optional connection parameters. | tcp://127.0.0.1:6379 |
Do not put these lines only in application code if you need every request, including framework bootstrap requests, to use Redis. The SAPI configuration is the predictable place for a site-wide session handler. If an application deliberately calls ini_set(), its runtime values can override the file, so inspect the effective values during troubleshooting.
4. Add authentication, database selection and key prefixes
phpredis extends the URI with a query string. A combined example is:
Quick wins for a faster PC:
Repair Windows errors before they cause bigger problemsFix Now →Scan for outdated or missing drivers - takes under a minuteDriver Scan →session.save_path = "tcp://127.0.0.1:6379?auth=yourpassword&database=1&prefix=myapp_session:"
Use the options supported by your installed phpredis release. The following forms are reported in phpredis examples and tutorials:
| Option | Example | Use |
|---|---|---|
| Authentication | auth=yourpassword |
Supplies a password. A single-value form is seen in practice. |
| Username and password | auth[]=user&auth[]=password |
The documented array form in a phpredis pull-request example for ACL-style credentials. |
| Database | database=1 |
Selects a Redis logical database instead of the default database. |
| Prefix | prefix=myapp_session: |
Places an application-specific prefix in session keys. |
| Persistent connection | persistent=1 |
Requests a persistent Redis connection where supported by the build. |
| Weight | weight=1 |
Used with supported multi-endpoint connection definitions. |
The default key prefix reported for phpredis sessions is PHPREDIS_SESSION:. If you set a custom prefix, use that exact value when inspecting keys. Percent-encode reserved characters in passwords before placing them in the URI; otherwise an ampersand, question mark or other delimiter can be interpreted as part of the connection string rather than the credential.
Rank #3
- 【Large size】:Measuring 800 x 300 mm/ 31. 5×12 inches, which is wider and taller than others. Large mouse pad can perfectly fit your keyboard and mouse of any size, and there is also ample space for peripherals such as phones, tablets, etc.
- 【LED backlight mouse pad】:Blade Hawks RGB mouse pad provides 7 static modes and 7 dynamic modes will give you the options you are looking for. Power-off memory function remembers the last lighting mode you selected. The super glow fiber Chroma will give you a colorful gaming setup that you want.
- 【Anti-slip rubber base】:Made from Natural rubber, this gaming mousepad will firmly grip your desktop, allowing you to enjoy the ultimate precision in the games you are most passionate about. It also comes with a texture that enhances this ability even further.
- 【Smooth and waterproof surface】: Micro-textured cloth surface, for extremely precise mouse control and a smooth movement. When liquid splashes on the gaming mouse pad, it forms water droplets and slides down. Will not delay your work or gameplay.
- 【Plug and play】: This mouse and keyboard pad is powered by USB, plug and play, no driver required. One button control light modes. Press one time to change the lighting mode, press twice to change the brightness, press and hold about 3 seconds turn ON/OFF.
Multiple Redis hosts
phpredis accepts multiple hosts separated by commas in the save path. Because parsing and failover support differ by version, test the exact string with your installed extension rather than assuming that a list provides cluster semantics. Session locking is reported as supported only for a single-master Redis arrangement, such as a traditional master/replica deployment managed with Sentinel; do not infer that arbitrary clustered topologies provide equivalent locking.
Unix-socket connections
If Redis listens on a Unix socket, a reported form is:
session.save_path = "unix:///var/run/redis/redis.sock?persistent=1&weight=1&database=0"
Use the socket path configured on your host and ensure the PHP worker account has permission to open it. A TCP loopback connection is simpler to diagnose, while a socket can avoid TCP exposure on a single host.
5. Restart the SAPI that serves the site
Configuration changes are read when PHP workers start. Restart the service that owns the edited php.ini:
- For PHP-FPM, restart the versioned FPM service used by the virtual host, for example
sudo systemctl restart php8.3-fpmafter confirming the version and service name. - For Apache with mod_php, restart Apache, for example
sudo systemctl restart apache2.
Refreshing a browser without restarting the workers can continue using the old handler. If you operate several FPM pools or web servers, restart each one or roll the change out consistently.
6. Verify that PHP is writing sessions to Redis
Watch Redis traffic
- In one terminal, start the Redis monitor:
redis-cli monitor - In another terminal or browser, load a PHP endpoint that calls
session_start(), writes a small session value and then reads it on a subsequent request. - Return to the monitor and inspect the commands generated for the session key.
Older tutorial examples describe seeing GET and SETEX. phpredis documentation examples also refer to SET with EX and NX options. The command sequence can therefore differ by phpredis and Redis version; use the monitor output from your own installation as the authoritative test, not a screenshot from another release.
Rank #4
- 【Softer and More Comfortable】Vaydeer wrist rest has unique diamond pattern, which is the combination of softness and aesthetics. The materials of wrist rest are improved into higher quality memory foam and covered with silky smooth lycra. The computer wrist rest makes you as comfortable and cushiony as like rest your wrists on clouds.
- 【Ergonomic Wrist Saver】The wrist rests for keyboard and mouse comes with a 17.32×3.15×0.83 inch keyboard wrist pad and a 5.94×3.15×0.83 inch mouse wrist support. Based on ergonomic design, the unique concave shape is the perfect fit for your wrist joints. The wrist rest pad fits most computer keyboards and laptops, improve hand and wrist posture, release your wrist and arm stress.
- 【Non-Slip Rubber Bottom】Featuring an anti-skid silicone base on the bottom, this wrist keyboard support stays firmly in place on your desk, preventing the padding from sliding around, ensuring stable and consistent wrist support during extended computer sessions.
- 【Better Experience & Pain Relief】Our keyboard arm rest is beneficial to alleviate the soreness caused by direct contact and friction between your arm and a hard desk surface, reducing the risk of wrist fatigue or carpal tunnel. The soft texture of memory foam can evenly distribute the pressure around your wrists and provide good support with just enough give.
- 【Helpful in Multiple Scenarios】Whether you're working, studying, writing, typing, gaming, this keyboard and mouse rest combo is an essential accessory to add comfort and support to your hands and wrists. It’s also a great gift for men, women, family, friend, coworker, gamer, teacher, etc.
Inspect keys without exposing values
After creating a test session, list keys with the prefix configured for your application:
redis-cli keys 'PHPREDIS_SESSION:*'
For production-sized databases, avoid running the blocking KEYS command broadly. Use a prefix appropriate to your environment and a controlled test window; if your Redis tooling and version support it, a cursor-based scan is safer for a large keyspace. The key check is an additional diagnostic, while monitor confirms that the PHP request is actually issuing Redis commands.
Test persistence across requests
Create a test page that sets a session value, open a new request and confirm the value remains. Then inspect the key’s expiration in Redis and verify that an expired session is no longer accepted by the application. The exact expiry and garbage-collection behavior comes from PHP and phpredis settings; do not assume it matches file sessions without testing.
Security and network hardening
Redis binds to localhost by default in the common Ubuntu configuration. That is a safe starting point when PHP and Redis share one host, but it is not a substitute for authentication and firewall policy if the service must be reached from another machine.
Free tools Windows power users keep installed
One-click scans. No signup required.
- Keep port
6379off public interfaces. If a separate web server must connect, bind Redis only to the required private address and restrict the port with host and network firewalls. - Configure Redis authentication appropriate to your Redis version and reference the credential in
session.save_pathusing the syntax your phpredis build accepts. - Protect
php.iniand deployment secrets. The save path contains a password when authentication is enabled, so limit file permissions and avoid publishing it in diagnostics. - Use a dedicated logical database or a distinctive prefix when other applications share the Redis service. This reduces accidental key collisions but is not a security boundary between mutually untrusted tenants.
- If traffic crosses hosts, evaluate transport encryption and network isolation; a plain TCP URI does not itself provide encryption.
Locking, concurrent requests and outages
Two simultaneous requests for the same session can otherwise overwrite one another. phpredis has session-locking support, but the available controls and defaults are version-dependent. A code example reported by users includes these INI names:
| Setting | Reported role |
|---|---|
redis.session.locking_enabled |
Turns session locking on or off. |
redis.session.lock_expire |
Controls how long a lock remains valid. |
redis.session.lock_wait_time |
Wait interval in microseconds; a reported default is 2,000. |
redis.session.lock_retries |
Number of retries; a reported default is 10. |
These names and defaults are not confirmed for every Ubuntu package. Check the phpredis documentation or the module information for your installed release before adding them, then load-test requests that update one session concurrently. A locking failure issue has been reported in the phpredis project, so treat lock errors as an operational condition to monitor rather than assuming they are impossible.
Best Value
- 【No Drill Mounted】Cable management tray can be assembled in as little as 3 minutes or less-simply. Side clips easily clampe the edge of desk, pass through the holes on the sides, and secure excess cables with baskets. Desk cable management supports inward or outward installation to meet your needs in different scenarios, and provides you with great convenience when collecting and organizing wires.
- 【Rubber Pad Protects Desk】Wire organizer under desk built-in soft rubber pads on the clamp protect your desk from scratches, so you will not damage your furniture or office.
- 【Sturdy and Beautiful】Cord management under desk is made of high-quality carbon steel and holds about 15 lbs. The wire basket has 2 holes on each side of the tray to enable your cables to pass freely. Cable baskets are suitable for desk thickness use from 0.4" to 2.4".
- 【Space Saving & Keep Organized】Desk cable management tray holds all your power cords, outlet strips, USB hubs and computer transformers hidden from your feet, and the data cables will not enter the vacuum cleaner to keep your desk clean and tidy. Desk wire organizer is also suitable for use in the kitchen and outdoors.
- 【Reduce Safety Risks】Cable tray under desk keeps all plugs away from your kids, no more worry about tripping. Using 2 holes wire tray saves extra space, helps you easily cabling and wire protection. The mesh design is not easy to accumulate dust, but avoids safety accidents caused by messy wires.
Redis outages need explicit testing. One reported issue found that a two-second timeout supplied in connection parameters did not make a script finish promptly after Redis was stopped. Set realistic web-server and PHP timeouts, test failure behavior in a staging environment and decide whether the application should fail closed, ask the user to retry or temporarily use another session mechanism. Do not describe a connection timeout as a guaranteed upper bound until your exact PHP, phpredis and Redis versions demonstrate it.
Redis persistence and session lifetime
Redis sessions survive a Redis process restart only when Redis persistence is configured in redis.conf. The particular persistence directives and their values were not established here, so consult the configuration shipped with your Ubuntu release and choose a policy deliberately. Persistence also affects recovery objectives and disk usage; it does not remove the need to expire old session keys.
The Tool Desk
Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Session lifetime is governed by the interaction of PHP session settings, the phpredis handler and Redis key expiration. Confirm the actual TTL with a test session, especially after changing session.gc_maxlifetime, application cookie lifetime or custom framework settings. A browser cookie can outlive a Redis key, in which case the next request behaves like a new session.
Redis sessions compared with other handlers
| Consideration | Local file sessions | Redis sessions | Database sessions |
|---|---|---|---|
| Sharing across web servers | Requires shared filesystem or routing that keeps a user on one server. | Natural fit when all servers can reach the same Redis endpoint. | Shared when every server uses the same database and table. |
| Restart behavior | Depends on the filesystem and deployment lifecycle. | Depends on Redis persistence and restart policy. | Depends on database durability and cleanup policy. |
| Expiration and garbage collection | Uses PHP file-session cleanup behavior. | Uses Redis key expiry together with PHP/phppredis session settings. | Requires driver-specific expiry or cleanup jobs. |
| Concurrent requests | Uses the file handler’s locking behavior. | phpredis locking is available but version- and topology-dependent. | Depends on the database driver and transaction/locking design. |
| Network exposure | None when files are local. | Requires securing the Redis listener, credentials and any cross-host traffic. | Requires securing the database listener and credentials. |
Choose Redis when shared, low-latency session storage is more important than keeping state local and you can operate Redis securely. Keep the design simple if the application runs on one server and local files already satisfy its availability requirements.
Troubleshooting checklist
The site still uses file sessions
- Check the effective
session.save_handlerandsession.save_pathfrom the web SAPI, not only from the CLI. - Confirm that
php-redisis installed for the PHP version used by FPM or Apache. - Restart the correct SAPI service after editing
php.ini. - Look for a framework or bootstrap call that overrides the INI values.
No traffic appears in redis-cli monitor
- Verify that the test request actually calls
session_start(); a page that never starts a session will not create session traffic. - Check the host, port, database and prefix in
session.save_path. - Test the Redis endpoint from the same host and under the same network restrictions as the PHP worker.
- Inspect PHP and web-server error logs for an extension-load or authentication error.
Authentication fails
- Confirm whether your phpredis build expects
auth=passwordor the array formauth[]=user&auth[]=password. - Percent-encode special characters in the password.
- Ensure the URI’s ampersands are preserved in the actual configuration value; HTML escaping applies only when displaying the string in a web page.
Sessions disappear unexpectedly
- Inspect the Redis key TTL and compare it with PHP and application session-lifetime settings.
- Check whether Redis was restarted without the persistence policy you expected.
- Verify that every web server uses the same endpoint, database and prefix.
- Check for lock failures or connection errors during the period in which sessions vanished.
Session names or keys look different than expected
An older 2013 report claimed that phpredis ignored a session name set in php.ini or with session_name(). That behavior has not been re-verified against current phpredis releases. If your application depends on a particular session name, test it on the exact package version you deploy and inspect the resulting cookie and Redis key rather than relying on the old report.
Quick Recap
Production handoff checklist
- Record the PHP version, SAPI and phpredis package version for every web host.
- Keep
session.save_handler = redisand the matchingsession.save_pathin the configuration used by that SAPI. - Use authentication, a protected bind address and firewall rules whenever Redis is reachable beyond localhost.
- Choose a database or prefix that cannot collide with unrelated applications.
- Restart all relevant PHP workers and verify a real session with
redis-cli monitor. - Test concurrent requests, expiration, Redis restart recovery and complete Redis outage behavior before rollout.
- Recheck phpredis parameter names and locking options whenever Ubuntu or PHP packages are upgraded.
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

