A
A
Alexander2019-09-12 22:27:25
linux
Alexander, 2019-09-12 22:27:25

How can I set permissions for Apache on Ubuntu (Linux)?

We were given the task (at the educational institution where I study) to set up a local server on Ubuntu (standard Apache + MySQL + PHP stack). So far, I've dealt with these three technologies only on Windows, which was quite simple and workable. But things are not so simple with Linux. I was able to compile and install Apache following the instructions on httpd.apache.org, but there was a permissions issue.
All Apache folders are owned by root, which led to the fact that Apache cannot even write its own logs (respectively, it cannot start). I found out what commands can help me change permissions and permissions, but I do not quite understand how I should apply them to Apache directories (I started getting acquainted with Linux relatively recently). Should I create a group for the apache user, the user of the same name, and give the group full access to all Apache directories (removing root rights to these directories) or only to some (retaining root rights to some of these directories)? Do I understand correctly that if I give the apache group access to a directory, then I myself will not be able to create, modify or delete anything in these directories? So I need to add myself to the apache group and then I will get access to these directories?
I'd love to know how Apache would be configured in the real world, but I can't find any good information about it.

Answer the question

In order to leave comments, you need to log in

6 answer(s)
X
xmoonlight, 2019-09-13
@Caius

Apache HTTPD build instructions
install-bindist.sh.in and here

HURRAH! :)
echo "Ready."
echo " +--------------------------------------------------------+"
echo " | You now have successfully installed the Apache @[email protected] |"
echo " | HTTP server. To verify that Apache actually works |"
echo " | correctly you should first check the (initially |"
echo " | created or preserved) configuration files: |"
echo " | |"
echo " | $SR/conf/httpd.conf"
echo " | |"
echo " | You should then be able to immediately fire up |"
echo " | Apache the first time by running: |"
echo " | |"
echo " | $SR/bin/apachectl start "
echo " | |"
echo " | Thanks for using Apache. The Apache Group |"
echo " | www.apache.org |"
echo " +--------------------------------------------------------+"
echo " "

PS: A set of assembly documentation throughout!

M
moropsk, 2019-09-12
@moropsk

but I can't find any good information about it.

I do not believe.
https://www.8host.com/blog/nastrojka-apache-v-ubun...

C
CityCat4, 2019-09-13
@CityCat4

I was able to follow the instructions on httpd.apache.org to compile and install Apache,

You don't have to do that. Such things are for those who understand what they are doing.
You - to do everything only through the package manager - he will put everything himself and he will create all the folders with the necessary rights. Not, of course, your work can be brought to mind - persistent reading of mana about how UNIX works, how rights are assigned in it, etc. - it's also cool, but long.

T
Talyan, 2019-09-12
@flapflapjack

When installing Apache in a regular way via apt-get, Apache itself creates the desired group and user.
And he can write logs.
How did you set?
Try to do

sudo apt-get purge apache2 && sudo apt-get autoremove
,
then put the server on any article on request from Google "LAMP Server" (Linux + apache + php + mysql).

D
Dmitry, 2019-09-12
@slo_nik

Good evening.
Here are a couple of my questions / answers, everything is described in them
How to display text from a file? // install and configure apache2
Access denied to the console controller, how to solve? // access rights, but most likely you won't need
Virtual host configuration example, change the paths to your own.

<VirtualHost *:80>
  ServerAdmin [email protected]

  ServerName localhost

  DocumentRoot /home/slonik/localhost/www
  <Directory />
    Options FollowSymLinks
    AllowOverride All
  </Directory>
  <Directory /home/slonik/localhost/www/>
    Options +Indexes +FollowSymLinks -MultiViews
    AllowOverride All
    Order allow,deny
    allow from all
    Require all granted
  </Directory>

  ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
  <Directory "/usr/lib/cgi-bin">
    AllowOverride None
    Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
    Order allow,deny
    Allow from all
  </Directory>

  ErrorLog /home/slonik/localhost/error.log
  #AccessLog /home/slonik/localhost/access.log

  # Possible values include: debug, info, notice, warn, error, crit,
  # alert, emerg.
  LogLevel warn

  CustomLog ${APACHE_LOG_DIR}/access.log combined

    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory>

</VirtualHost>

V
Victor Taran, 2019-09-13
@shambler81

braynycp - set by 1 script, web muzzle is free, has a lot of not very convenient.
bitrix vm - excellent speed is set only on centos in 1 click, has a console interface (press 1 if press 2 if, enter the domain)
vestacp - also free, too, web muzzle is also set in 1 click
ispconig3 - set by manu handles.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question