I had my server configured following the perfect server guide for Ubuntu and NGINX her: https://www.howtoforge.com/tutorial/perfect-server-ubuntu-18-04-nginx-bind-dovecot-and-ispconfig-3/ Updated to Ubuntu 22.04.5 Everything was fine, however I have a dev working on deploying a laravel mobile application. This is not my forte whatsoever - they wanted me to use CPanel, and I insisted using my existing setup should not be a problem. They had me enable root permissions for the public folder, /var/www/clients/client5/web7/web/public , and install composer into the directory - all good In my impatience, I looked at https://digitalocean.com/community/...omnfiguere-laravel-with-nginx-on-ubuntu-20-04 I went ahead and installed the php modules, and attempted to follow the next step of creating a database for the application. The creation itself was fine, however creating the user with 'user'@%' IDENTIFIED WITH 'password' was not working. I went ahead and used CREATE USER 'user1'@localhost IDENTIFIED BY 'password' This seemed to work, however I still had issues giving the user permission over the database. - I skipped ahead (Product of my downfall) and ran sudo chown -R www-data.www-data /var/www/clients/client5/web7/web (Rather than database, as indicated - I know) From there, i ran sudo nano /etc/nginx/sites-available/web7 - now the root here was displayed as /var/www/site-name/public/ - I changed it to /var/www/clients/client5/web7/web/public I attempted to run nginx -t , where I encountered SSL Errors - again with systemctl reload nginx It was about this point I tried accessing my server.web.com:8080, to discover it would not load - along with my hosted sites. I went and changed the root on /etc/nginx/sites-available/web7 back, to no avail. Looking into the issue, someone on stackoverflow had recommended uninstalling and reinstalling NGINX to resolve the issue. so i ran apt-get purge nginx nginx-common nginx-full and apt-get install nginx This did resolve the SSL issue, allowing the server to start - however it did not fix the page load. The /etc/nginx/sites-available/ folder is now empty, save for default, so I'm guessing this is where the issue lies. I then forced an update for ISPconfig, which again provided no results. I can still access everything via SFTP - so i know it's there. I'm just not positive on what I need to do to restore web access.
All you need to configure a website for Laravel app can de done easily right from within ISPConfig. No need to edit any config files manually or change permissions of folders. You did a lot of things to forcefully destroy your server, starting with changing permissions of a website to editing vhost files and then removing vhosts incl. all config that ISPConfig needs and which can not be restored automatically doing an ISPConfig update. Also you should not have created a database manually. You have to undo all these steps now to fix it, especially deleting this messed up website from within ISPConfig to be able to create a new working one. Do you have a backup of your server that you can restore? If you do not have a backup of the system, check folder /var/backup, it might contain a folder named ispconfig which then contains at least a backup of the /etc from where you can restore the nginx config files you deleted. After restoring the Nginx config files, you should be able to log into ISPConfig where you can delete that website and create it again. Then manually delete that mysql database you created for the site and create one in ISPConfig instead. When you fixed the system until that stage, then we can help you with the steps for the final preparation of that site for Laravel.
I restored from /var/backup, however the file date was from this morning - I have a feeling this was created after the fact. I now have 000-apps.vhost and 999-acme.vhosts , along with default - no access to ISPconfig. I'm assuming I've just fully destroyed the server at this point. In theory, I should still be able to backup the sites through SFTP, backup the DB manually, then wipe the server and at least restore the sites, right?
The server is not fully destroyed. But we have to try to recreate the ispconfig vhost manually now to get the interface up again. Whats in /etc/nginx/sites-available/ now and whats in /etc/nginx/sites-enabled/ ?
in sites-enabled : 000-apps.vhost , 999-acme.vhost, default in sites-available : acme.vhost , apps.vhost , default
If you are in a hurry to get server back working, consider paying for business support to do the job. https://www.ispconfig.org/support/
Create a new file: /etc/nginx/sites-available/ispconfig.vhost with this content: Code: server { listen 8080 ssl; listen [::]:8080 ssl ipv6only=on; ssl_protocols TLSv1.2; ssl_certificate /usr/local/ispconfig/interface/ssl/ispserver.crt; ssl_certificate_key /usr/local/ispconfig/interface/ssl/ispserver.key; ssl_ciphers 'ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:ECDHE-ECDSA-DES-CBC3-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA:!DSS'; ssl_prefer_server_ciphers on; # redirect to https if accessed with http error_page 497 https://$host:8080$request_uri; server_name _; root /usr/local/ispconfig/interface/web/; client_max_body_size 20M; location / { index index.php index.html; } # serve static files directly location ~* ^.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt)$ { access_log off; } location ~ \.php$ { try_files $uri =404; include /etc/nginx/fastcgi_params; fastcgi_pass unix:/var/lib/php7.3-fpm/ispconfig.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; #fastcgi_param PATH_INFO $fastcgi_script_name; fastcgi_buffer_size 128k; fastcgi_buffers 256 4k; fastcgi_busy_buffers_size 256k; fastcgi_temp_file_write_size 256k; fastcgi_read_timeout 1200; fastcgi_param HTTP_PROXY ""; } location ~ /\. { deny all; } # location /phpmyadmin { # root /usr/share/; # index index.php index.html index.htm; # location ~ ^/phpmyadmin/(.+\.php)$ { # try_files $uri =404; # root /usr/share/; # include /etc/nginx/fastcgi_params; # fastcgi_pass unix:/var/lib/php7.3-fpm/ispconfig.sock; # fastcgi_param HTTPS on; # fastcgi_index index.php; # fastcgi_param SCRIPT_FILENAME $request_filename; # } # location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ { # root /usr/share/; # } # } # location /phpMyAdmin { # rewrite ^/* /phpmyadmin last; # } # # location /squirrelmail { # root /usr/share/; # index index.php index.html index.htm; # location ~ ^/squirrelmail/(.+\.php)$ { # try_files $uri =404; # root /usr/share/; # include /etc/nginx/fastcgi_params; # fastcgi_pass unix:/var/lib/php7.3-fpm/ispconfig.sock; # fastcgi_param HTTPS on; # fastcgi_index index.php; # fastcgi_param SCRIPT_FILENAME $request_filename; # } # location ~* ^/squirrelmail/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ { # root /usr/share/; # } # } # location /webmail { # rewrite ^/* /squirrelmail last; # } } Then run: Code: cd /etc/nginx/sites-enabled/ ln -s /etc/nginx/sites-available/ispconfig.vhost 000-ispconfig.vhost service nginx restart then you can try to login to ISPConfig. If this works, delete that site in ISPconfig. Afterwards choose Tools > resync in ISPConfig and let it resync the websites.
I followed your advice from here: https://forum.howtoforge.com/threads/nginx-vhost-lost-how-to-rebuild-via-ssh.91956/ Running it only for the missing file. It worked, I got into the panel, removed the site and resynced. My SSL certs need to be fixed, but that’s a lot less work than a wipe and rebuild. Thanks!! So now, what’s the proper way to go about deploying the Laravel application through the panel?
1) Create a database and database user in ISPConfig. 2) Create a website in ISPConfig, enable PHP for that website. Then go to the options tab and change the document root of the site. E.g. if your laravel app wants to use public/html, then you enter this in the Nginx directives field on the options tab of the website: Code: ##subroot public/html ## 3) Now create an SSH user for the site, log in with that SSH user, and start installing your Laravel app inside the site's web folder. You likely want to choose an SSH user without chroot, as this will make things easier and allow that user to use the globally installed composer. There is no need to alter any folder owners etc. as the SSH user is already the same user that runs PHP in that site.
Alright, the Dev is fixated on the concept they need to change file permissions, so I’m stuck doing it myself. Files are uploaded. According to them, composer has been done. Contents of the public folder are: Assets (folder) Storage (folder) .htaccess favicon.ico index.php robots.txt Everything else is in the main web folder Setting the NGINX directive to Code: ##subroot public/ ## At first just loaded String(3) “sss” After deleting the directive and then saving it again, it now redirects to example.com/login Which shows a 404. What am I missing?
That's because the dev does not know that there are Hosting Control Panels like ISPConfig which set correct permissions on their own. The PHP process runs under the same user that you use to upload, so there are no permissions that need to be changed, especially not to ww-data as websites do not run as www-data. That's not related to ISPConfig and only the person who developed that application can help you there and tell you what "sss" means in his app. If its a Laravel app, you need the subroot, otherwise the web server will load content from web folder and not web/public/ folder.
Looking into it, the issue was the line Code: try_files $uri $uri/ =404; in the site .vhost file Solution was to change the NGINX directive within ISPConfig to Code: location / { root {DOCROOT}/public; try_files $uri public/$uri/ /public/index.php?$query_string; } Loads properly now