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.
Related
Let's say I have a local apache2 and I need a script that runs the apache2 with a special injected VirtualHost.
More presice:
I have a xampp Installation (PHP 7.3.10, MariaDB 10.4.8, mysqlnd 5.0.12-dev, Apache 2.4.41) on Windows 10.
Several PHP projects are located all over the hard drive. Until now I modify the ./apache/conf/extra/httpd-vhosts.conf file before starting the apache2 service on every project switch. With that I can leave the project folders where there are without copying them in the xampp installation folder.
Now I am curious if I can write a script for each project (bat or sh, GitShell is installed) that will run mariadb normally and apache2 with a temporarily VirtualHost for that specific project folder as DocumentRoot.
What I currently can do:
Lay down a httpd-vhosts.conf file and a startProject.sh script in a project folder. Running the script will copy the configuration file in the xampp installation and then start the apache2 service.
That is working, but only one apache2 process can start and not multiple projects at once.
What I want:
I want to use a parameter that specifies a VirtualHost by parameter when starting apache2.
Maybe by saying apache2 to use a special config file rather then the file in the own project structure.
Or I want to use a parameter by starting the apache2 process that specifies a alternatie DocumentRoot Folder for a already specified VirtualHost.
Currently this is my approach:
#!\bin\bash
BASEDIR=$(dirname "$0")
xamppPath="C:\xampp\v7.3.10"
cd $xamppPath
"apache\bin\httpd.exe" -S "$BASEDIR\httpd-vhosts.conf" &
But -S only prints out the VirtualHosts, not setting the configuration file.
How can I achieve running a project with a script somewhere on my harddrive without overriding the existing configuration file in the xampp installation folder?
Easier: build a couple of congratulation files, use option -f to specify an effective configuration file, not -S.
Can be more complicated: user -D name and use <IfDefine name> in the configuration file to "select" sections of it to apply to a particular start.
Note: I use apachectl, not directly httpd to start/stop Apache.
In the xampp package there is no direct apachectl file, so a use of -D <name> is not possible for me. It would be the perfect solution, but unfortunately not possible.
Now I have to override the httpd-vhosts.conf file from every project I want to start it. Therefore, I am using a modified script solution:
#!\bin\bash
BASEDIR=$(dirname "$0")
xamppPath="C:\xampp\v7.3.10"
cp -f "$BASEDIR\httpd-vhosts.conf" "$xamppPath\apache\conf\extra\httpd-vhosts.conf"
sleep 1
cd $xamppPath
"apache\bin\httpd.exe" &
It is not the perfect solution, but it works.
Two apache services at the same time with two different projects is not possible, but until now not necessary.
I'm using laravel valet to serve sites in my local dev env, which is great. However, there's only one file in the expected location of ~/.valet/Log:
➜ ls ~/.valet/Log
nginx-error.log
I've tinkered with php-fpm log settings and the nginx log settings, but I'm not sure that I'm even using the right config files, since I suspect that valet installs its own version of PHP and nginx.
Can any one tell me where the php / nginx config files for valet would be found, and what specific settings to change to drop the PHP error / log files where they're supposed to be written?
Hopefully this helps with your question about the nginx config files. You can find the nginx configuration for your sites by running cd ~/.config/valet/Nginx in your terminal. To get to the base nginx config for valet use cd /usr/local/etc/nginx/valet. You should then see valet.conf, inside you can update the following lines to put the log files where you want them.
access_log "/Users/[user_id]/.config/valet/Log/access.log";
error_log "/Users/[user_id]/.config/valet/Log/nginx-error.log";
Make sure to run valet restart after you make changes to the valet.conf file.
The NGINX configuration file should be available at /usr/local/etc/nginx/nginx.conf
My server uses Ubuntu with PHP5 and NginX.
I have installed pear using sudo apt-get install php-pear, and later uninstalled it using sudo pear uninstall pear. Today I downloaded phpmailer using sudo apt-get install libphp-phpmailer.
I wrote code to send email with phpmailer. It begins with:
require_once("class.phpmailer.php");
and I edit the php.ini both in /etc/php5/cli and in /etc/php5/fpm to set:
include_path = ".:/usr/share/php/libphp-phpmailer"
It did work well if I execute this php program in command line, but if I visit this php page through my browser, it produce a HTML500 error, and I checked the error.log file, which shows:
PHP message: PHP Fatal error: require_once():
Failed opening required 'class.phpmailer.php'
(include_path='.:/usr/share/php:/usr/share/pear') in ...
I wander how comes this path? I am sure I have edited the include_path in both php.ini files. Is there another configuration file I missed? Where does the string ".:/usr/share/php:/usr/share/pear" come from?
If you are absolutely sure all paths are correct then it could be a file permission issue.
Find out what user Nginx runs under. It will probably be nginx. Run groups nginx and the output should be nginx : nginx, meaning the user nginx exists, and has only one group, which is also nginx.
On the command line navigate to the location of class.phpmailer.php and run ls -l to view the permissions of the files in that directory. Example output would be: -rw-r--r-- 1 someuser somegroup, meaning read and write access is granted to the owner (someuser), read access for the group (somegroup), and read access to everybody else.
The user nginx (if that is what it is running under) needs to have read access to that file. So change the owner/permissions as necessary.
If you need further explanation of how to do any of this just give me a shout and I will update this with further instructions.
I have just installed a fresh copy of Yii2 advanced and am having trouble getting the style sheets to load. The error seems to be that Yii (or webserver) cannot create path /var/www/frontend/web/assets/1ecfb338/css despite doing so in the same http request that it errors. Even after reinforcing file permissions of 777 from without and outside the VM, Yii doesn't seem to make further attempts to write the stylesheet.
If I just refresh the page loads without error but the stylesheet bootstrap.css has not been created in the directory.
This is most frustrating. Does anyone have any ideas?
If it matters I am running Yii in a Vagrant VM with Virtualbox. Debian is the VM OS and Ubuntu is the host.
This is quite strange at not experienced this before. I was able to correct this by changing the mode to 777 as the super user from outside the virtual machine. From doing the same thing inside the virtual machine made no difference.
I have worked on many projects before with this kind of setup but not had this before. Software that I'm using that may be responsible is:
Host machine:
Ubuntu 14.04
Vagrant 1.7.4
Virtualbox 4.3.30
Virtual machine:
Debian Jessie
Nginx 1.6.2
PHP 5.6.14
Edit: I found that I had defined the sync folder incorrectly. I had to change to rule this this:
config.vm.synced_folder "./", "/var/www", id: "vagrant-root", :group=>'www-data', :mount_options=>['dmode=775,fmode=775']
You just give permission for particular directory like:
sudo chmod -R 777 /var/www/frontend/web/assets
The solution for me was adding
sed -i 's/www-data/vagrant/g' /etc/apache2/envvars
to the Vagrantfile like written here
Vagrant file_put_contents permission denied
I am new to Ubuntu Linux (version 13.10). I am following this tutorial to install MySQL, PHP, and Apache2.
It installed successfully, but I don't know where to write PHP files that execute when you navigate to the URL localhost/example.php.
I am looking at this link, but I am afraid that maybe it will not work and have to reinstall Ubuntu again.
In a newer version should be in a different path: /var/www/html
With a series of commands you can find:
ls /etc/apache2/sites-available/
That answers with something like
000-default.conf default-ssl.conf
In this case you need the second file default-ssl.conf; with
grep -n -e "DocumentRoot" /etc/apache2/sites-available/default-ssl.conf
you can obtain:
5: DocumentRoot /var/www/html
That means you can find (and change) DocumentRoot definition in the 5-th lines of the file /etc/apache2/sites-available/default-ssl.conf.
As a simple Google search would have showed you, it's (by default), /var/www/.
In the Ubuntu default config, that is defined in the default virtual host, the config file for that is /etc/apache2/sites-available/default
The default location of document root is /var/www. This, assuming you haven't touched the HTTPd configuration.
By the way, if you simply need a development server for PHP scripts, you can use the one emebedded in PHP > 5.4. Just cd to the project directory and launch:
php -S localhost:8008
In vscode (I'm sure in other editors as well) you can right click the file and copy path and copy relative path.
http://127.0.0.1:8000/site.php
Works for me.