Run browser-sync in php server - php

I have a XAMPP local PHP server and I need use browser sync but I don't know how to run it WITHOUT gulp or grunt only using command line. I try to
browser-sync start --server --port 80 --files "css/.css"
but instead of port 80 it launch with 81 port
browser-sync start --proxy 'localhost:80' I tried this. It's connect to my localserver but doesn't refresh

You have an error in your --files argument. There should be an asterisk before .css to select all CSS files in your css directory, like this:
browser-sync start --proxy "localhost:80" --files "css/*.css"
Remember that the directory path should be relative to the current directory you're inside in your terminal/cmd window.
This means that if your server is running on localhost and CSS files can be found under localhost/css, it is NOT enough to just run the browsersync script above from any directory.
You have to navigate to your local server folder (usually C:\xampp\htdocs, where your real css folder is located) and run the browsersync script from there. Alternatively, if you don't want to change the directory in your console/terminal/cmd window, you have to specify the full relative path to your CSS files from your current directory.
Had the exact same issue, and I just had to run the script from the correct folder path.

Related

Is it possible to use browser-sync as a proxy to watch for PHP files?

I have a xampp php server running at port 8080. Is it possible to do something like this
browser-sync start --proxy "localhost:8080" --files "*.php" "css/*.css" "js/*.js"
It works, in that localhost:8080 is proxied but the page doesn't refresh when I edit the PHP code

YII 2 application on VirtualHost in fedora 26 OS - The directory is not writable by the Web process

I develop a small system using YII2 PHP framework on my local host.
folder path "/var/www/html/MY_SITE"
with "yii php serve" command it work fine for this url - localhost:8080
Then I configured a virtual host with documentRoot "/var/www/html/MY_SITE/web" and host name like "www.my.site.lk"
and configure my host file.
restart httpd service.
then go to url www.my.site.lk.
but site not working.
YII application error.
Invalid Configuration – yii\base\InvalidConfigException
The directory is not writable by the Web process: /var/www/html/RLF_CMS/web/assets
in /var/www/html/RLF_CMS/vendor/yiisoft/yii2/web/AssetManager.php
but still woke this url (localhost:8080).
Please help me...
Give write permision chmod -R 777 to folder runtime and web/assets

How to edit Apache Host file using php and add domains into it

I have an dedicated server where i have to create multiple virtual hosts.So for this i have managed to create .conf file in /apache2/sites-available folder using php,but next step is to add that virtual host entry in host file which is at /etc/hosts.
I can do this using Linux command by editing hosts file in nano editor,But i want to do this using php.
I found this command which add entry in host file using terminal which i will execute via shell_exec() programmatically,
sudo echo "192.168.xx.xx example.com" >> /etc/hosts
but this is not working,it throws permission denied error.
So,can i edit host file dynamically using php or can i append a line into it?

How to reach Laravel without /public/index.php

I'm following the official Laravel course (currently the first chapter "Meet Composer,"), but I can't seem to get it right. In the course I was instructed to enter in the command line:
php -S localhost:8888 -t public
and I should be able to reach the URL: "http://localhost:8888/learning-laravel-5", but this gives me a 404 error.
But if I put in this URL I get to see the frontpage, as it should: http://localhost:8080/learning-laravel-5/public/index.php
My question is, how can I see the frontpage as instructed in the video, following the provided URL: http://localhost:8888/learning-laravel-5 ?
I have looked through the duplicate questions on stackoverflow but I can't find a solution to this problem.
Edit: I have tried to get my absolute path by doing pwd, its says "/media/sf_sandbox/laracast-4.2", I now have done this: "php -S localhost:8888 -t /media/sf_sandbox/laracast-4.2/public". I now go to localhost:8888 but it still doesn't work.
It says my documentroot is /media/sf_sandbox/learning-laravel-5/public
If you are running below command from the project root learning-laravel-5 , than localhost:8888
it self points to the learning-laravel-5/public folder
php -S localhost:8888 -t /var/www/html/learning-laravel-5/public
In this case only localhost:8888 should work and you don't need to append learning-laravel-5 after that.
It seems like you are using XAMP..because
For XAMP, localhost port is 8000 And
For XAMP, localhost port is 8000.
in the laravel directory, where you ran composer, type php artisan serve. This will run an internal webserver, which opens up 8000 port by default. Once you have that, open your browser and access http://localhost:8000
If that works, you have an issue with your MAMP configuration.
If it is MAMP, check the following
1) make sure you set the document root to the /public directory in your laravel installation.
2
make sure you have enabled rewrite module in your mamp.
Checkout How to get htaccess to work on MAMP

Allow Apache/PHP a read/write access to a mounted directory

We have websites running on a linux server with apache httpd and php. On that server a certain directory from a windows server is mounted as let's say /mnt/some_directory/. I can browse this directory with both WinSCP or SSH, using my own user account.
I can also perform the following in SSH:
php -r "print_r(file_get_contents('/mnt/some_directory/file_name.txt'));"
and see contents of that file.
We need to read a file and parse from that directory in order to import it in the database that is used by the website. But when an fopen or a file_get_contents on the website we get a permission denied error.
I have limited access to the web server (and limited knowledge of *nix and apache configuration), but the administrator that is supposed to resolve this apparently is also lacking this knowledge and I need to have this task resolved,that's why I am asking here.
What the admin did was to set the group and ownership of the mounted directory to"apache", which is the user the httpd process is running as. But that didn't help.
As far as I know access to files outside of the webroot is disallowed by default. Would it be sufficient to set a DIRECTORY directive in httpd.conf for /mnt/some_directory/? Or is there anything else that has to be done?
our team had the same issue, my team-mate was able to resolve this by adding context to mount options.
we are using the following format for mounting windows shared folder to linux that apache will be able to access:
mount -v -t cifs <//$hostname/$(windows shared dir)> <mount directory> -o username="<username>",password=<password>,domain=<domain name>,iocharset=utf8,file_mode=0777,dir_mode=0777,context="system_u:object_r:httpd_sys_content_t:s0"
For example:
mount -v -t cifs //192.168.1.19/sample_dir /mnt/mount_dir -o username="admin",password=adminpwd,domain=MIINTER,iocharset=utf8,file_mode=0777,dir_mode=0777,context="system_u:object_r:httpd_sys_content_t:s0"
Link the mounted directory to your www root dir and name the link "share"
ln -s /mnt/some_directory /path/to/your/www/root/directory/share
than try reading the file
php -r "print_r(file_get_contents('/path/to/your/www/root/directory/share/file_name.txt'));"
...or you can allow (if you have enough privileges to edit the webserver's configuration)
<Directory /mnt/somedirectory >
Allow from All
</Directory>
i have seen the same problem with a cifs mount
linux/unix apache that user can have access to the mounted volume, but not apache.
see also this: EnableSendfile off
but when turned off, apache may work slowly,
in .htaccess, only for the cifs mount path, it should work ... .
http://httpd.apache.org/docs/current/en/mod/core.html
best regards
L.Tomas

Categories