Using LAMP stack for development

BaTouSai

Well-Known Member
Joined
Apr 14, 2010
Messages
403
Reaction score
1
Hi I have always used xampp on windows for development purposes and just copied my files to the htdocs folder and all was well.

Now I have decided to start learning linux and have installed Fedora 23 on my notebook. I have installed apache, mariaDB and php all is well and configured but now the issue I have is the var/www/html directory.

Is this the same directory as xampp's htdocs folder? I have no access to this folder to add and remove files and I don't see the www-data group.

What is the correct way to set up a linux machine for development purposes, php and mysql just local don't want it accessible from the outside
 
You can modify where files are saved by changing the DocumentRoot directive in httpd.conf. I have no idea where Fedora puts this file, or how they lay out their apache configuration, but if you do the following you can find out:

Code:
grep -ri documentroot /etc/httpd/*

Somewhere you should see:

DocumentRoot /var/www/html

Make a html directory in your home directory, and then change DocumentRoot to that path, i.e. something like

DocumentRoot /home/batousai/html

Restart apache and you're good to go.
 
all of these will be terminal commands.

To see the list of groups on the system:
Code:
cat /etc/group

There, you can check whether either of www-data, apache or http is the apache group. Thereafter,

Code:
ls -l /var/www/

to see the ownership of the html folder. It should look something like this:

Code:
drwxr-xr-x 36 root   root    4096 Feb  6 11:58 html/

Suppose you've made a group called 'dev' (with the command 'sudo groupadd dev'). You can change group ownership of html/ to dev like so...

Code:
sudo chown :dev /var/www/html

...then give that group write privileges...

Code:
sudo chmod g+w /var/www/html

...add that group into your user's 'profile'...

Code:
sudo usermod -a -G dev batousai

...and you're good to go for writing to that folder. This will need a restart of the terminal window you're using for the changes to reflect. Simply run
Code:
touch /var/www/html/test
to see if the group privileges work.

As for mysql being local, if you haven't touched /etc/my.cnf, mariadb should only be accessible on localhost. You could force it tho by adding the following under the [mysqld] section:

Code:
bind-address=127.0.0.1

Then again, you'll need to permit access from outside computers in anycase when setting up users in mysql.

Additionally, your firewall (I'm nearly 100% its running firewall-cmd) will initially block port 3306, so outsiders won't get in even if you allow bind-address in my.cnf or users in mysql. Have a look over here if you'd want to allow mysql access outside of locahost one day, but it goes something like this:

Code:
sudo firewall-cmd --permanent --add-service=mysql --zone=public

where you can swap out the --add-service bit with '--add-port=3306/tcp' (assuming its running on 3306) and --zone=public with whichever zone you'd like (e.g. 192.168 is the home zone, and all others are public; you then have the option of allowing 3306 only to the 192.168's in home)

EDIT: one last bit, SELinux. If ever file uploads fail even if the apache user has ownership over the folder, chances are SELinux is enabled. Run the chcon command to allow the user who's running apache to upload files.
But be careful, because people can then upload php files (or pl's.... basically any script file) into your webserving directory wreaking havoc once they visit that uploaded file. So either edit .htaccess within the folder containing your uploads to disallow php, or have your scripts deny php filetype uploads
 
Last edited:
Top
Sign up to the MyBroadband newsletter
X