


How to fix 404 errors encountered when deploying a ThinkPHP 6 project on port 8088 via Nginx on Ubuntu?
Ubuntu system Nginx deploys ThinkPHP 6 project, 8088 port 404 error check
When deploying PHP projects using Nginx on Ubuntu, especially when listening for non-standard ports (such as 8088), you often encounter 404 errors. This article will analyze in detail the 404 problems encountered when deploying ThinkPHP 6 projects on port 8088 through Nginx on Ubuntu and provide solutions.
Problem description
On Ubuntu systems, using Nginx to deploy ThinkPHP 6 project to port 8088, accessing any interface or files under public directory will return a 404 error. The Alibaba Cloud Security Group has released port 8088.
Nginx configuration file
Configuration file under conf.d (xxx.conf):
server { listen 8088; server_name your server IP address; # Please replace it with your server IP root /path/to/your/project/public; # Please replace it with your project's public directory path index index.php index.html index.htm; location / { try_files $uri $uri/ /index.php?$args; # simplify try_files directive} location ~ \.php$ { try_files $uri =404; fastcgi_pass unix:/var/run/php/php7.4-fpm.sock; # Please check whether the php-fpm socket path is correct fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; # Use the standard parameter name include fastcgi_params; } }
nginx.conf file (some key configurations):
user www-data; worker_processes auto; # ... other configurations ... include /etc/nginx/conf.d/*.conf; # ... other configurations ...
Solution
Configuration file syntax check: Use
nginx -t xxx.conf
to check configuration file syntax errors. If there is any error, modify and re-run the command. Then executesystemctl reload nginx
orservice nginx reload
to restart the Nginx service.Local testing: Use
curl 127.0.0.1:8088
on the server to test whether it is accessible. If you can access it, it means that the Nginx configuration is basically correct, and the problem may be in the external network configuration of the server or the firewall.-
Network configuration and firewall:
- Firewall: Confirm whether Ubuntu firewall (such as UFW) allows access to port 8088. You can use
sudo ufw allow 8088
to allow access, and thensudo ufw status
to view the status. - Alibaba Cloud Security Group: Check the Alibaba Cloud Security Group rules carefully again to ensure that the entry direction rules for port 8088 are correctly configured and allow your client IP address to access.
- Firewall: Confirm whether Ubuntu firewall (such as UFW) allows access to port 8088. You can use
php-fpm socket path: Ensure that the
/var/run/php/php7.4-fpm.sock
path is correct and is consistent with the configuration of php-fpm. Check whether the php-fpm service is running normally.Permissions issue: Check whether the Nginx user (www-data) has read execution permissions for the project directory and its files.
ThinkPHP 6 routing configuration: Check whether the routing configuration of the ThinkPHP 6 project is correct to ensure that the request can be processed correctly.
Log check: Check Nginx error log
/var/log/nginx/error.log
nginx/error.log to see if there is more detailed error information.
If the above steps still fail to resolve the problem, please provide the following information for further troubleshooting:
- Server operating system version
- Nginx version
- PHP version
- php-fpm configuration
- ThinkPHP version 6
- Complete Nginx error log content
By systematically examining each of the above aspects, you should be able to find and resolve the root cause of the 404 error.
The above is the detailed content of How to fix 404 errors encountered when deploying a ThinkPHP 6 project on port 8088 via Nginx on Ubuntu?. For more information, please follow other related articles on the PHP Chinese website!

APHPDependencyInjectionContainerisatoolthatmanagesclassdependencies,enhancingcodemodularity,testability,andmaintainability.Itactsasacentralhubforcreatingandinjectingdependencies,thusreducingtightcouplingandeasingunittesting.

Select DependencyInjection (DI) for large applications, ServiceLocator is suitable for small projects or prototypes. 1) DI improves the testability and modularity of the code through constructor injection. 2) ServiceLocator obtains services through center registration, which is convenient but may lead to an increase in code coupling.

PHPapplicationscanbeoptimizedforspeedandefficiencyby:1)enablingopcacheinphp.ini,2)usingpreparedstatementswithPDOfordatabasequeries,3)replacingloopswitharray_filterandarray_mapfordataprocessing,4)configuringNginxasareverseproxy,5)implementingcachingwi

PHPemailvalidationinvolvesthreesteps:1)Formatvalidationusingregularexpressionstochecktheemailformat;2)DNSvalidationtoensurethedomainhasavalidMXrecord;3)SMTPvalidation,themostthoroughmethod,whichchecksifthemailboxexistsbyconnectingtotheSMTPserver.Impl

TomakePHPapplicationsfaster,followthesesteps:1)UseOpcodeCachinglikeOPcachetostoreprecompiledscriptbytecode.2)MinimizeDatabaseQueriesbyusingquerycachingandefficientindexing.3)LeveragePHP7 Featuresforbettercodeefficiency.4)ImplementCachingStrategiessuc

ToimprovePHPapplicationspeed,followthesesteps:1)EnableopcodecachingwithAPCutoreducescriptexecutiontime.2)ImplementdatabasequerycachingusingPDOtominimizedatabasehits.3)UseHTTP/2tomultiplexrequestsandreduceconnectionoverhead.4)Limitsessionusagebyclosin

Dependency injection (DI) significantly improves the testability of PHP code by explicitly transitive dependencies. 1) DI decoupling classes and specific implementations make testing and maintenance more flexible. 2) Among the three types, the constructor injects explicit expression dependencies to keep the state consistent. 3) Use DI containers to manage complex dependencies to improve code quality and development efficiency.

DatabasequeryoptimizationinPHPinvolvesseveralstrategiestoenhanceperformance.1)Selectonlynecessarycolumnstoreducedatatransfer.2)Useindexingtospeedupdataretrieval.3)Implementquerycachingtostoreresultsoffrequentqueries.4)Utilizepreparedstatementsforeffi


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

Dreamweaver Mac version
Visual web development tools

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

WebStorm Mac version
Useful JavaScript development tools

Zend Studio 13.0.1
Powerful PHP integrated development environment
