I have got a project to work on that is based on laravel. I have unzipped the folder in my
/home/testsite/public folder and replaced the httpd.conf file which I have received.
Ran these two commands
chown -R username:group /home/testsite/public
chmod -R 777 /home/testsite/public/app/storage
But when I try to access localhost it shows default apache page, for other route url it shows 404 and it shows Forbidden when I try to access localhost/server.php
I have pasted my httpd.conf file here: http://pastebin.com/WLpFN7Sr
From your httpd.conf I see that your apache user is apache and its group is also apache. You can see that from these entries in the httpd.conf:
User apache
Group apache
Try this from within your project directory:
chown -R :apache .
I would also suggest that you not put virtual host or directory definitions inside of your httpd.conf. Most distributions have a good place already for you to put them, where you can store a single vhost inside of a single file. This makes it much easier when you want to enable one, disable another and general management becomes easier.
For instance, on ubuntu, I store all of my vhosts as separate files inside of:
/etc/apache2/sites-available/
Related
I'm testing Laravel on a Arch Linux ARM, to which I'm connecting through SSH.
Going throughout the Laravel's docs
I created a new blog. So far so good.
The Docs mention the following:
After installing Laravel, you should configure your web server's document / web root to be the public directory. The index.php in this directory serves as the front controller for all HTTP requests entering your application.
After installing Laravel, you may need to configure some permissions. Directories within the storage and the bootstrap/cache directories should be writable by your web server or Laravel will not run. If you are using the Homestead virtual machine, these permissions should already be set.
This post says that 'writable by my webserver' means that it must be writable by the user/group which is running apache. I was able to get the group that apache is running from using
ps -ef | grep httpd | grep -v grep.
The user turned out to be http. I checked both /etc/group and /etc/password and the user and group exist with the same name. So I changed the permissions of both bootstrap/cache and the directories inside storage with
sudo chown http bootstrap/cache/
sudo chown -R http storage
sudo chgrp http bootstrap/cache/
sudo chgrp -R http storage
And gave writting permissions to the http group, I realize that this is overkill, since permissions are additive but I still had to try.
sudo chmod g+w bootstrap/cache/
sudo chmod -R g+w storage/
I've read plenty of threads and most of them mention Virtual Hosts so I thought I might as well attempt that, I went throughout the Arch Apache wiki
If you want to have more than one host, uncomment the following line in /etc/httpd/conf/httpd.conf:
Include conf/extra/httpd-vhosts.conf
To test the virtual hosts on your local machine, add the virtual names to your /etc/hosts file:
127.0.0.1 domainname1.dom
<VirtualHost *:80>
DocumentRoot "/srv/httpd/blog/public"
ServerName www.mytest.com
</VirtualHost>
And on my local Ubuntu computer I have <my_Linux_ARM_IP> www.mytest.com on /etc/hosts/
So, whenever I type www.mytest.com on my local computer I get.
I changed the DocumentRoot to test a simple and pure index.html file and it rendered just fine, so I figure the issue is with Laravel.
I was able to manage all this on a local WAMP system beforehand, write the vhosts, change the hosts file so that localhost points to the vhost. And blog rendered just fine.
So it's not Laravel but Apache and the LAN connection? I'm not sure where to go next. Should I read more Apache docs? Should I read more Laravel docs? Should I read more networking stuff? If so, could someone provide some good resources?
Thank you.
Thank you #langbox.
I just followed the steps of this wiki, I chose to use libphp and now it renders correctly.
I have LAMP server
Server version: Apache/2.4.29 (Ubuntu)
PHP: PHP 7.2.5-0ubuntu0.18.04.1
I need to give an php SQLITE3 access to db outside www/html folder.
Right now my filesystem looks this way.
/root
./database
user.db
/var
./www
./html
index.html
reg.php
user.db must be located in /root/database, so just putting it inside var/www/html isn't solution for me.
So I need to give access to this folder for Apache or php.
I found some information here https://httpd.apache.org/docs/2.4/urlmapping.html, but didn't get how this works and where I need to put this?
The problem here is Linux permissions, not URL mapping, as PHP is running in the server, in the backend.
If you run PHP as an Apache module, (mod_php or something like that), it will run with the Apache user and group (usually www-data:www-data or nobody:nogroup, it depends of the LAMP configuration).
So, you should give permissions and change ownership to the user.db file and its tree, something like:
chmod o+x /root
chmod o+x /root/database
chown www-data:www-data /root/database/user.db
You can read more about permissions here.
I cannot seem to allow permissions in vagrant. I am attempting to run importbuddy.php in order to migrate a WordPress instance. I get the following error.
file_put_contents(/path/): failed to open stream: Permission denied
I have setup permissions to 777 on the www directory, but that changes nothing. Any idea on how to fix this?
While recursively setting folder and file permissions to 777 should fix your problem (instructions for doing so here), the root of this is probably an issue with the ownership of the files and folders.
The owner of shared folders is usually 'vagrant' but the server itself (if you're using Ubuntu) runs as user and group 'www-data'. You can view the user/group of your files by sshing into your VM (vagrant ssh), navigating to the directory in question and entering ls -l in your console.
If you're running apache, then you can update the user to 'vagrant' by editing the following file (/etc/apache2/envvars) like below:
Find this section
export APACHE_RUN_USER=www-data
export APACHE_RUN_GROUP=www-data
And change it to
export APACHE_RUN_USER=vagrant
export APACHE_RUN_GROUP=vagrant
Afterward just be sure to restart apache (with this command sudo service apache2 restart) and the file permission errors should be fixed
I'm a newbie in Linux, just installed ubuntu 14.04 and wanted to install WAMP (MAMP), I followed a youtube tutorial to install php5, apache2, mysql and phpmyadmin. Installed successfully both http://localhost and http://localhost/phpmyadmin works fine logged in successfully.
now I wanted to add some files and folders to apache www folder which is located at /var/www but cant create files or folders. I'm a Windows user where I usually keep all my PHP work in www folder.
I would like to know if there is a way to use any-other folder as www folder or how to create folders and files in that www folder. I reckon its permission issues, since being a newbie don't know how to fix that.. please help
Regards
Ubuntu 14.04 runs apache as user www-data, you can change to this user using the command in terminal (shell)
sudo su
This will make you root and have access to /var/www directory, and you will be able to create files and directories. Say you had a directory of images containing img1.jpg, img2.jpg, etc. in say /home/user1/images
as root you could
sudo su <- change to the document folder
cd /var/www <- change to the document folder
cp /home/user1/images/ . <- copy what you need to copy
chown -r www-data images/ <- give the web server read/write permission to the folder / files
which will let you do access the images via a browser via the url
http://localhost/images/img1.jpg
The reason is that apache runs under different user (given your distro most likely www-data), while /var/www belongs either to the user or root.
So if you want to allow apache to write somewhere you have to give it permissions.
Since it is not good practice to give apache full permission to your disk, usually you would have a special directory where it can upload data.
For example creating directory
/var/www/myProject/uploaded
and then giving permission to all to write there
chmod 777 /var/www/myProject/uploaded
Alternatively you can change the owner/group with chown.
I have installed macports and updated my path:
via docs:
http://guide.macports.org/#installing.shell.postflight
but now if I test any of the sites in my Sites folder, I get a 404.
so for instance if I go to localhost/~carey/test.php which is just a php_info, I get a 404
If I go to:
localhost/
I get the It Works! page
Am I missing a step to configure Macports to run apache from my Sites directory?
If I run $env from the command line I get:
TERM_PROGRAM=Apple_Terminal
SHELL=/bin/bash
TERM=xterm-256color
TMPDIR=/var/folders/rs/943jh19j31j3ld55yxqgf2mm0000gn/T/
Apple_PubSub_Socket_Render=/tmp/launch-NehzDd/Render
TERM_PROGRAM_VERSION=326
TERM_SESSION_ID=A329EAC2-AE9F-4460-BB1B-B35981BAE0ED
USER=carey
SSH_AUTH_SOCK=/tmp/launch-CgUaVv/Listeners
__CF_USER_TEXT_ENCODING=0x1F5:0:0
PATH=/opt/local/bin:/opt/local/sbin:/opt/local/bin:/opt/local/sbin:/opt/local/bin:/opt/local/sbin:/opt/local/bin:/opt/local/sbin:/opt/local/bin:/opt/local/sbin:/usr/local/mysql/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin
__CHECKFIX1436934=1
PWD=/Users/carey
LANG=en_US.UTF-8
SHLVL=1
HOME=/Users/carey
LOGNAME=carey
SECURITYSESSIONID=186b0
_=/usr/bin/env
and I can run any macport install, but I cannot configure the terminal to connect to my localhost in the browser.
So I think I have macports installed correctly, but I dont know how to make it run out of the /opt directory.
I also think this is relative to establishing the env variables, so apache knows to look to the /opt dir, but I don't know how to change it.
I am running Mavericks.
UPDATE
Following the docs recommended by eborisch here:
https://trac.macports.org/wiki/howto/MAMP
I have been able to setup the localhost directory, but still an issue.
Since I have multiple users on the machine, I had to comment out this line in httpd.conf:
Include conf/extra/httpd-userdir.conf
and added this to the httpd-userdir.conf file:
#
# Include user configurations
#
Include /private/etc/apache2/users/*.conf
which connects my Sites folder to the localhost.
I also needed to add this to the httpd.conf file to parse php files as php:
AddType application/x-httpd-php .php
Now, I have a file in my Sites dir called test.php, which has <?php phpinfo() ?>
and if I run localhost/~carey/test.php in the browser it works. phpinfo() returns that I am running php5.5.10 out of the /opt/ dir. So, all seems well. The problem is if I try to run any sites from folders in this directory. It just displays the directory tree, rather than treating it like a site.
For instance if I run,
localhost/~carey/mysite
it just returns:
Index of /~carey/mysite
Parent Directory
2005/
2006/
index.php
../
If I run
localhost/~carey/mysite/index.php
it runs that file correctly (ie looks correct in the browser)
Seems like an .htaccess issue, but not sure how I would resolve that globally for each folder in the Sites directory
any suggestions?
Probably better served on https://lists.macosforge.org/mailman/listinfo/macports-users/ the macports mailing list. But some basics:
Is the osx web server running? (Web sharing under the sharing control panel?) If so, turn it off, or configure the two to use different ports.
Is the macports apache2 installed? (sudo port install apache2)
Is it running? (sudo port load apache2)
Have you edited its configuration (/opt/local/apache2/conf/httpd.conf)?
See https://trac.macports.org/wiki/howto/MAMP for instructions on getting things up and running.