Error 503 with httpd localhost server on Fedora 35 - linux

So I switched to Fedora and wanted to install LAMP on it. So I followed this article: https://computingforgeeks.com/how-to-install-lamp-stack-on-fedora/. Everything has been installed successfully. Afterward, I wanted to change the default root directory. In order to achieve it, I edited /etc/httpd/conf/httpd.conf and have set:
DocumentRoot "/home/muq/Localhost"
User muq
Group muq
<Directory "/home/muq/Localhost">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
And now I am getting the error: 503 Service Unavailable.
If I change User and Group to default (apache) the error I get is: 403 Forbidden.
Previously I was doing the same thing with Apache on PopOS and it was working fine.
Thank you all in advance!

Did you follow the step in the article which says to set SELinux to permissive? My guess is that you didn't, and that's what's happening: SELinux is preventing user home directory files from being served out by the web server.
You could just follow the advice in the article and just turn it off. But, I strongly recommend that you don't. The thing it's protecting you from here is a reasonable one — a misconfiguration could otherwise very easily expose personal user files to the internet. And here's the key thing: fixing this is really easy! At least as easy as the instructions for disabling SELinux in the article! You just need to do:
sudo chcon -R -t httpd_sys_content_t /home/muq/Localhost
to label that directory as one from which you want to serve httpd content. And that should do it — and still give you all the other protection of SELinux.
(You could also consider a location like /srv/www or /var/www/html as your web root, keeping your home directory out of the whole thing. These are parts of the filesystem designated for that, and to me as a former sysadmin seems cleaner. But the choice is yours.)

Related

After installing Pimcore demo i cannot enter /admin

So i'm trying to install Pimcore to my local environment.
I followed the steps at: https://pimcore.com/docs/pimcore/current/Development_Documentation/Getting_Started/Installation.html
The install wen't fine with just one error about running a sql: * An exception occurred while executing 'DROP FUNCTION IF EXISTS PLUGIN_CMF_COLLECT_ASSET_SEGMENT_ASSIGNMENTS;
I did fix that by logging in to mysql as root and executed the query described from this: https://github.com/pimcore/pimcore/issues/4526
So, all installed i went to my browser and localhost. The Pimcore demo page loads, but with no images. And i'm not able to enter /admin. the page doesn't excist.
I have googled around for hours and read about filepermissions, so i set the pimcore project folder to rw for all users.
When i check the project folder i have no "web" folder or "admin" folder..
So where should i look next?
Should there be an admin folder in my project root?
So the problem seemed to be in httpd.conf
user _www (had to be my personal account)
group _www (had to be staff)
Also i have missed the AllowOverride All setting.
I had the same problem as a result of being sloppy..
Running on FreeBSD 13.1 with Apache 2.4 and PHP 8.1 with Composer 2, I made several attempts to install both the demo and the skeleton with the exact same outcome as this question poses.
The reason it failed was that I ran the installation as root. SU to the web service user - probably www - and try again.
Edit: I'd like to add that the installation instructions for Pimcore skips a crucial step for the installation. To a salty PHP developer, this is probably obvious, but for anyone else - after you run "composer create-project pimcore/demo my-project", enter the "my-project" folder (or whatever you chose to name it) and run "composer install".
One more important thing, that is missing in pimcore installation guide.
It looks like the installation doesn't create the .htaccess file in
your-project/public/.htaccess
I have created .htaccess according to:
https://pimcore.com/docs/pimcore/current/Development_Documentation/Installation_and_Upgrade/System_Setup_and_Hosting/Apache_Configuration.html
Make sure that Allowoverride All is set for your the DocumentRoot, in your VHOSTS settings - it is needed for .htaccess support.
<Directory /var/www/<your-domain>/public>
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
*public is public directory in pimcore installation folder.
And now it is working well.

Symlink to raspberry pi webroot breaks

I have my raspberry pi setup as an internal web server. I have an external hard drive connected to the pi and mounted correctly.
I then symlink two folders from the hard drive to the web root on the pi, one is /Movies, and the other is /Series.
Initially this all works fine, as in if I hit http://192.168.1.17/Movies I get a list of all the files, I then click one and it starts playing no problem. However, after leaving it for a while and coming back, I can still get to the file directory in /Movies or /Series, but when I click a file, the web browser cannot open it.
I have no idea what's going on, it seems weird that I can still access the file directory, but playing a file doesn't work?
Any thoughts or help appreciated.
Are you using an apache server?
If so Symlinking is not a good idea.
An alternative which is more secure and may fix your problem is to install Userdir
sudo a2enmod userdir
Then you need to make a directory in home
mkdir public_html
Restart Apache
sudo service apache2 restart
If you want to change the home directory apache points to you can do so in /etc/apache2/mods-enabled/userdir.conf .Then change the <Directory /home/*/public_html> to the directory you want.
To access you're server simply enter ip_of_Rpi/~pi_username. e.g 192.168.0.100/~pi
more details here: http://ubuntuserverguide.com/2012/10/how-to-enable-and-configure-apache2-userdir-module-in-ubuntu-server-12-04.html
If you are using Apache web server, you can use mod_alias to map some directory in a URL path like this
Alias /mnt/external_disk01/movies /Movies
Alias /mnt/external_disk02/series /Series
Before use alias, make sure it is activated.
To activate:
a2enmod alias
more info in http://httpd.apache.org/docs/2.2/mod/mod_alias.html

403 Forbidden trying to access folder on browser

I have a folder in ~/Documents/WebD/ named Tarea which have a public_html folder inside, to access it I have tried creating a virtual host in a thousand ways but it didn't work, now I'm trying to get there creating a Symlink from tarea to /var/www/html/tarea, and accessing via localhost/tarea/public_html but y get
Forbidden
You don't have permission to access /tarea on this server.
Apache/2.2.15 (CentOS) Server at localhost Port 80
I tried a lot of different ways named on forums, changing httpd.conf, give permissions to apache, etc, but non of them worked
Any suggestion?
It could be SELinux preventing Apache from accessing those files. I would try switching SELinux into permissive mode and seeing if your permissions open up. You can read more about SELinux and Apache here.
To put SELinux into permissive mode, do:
echo 0 > /selinux/enforce
To put SELinux back into enforcing mode, do:
echo 1 > /selinux/enforce
Hope you have already checked Persmissions for /tarea folder. The User which is running the Apache server should have read/write permissions on the specific directories.

installations of cake php website in linux server

I've developed a website in cakephp and it is running successfully in localhost of my windows operating system.Now i need to make it run on Linus static IP server.I also need to know that what are all the softwares needed to install and implementation procedures to upload it and where to upload it.Any help would be greatly appreciate.
You have to research a bit more on the net, there's plenty of answers guiding you how to do it. Stackoverflow is more pertaining to specific coding questions. I personally prefer using amazon ec2 for uploading my cakephp applications.
There's lots of tutorials on how to set up a free tier linux server instance on ec2 all over the net. Here's a great one:
http://www.comtechies.com/2013/01/how-to-host-dynamic-php-website-on.html
Once you have your instance set up, this is what you have to do:
In apache your public folder will be /var/www/ so anything you put in there will be directly accessible to people by URL. Use putty to connect to your server.
sudo service apache2 stop
This will stop your apache server for security reasons while you upload etc.
Copy your project to /var/www/cakephp such that your webroot lies in /var/www/cakephp/app/webroot.
type the following to describe location of cakePHP
nano /var/www/cakePHP/app/webroot/index.php
Go to the line starting with define('CAKE_CORE_INCLUDE_PATH' and make it define('CAKE_CORE_INCLUDE_PATH', DS . 'var' . DS . 'www' . DS . cakephp . DS . lib') - assuming cakephp/lib is to be found in /var/www/cakephp/lib
Next, set the new document root:
sudo nano /etc/apache2/sites-available/default
and wherever you see /var/www change it to /var/www/cakephp/app/webroot.
Also, in the change allowoverride none to allowoverride all the first two times they occur from the top of the document.
To allow apache to access your files and write to cache, execute the following commands:
sudo chown www-data:www-data /var/www/myproject -R
sudo chmod 777 /var/www/myproject/tmp -R
To allow CSS to be applied properly:
sudo a2enmod rewrite
Restart apache:
sudo service apache2 start
Now everything should be working according to plan. If you have any further questions do hit me back!

WordPress can't install themes

I can't workout how to solve this problem so wordpress would let me upload themes.
I have a fresh copy of Fedora 17 installed on my dev machine.
I then installed mysql using: yum install mysql mysql-server. Next I installed WordPress which also installs apache and php: yum install wordpress
I can go to http://localhost/wordpress and see WordPress working. But when I try tried to install my theme it asked for ftp credentials. I then updated the wp-config.php file and set the FS_METHOD constant to direct. Now it doesn't ask for ftp credentials but it gives me this error:
Could not create directory. /usr/share/wordpress/wp-content/themes/my-theme-name/
httpd service is running under 'apache' user and 'apache' group. The /usr/share/wordpress/ directory is recursively own by 'apache' user and 'apache' group too. I've even set the permissions to 777 (also recursively) and even then I keep getting the same error as above.
How can I solve this problem?
Fedoras SELinux configuration is most probably blocking the attempts of the webserver to write to the disk. To change the settings for your wordpress folder you can run this command (as root):
chcon -R -t httpd_sys_content_rw_t /usr/share/wordpress/wp-content
No need to do chmod 777 to the whole folder, this is a huge security risk. Of course this is for direct filesystem access, you have to disable the ftp access. For ftp access you will have to look up the right SELinux context.
You got the check these lines in your Wp-config.php (aproximatively line 105) :
define('FTP_USER', 'usr');
define('FTP_PASS', 'P#ssw0rd');
define('FTP_HOST', 'url');
You process of web server is running on apache but Wordpress will use the account define in the wp-config.php . So you got to set the group of your user to get access to these files.
Setting permissions 777 is not a solution, you got to care about it.

Resources