I wanted to run some PHP right on my Mac, uncommented httpd.conf, activated web sharing, installed MySQL etc.
I can't seem to find my PHP files, most importantly, PHP.ini.
On my old machine it was located in /usr/local/php5/lib
But php5 directory doesn't exist in /usr/local..
Do I need to get a package or am I looking in the incorrect place?
Running OS X 10.7.3, PHP 5.3.8, Apache/2.2.21
To locate the ini file on your machine, open Terminal.app and run the following command:
php --ini
If you need a template for Lion, try this.
You should find it in /private/etc if it exists, otherwise:
sudo cp /private/etc/php.ini.default /private/etc/php.ini
In terminal do php -i | grep php.ini.
Should give you some clues ;)
Answers from #Cronk and #Justin got me close on Mac OS X 10.9 Mavericks. In fact, on my system the /etc/php.ini file was missing completely, and it wasn't until I ran phpinfo() on the web server that I observed there was no configuration file. Copying the file from /etc/php.ini.default and adding the fully qualified path to the mcrypt.so library to the config file solved the problem:
cp /etc/php.ini.default /etc/php.ini
Then in /etc/php.ini add the following line (using the correct path to your mcrypt.so file):
extension="/usr/local/Cellar/php54-mcrypt/5.4.29/mcrypt.so"
Then restart Apache2:
apachectl restart
As pointed out, the php --ini command will tell you where PHP is expecting to find the php.ini file.
For a standard installation, it's likely to be looking for /etc/php.ini
If you've used macports then PHP may be looking for /opt/local/etc/php5/php.ini
Run phpinfo() from any file and it tells you where it is. Here is a screenshot.
I have more than once instance of PHP running so the other answers did not work for me. This did:
Create a PHP file and open its local url in your browser:
<?php phpinfo(); ?>
The PHP.INI path will be listed close to the top.
1- Find .ini location path
Open Terminal and run command
php --ini
2- copy this path /usr/local/etc/php/7.4/php.ini
and open it by command
nano /usr/local/etc/php/7.4/php.ini
3- Make changes and Quit with the keyboard combination Ctrl+X to exit nano
4- run apachectl restart after finish
This is rather old thread, but I would like to add a further clarification.
If you have a system that has multiple PHP installations (like mine did) the results you get from using the command line tools MAY BE different than what is actually used by the web server. If you are interested in what PHP is being used by the web server, only use the information gathered from a web page that uses the 'phpinfo()' function.
For example, on my system the versions reported by the two different methods were:
Command line: 5.3.26
Web: 5.3.13
For the php.ini file path things were different, too:
Command line: /private/etc/php.ini
Web: /long/path/to/the/file/php.ini
You can find all the possible php.ini files using this:
find / -name php.ini 2>&1 | grep -v "denied" | grep -v "directory"
(the '2>&1' and 'grep' elements just restrict the output of the command to useful information, i.e. get rid of error messages)
On my system I found 3 INI files. Because I was interested in what the web server was using I knew that I should use the path returned from the web-page results. I made my changes to the php.ini file that was listed there, restarted apache, and re-ran the web page; the new edits were shown there.
To restart apache:
sudo apachectl -k restart
-- J
On OSX/MacOS do the following in a Terminal window:
Run php --ini at the prompt by typing it and pressing enter
Reports something like:
Configuration File (php.ini) Path: /etc
Loaded Configuration File: (none)
Scan for additional .ini files in: /Library/Server/Web/Config/php
Additional .ini files parsed: (none)
...this is because in /etc there is a file called /etc/php.ini.default as an example and to show it is not in use. You need to copy that file to the name php expects so that you can edit it, like this:
Type:
$ sudo cp /etc/php.ini.default /etc/php.ini (and enter your password)
...then you will see if you run php --ini again that it now sees your new file:
Typing this: php --ini at the prompt should report this:
Configuration File (php.ini) Path: /etc
Loaded Configuration File: /etc/php.ini
Scan for additional .ini files in: /Library/Server/Web/Config/php
Additional .ini files parsed: (none)
...now edit /etc/php.ini - you want to make sure the following lines (NOT the same line starting with a semi-colon ';') are exactly as follows:
log_errors = On (this will turn the logging engine on)
Then, in this section:
; Log errors to specified file. PHP's default behavior is to leave this value
; empty.
; http://php.net/error-log
; Example:
;error_log = php_errors.log
; Log errors to syslog (Event Log on Windows).
;error_log = syslog
If you want to log to the syslog (or Windows Event Log on Windows) then ;error_log = syslog should become error_log = syslog
However, if as you say, you want to log to a file, you uncomment by removing the leading semi colon to make ;error_log = php_errors.log become error_log = php_errors.log or using a full path to place it where you want.
Good luck
I start with the 'Hello World!', once I get that displaying in my browser I throw a phpinfo(); in there and you can see all of the things. Tells you which configurations are loaded, everything.
<?php
echo 'Hello World!';
phpinfo();
You run php_info() and see line bellow :)
Loaded Configuration File /Applications/XAMPP/xamppfiles/etc/php.ini
Here is the complete method to modify correct php.ini in mac.
Find out the ini location via php --ini, this will give something like below:
Configuration File (php.ini) Path: /usr/local/etc/php/7.4
Loaded Configuration File: /usr/local/etc/php/7.4/php.ini
Scan for additional .ini files in: /usr/local/etc/php/7.4/conf.d
Additional .ini files parsed: /usr/local/etc/php/7.4/conf.d/ext-opcache.ini
Now open the php.ini via sudo vi /usr/local/etc/php/7.4/php.ini
Make your changes and exit it via :wq
Run final command sudo apachectl restart
You are changes should be now reflected, if done correctly :)
Related
I'm using #angular/compiler-cli to build my ng2 app in aot mode. When I input 'ngc -p tsconfig-aot.json' in my bash window, I get 'bash: ngc: command not found'. However, when I use 'node_modules/.bin/ngc -p tsconfig-aot.json' instead, it works. I googled for serval times but didn't get any usfull information. Can any give me a hand? Thx!
Seems like you need to put ngc in your path:
echo $PATH
Do you see ngc in binary in your path?
If not:
PATH=$PATH:/path/to/ngc
To make it permanent add to .bash_profile
export PATH=$PATH:/path/to/ngc
I've tried to change the slash to 'backslash' on windows and it worked for me:
node_modules\\.bin\ngc
If you don't want to set it globally, you can specify an absolut path in your angular-project, just make sure that you delete this part of the path when you don't use it anymore.
ngc is in node_modules/.bin, so depending on where you want to use ngc you can export the path like this:
PATH=$PATH:../../../node_modules/.bin
To run commands located into the node_modules folder of your project, without installing them globally (operation that will make the ngc command work in any system folder), you can use this command:
ngx ncc <options>
Basically ngx is a shortcut that executes any command located in node_modules bin folder.
I was downloading the CakePHP framework for a project. Below the steps:
Installation
1) Install PHP 5.6 from: http://php-osx.liip.ch/
curl -s http://php-osx.liip.ch/install.sh | bash -s 5.6
2) add the updated PHP version to our path. So we edit .profile file
nano ~/.profile
Add into the file
export PATH= /usr/local/php5/bin:$PATH
Then hit Control + O to write out the file
Then hit Control + X to save the file
exit
Restart the Terminal
Now the terminal doesn't work as usually. I've tried to understand the shell concept and apply different solutions, but I can't even find the .profile file again.
I obtain errors like:
enter code here-bash: ls: command not found
Anybody can explain me what's wrong and the shell concept to properly understand shell (-bash)?
The problem is this:
export PATH= /usr/local/php5/bin:$PATH
You killed your PATH variable. You need to find a way to edit .profile file, and change that line to:
export PATH=$PATH:/usr/local/php5/bin
You could try editing with the following command (using vim):
/usr/bin/vim /Users/yourname/.profile
Or (using nano):
/usr/bin/nano /Users/yourname/.profile
Or just remove .profile file completely by doing /bin/rm /Users/yourname/.profile. Of course, in any case, you need to restart your terminal once you're done.
I have problems with MySQL on my MacBook. I had updated my OS from Yosemite to El Capitan before I installed MySQL server.
Now, when I try to run MySQL on Terminal, I got the error like this
ERROR! The server quit without updating PID file
Anyone can help me please? Thanks a lot!
Try updating your my.cnf file to set the location of the PID file manually. Here's how you do that.
In your Terminal run the following command.
ps -ax | grep mysql
This will list all the locations of the important mysql files. Look for the path of the --pid-file
I will look something like this:
--pid-file=/path/to/your/local/mysqld.local.pid
Copy the path of the mysqld.local.pid file
Next open your my.cnf file using nano
sudo nano /usr/local/mysql/my.cnf
Set the pid-file path at the end of your my.cnf file. Search for pid-file. If you can't find it, manually enter it at the end of your my.cnf file. This will tell mysql where to look for the PID file. Enter the path that you copied like the example below.
pid-file = /path/to/your/local/mysqld.local.pid
Close and save the file
Next restart mysql. You may need to do this twice to reset your PID error.
sudo /usr/local/mysql/support-files/mysql.server start
That should solve your problem! Good luck
I had to create the file my.cnf in /etc and add [mysqld] before the line pid-file = /path/to/your/local/mysqld.local.pid
Finally it worked!
I'm trying to edit a remote file with VIM. In terminal, I type:
vim scp://my_user#some.server.net//app/logs/jboss/sso.log
and get this output:
:!scp -q 'my_user#some.server.net:/app/logs/jboss/sso.log' '/var/folders/4d/6z5mf6m96bq105stbqy_tjf4jmvwpj/T/vyHJPX5/0.log'
my_user#some.server.net's password:
[8]+ Stopped vim scp://my_user#some.server.net//app/logs/jboss/sso.log
I know that I have the right credentials and the file exists, because:
scp my_user#some.server.net:/app/logs/jboss/sso.log ~/Documents
successfully copies the desired file to localhost.
The vim wikia suggests that my syntax is correct.
The file is being downloaded, but VIM doesn't start to edit it.
The same happens when I start vim and issue the following command:
:e scp://my_user#some.server.net//app/logs/jboss/sso.log
The file is downloaded to the temp folder, and I'm being thrown out of VIM back to the console.
I'm using VIM 7.3 (2010 Aug 15, compiled Nov 6 2014 14:32:04) on OSX. I installed it with brew.
How can I fix this situation and have VIM started to edit the remote file?
It appears that Vim is trying to create a temporary local copy of your file for the editing. But this is located at /var/folders/... (as shown in the scp), which you may not have permissions to write to.
Try having it write somewhere your user controls by setting TMPDIR:
export TMPDIR=$HOME/tmp
mkdir $TMPDIR # if it doesn't exist
Also, by having the double-slash (//), you’re telling vim to use an absolute path, so /app should not be relative to my_user’s home. Not clear if you’re doing that intentionally.
What are the commands for adding the MAMP Apache, PHP and MySQL error logs to the MacOSX Console?
Thanks!
Similar to this question...
Console has a few standard locations where it will look for and index log files. The easiest thing you can do is add a symbolic link from the MAMP log files into one of the directories Console already uses, like ~/Library/Logs.
For example, my MAMP log files are located in /Applications/MAMP/logs. So I did:
cd ~/Library/Logs
ln -s /Applications/MAMP/logs/php_error.log .
ln -s /Applications/MAMP/logs/apache_access_log .
Hope that helps!
Do you mean Console.app? If so, click File/Open. If MAMP's logs are in a location that's not shown in the standard "open file" dialog, use Cmd-Shift-G to open a text field you can type the path into.
Console should remember the log files, so you can simply click them on the list at the left the next time you run it.
It looks like they changed the behavior in the console app!! It used to be that you could just throw a symlink to a directory and the contents would show up in Console, but:
On El Capitan, Console doesn't follow symlinks to directories full of log files, it shows the directory but not the contents... so I have found it works really well to do this:
cd ~/Library/Logs
mkdir MyNewLogsFolder
cd MyNewLogsFolder
ln -s /path/to/logs/folder/*.log .
That will create a new entry in the left-side quick-access bar in Console and fill it with symlinks to the log files in your original logs directory.
It's quick and easy and works consistently across all versions of OS X.