Good Afternoon,
I am currently working on a PHP project which requires a php script to mount a windows shared drive. Currently building using OSX with XAMPP.
exec('mount -t smbfs //user:pass#192.168.1.1/Share /Volumes/Share 2> temp/error.txt');
Now i understand why this does not work. Its due to permissions. Apache is running as user daemon. Now i could change the user that Apache runs to fix this "challenge" but want to avoid any changes to the server if possible.
I would like to reach out and see if there is a better way to go about this.
Any ideas?
Ok, So i got it working.
I just needed the web server (user daemon) to own a folder in which the share is mounted.
EG. created a folder called "tempshare" that user daemon owns and is in the same folder as the php script (don't worry, it will be placed out of the web root when complete)
exec('mount -t smbfs //user:pass#192.168.1.1/Share /path/to/tempshare 2> temp/error.txt');
Seemed to work. Any advice on security using this method?
Related
I have install Laravel in my pc using composer.
I used gitbash and started xampp control server
First I've changed my directory.
Then I've ran a command composer create-project laravel/laravel project_1. After the command had run, it installed laravel and all necessary file and key was successfully set.
Then I again changed my directory to project_1
Then I ran another command php artisan serve. After running this command Laravel development server started and 127.0.0.1:8000 this ip has genrated.
I copied the id and paste it in my browser url bar.(I copied and pasted it without using keyboard. I only used mouse)
but when I provided the ip the project_1 starting page did not open.
The page was loading and it is still loading.
what can I do? Please help
logs folder
Here is my contribution, I cannot say what is the cause but I have a solution for it; because I have such as a challenge.
run
php -S 127.0.0.1:8000 -t public
Note that the 8000 is your port, and this could be any 4-digit number.
I hope this helps
Every thing you did seems right to me in terms of Laravel requirements, so lets check some other possible issues:
make sure that your internet connection isn't configured to use
proxy, if so make sure you excluded your local address.
if you are using Internet security suite software, make sure it doesn't block your requests, this vary from software to another but you might test this by deactivating the software for a while until you try.
now that's what I have in mind, I hope it help.
First, stop the php artisan serve
After changing directory go to inside your project folder, you can run php artisan serve. Then a localhost URL will be generated for you where you can see your project in the browser
If you have PHP installed locally and you would like to use PHP's built-in development server will start a development server at http://localhost:8000
Please try to install Laragon and forget about Xampp for now. This is really cool tool and you'll start much quicker. I did try to resolve few issues with Xampp myself and always wasted a lot of time. You can google tutorials later for it as well. Plenty of info out there.
As well it comes with in house installer for Laravel ;) and more :).
Make sure that you are not coping the url from Git Bash through command, it will stop running the project
Make sure that you are not using antivirus specially avast antivirus.
We have an in-house Ubuntu Linux server that we use for development of PHP sites. The /var/www folder is shared via Samba on our network with settings that force anything created through this share to be www-data:www-data. Not the best, but it works.
We've recently started using Laravel - and this requires you to perform commands through artisan on the command line. I SSH into the Linux server to do this - but as a different username. Any files that are then created on the command line via artisan have my username and group attached to them and therefore cannot be edited remotely through the Samba share as they don't have the correct permissions unless I then chmod / chown them as well.
I would prefer this to happen automatically or, even better, to not be needed at all. My colleagues will start to build Laravel sites soon and it's not going to look good if they have to do this.
I have a feeling I'm doing something fundamentally wrong with the way we've got all of this set up (aside from the www-data thing) - I'd appreciate any pointers.
I have a DigitalOcean server running Ubuntu 14.04. I'm using this as a host for my web-development projects.
Now I want to start using Laravel for a project of mine, but I have a question about this.
In the /var/www/html folder of Ubuntu I created a folder, let's say, "project". In this folder I installed Laravel using this tutorial. Now everything is setup I want to run Laravel so I can test it and start developing on it.
When I run the command php artisan serve from within the "project"-folder it says "running on http://localhost:8000". So it's working.
But how do I access it? When I go to http://example.com/project it just shows me the files in that folder.
So it's running on the localhost on my server. Does that mean that it is external-accesible (the url above) or how does this work? (I guess the port is also different, 8000 instead of the default 80 for Apache)
I hope the question is clear and someone can help me out.
I have a Laravel project up and running on Digital Ocean with the Ubuntu 14.04 x64 vmlinuz-3.13.0-24-generic (1221) kernal.
I don't think you should be using php artisan serve for this purpose, as that is more for your local computer if you would like to preview your webpage if you don't want to use Apache.
To get set up, I used the excellent below instructions that were incredibly helpful. As you can see, there are many steps that you should carefully follow to get things up and running.
https://github.com/susanBuck/dwa15-fall2016-notes/blob/master/01_Servers_and_Git/07_Deploy_to_Digital_Ocean.md
Let me know if that helps you, and feel free to follow up with more questions if you get stuck on a step.
I've been working with a WAMP setup on windows, while learning PHP and MySQL. Lately, I wanted to try to put some of my work online and signed up for Rackspace, and I've now set up a LAMP environment for my server with centOS 6.5.
When I worked off of my own WAMP environment, all files were inside wamp/www as the root directory.
Now, I understand that my root directory for my web environment will be /var/www/html.
To be clear, I am logged as root, so I'm not interested in changing permission. I'm simply interested in learning how to add files into this directory, which the existing posts on stackoverflow or rackspace does not seem to have an answer for.
I'm completely new to Linux and I'm using Putty to write to my linux server. Could someone please walk me through the process of putting files into and taking files out of /var/www/html?
Use pscp from the putty suite, to copy your files from your machine to the server via scp.
See http://the.earth.li/~sgtatham/putty/0.60/htmldoc/Chapter5.html
I am not much of a web developer, so apologies in advance for this dumb question.
I have a test server (Centos 6.3) with LAMP set up for me to play around. From what I understand, the server executes whatever is in /var/www/html directory. How do you edit source files in that directory ? Do you do a sudo vim "foo.php" each time you want to fix something (or add something ) ? I'd imagine that would be a pain when you are building a complex application with many files and directories .
This is what worked for me. For the record this is a Centos 6.3 server running LAMP (On Rackspace).
First, I found out that apache runs as user "apache" and group "apache" on centos systems. In other distros, I believe it runs as "www-data" in group "www-data". You can verify this by looking at /etc/httpd/conf/httpd.conf. We need to change ownership of /var/www to this user. Replace "apache" below with "www-data" if that is the case for you.
chown -hR apache:apache /var/www
Now lets make it writable by the group:
chmod -R g+rw /var/www
Add yourself to the apache group:
usermod -aG apache yourusername
Replace apache with www-data in the above if thats the case for you.
Now log out and log in - you can now edit the files, ftp them to this directory or do whatrever you want to do.
Comments welcome. TNX!
There are many approaches to modifying and deploying websites/web apps.
CentOS 6 is, by default, accessible with SSH2 on port 22. If you are on Windows you can use a combination of PuTTY and WinSCP (to manage your server, and its files, respectively). If you're on Linux or Mac OS X, SSH is already built into your system and can be accessed with Terminal. I find that using SSH is favourable over other methods because of how widely supported, secure and lightweight it is.
You'll also need a decent text editor or IDE to edit the files if you want proper syntax detection. There's tons of choices, my favourites are Notepad++ and Sublime Text 2. Not to say that I haven't edited my PHP files from time to time using the nano text editor package directly in PuTTY (yum install nano).
If you're using a edit-save-upload approach, just remember to back up your files regularly, you will find out the hard way if you fail to do so. Also, never use root unless you need to. Creating a user solely to modify your websites is good practice (adduser <username>, and give that user write access to /var/www/html).
To answer your second question:
Once you get into heavier web development you will probably want to use something like Git. Deploying with git is beyond the scope of this question so I won't get into that. In brief, you can set it up so your development environment sits locally and you can use a combination of git commit and git push to deploy.
I use a FTP client (FileZilla) to download files, edit them and then re-upload them. If you're a one (wo)man show, and on a test setup and just playing around to learn, this is probably sufficient. With more than 1 person, or going to a (test and) production setup, you should look at some more control with svn like #Markus mentioned in another answer.
You should change the permissions of that directory (with chmod) so you have write permissions, and can then read and write to that directory. Then, you don't need sudo.
dude. read up on version control and source code control systems like subversion and git. the idea is to develop on your machine, revision control the result, then deploy a known working version on the production server.