I have a server running OS X 10.8.2. I wanted to install PhpMyAdmin, so I have installed MySQL and PHP (through MacPorts) too. Then I put the PhpMyAdmin folder in the root of my webserver, but when I surf to http://SERVERADDRESS/PhpMyAdmin on any web browser on any device I get the source code of the index.php file instead of the page loaded (see screenshot). Can you help me please?
First, open terminal. In it, write:
sudo nano /etc/apache2/httpd.conf
Find the row with
#LoadModule php5_module libexec/apache2/libphp5.so
and remove the comment from the beginning of the line (remove the #). Hit Ctrl+O and then Control+X to save and quit.
Then restart apache:
sudo apachectl restart
Then try and reload phpmyadmin.
Related
I'm testing file upload between client and server.
But file upload not working because below error.
Unable to move '/tmp/phpxQHW5q' to '/var/www/html/mri_image/test.jpg' in /var/www/html/server_form.php on line 49, referer: http://192.168.1.12/client_form.php
I have searched this problem at stackoverflow.
Most solution is permision problem.
So, tmp and mri_image folder own by apache and changed mod 755.
Then, not working i want to your help
For reference, my os is CentOS 7, php version is 7.3
I had an issue recently with Apache and PHP trying to write to /tmp, but stating that the script failed with an error "No such file or directory"
Centos 7 uses systemd, which has an awesome feature (PrivateTmp) that breaks Apache/PHP access to /tmp folders (particularly in cases where the files need to be shared to other processes/seen by others. This feature works by creating a sort of "virtual" /tmp directory for each process, so a file seen by Apache wouldn't be seen by PHP, etc.
First, copy the httpd.service and php-fpm.service files from /usr/lib/systemd/system/ to /etc/systemd/system using the commands below.
cp /usr/lib/systemd/system/httpd.service /etc/systemd/system/. && cp /usr/lib/systemd/system/php-fpm.service /etc/systemd/system/.
After copying those into place, edit each copy of the files in the new location and change the line with PrivateTmp=true to PrivateTmp=false using vi, or your preferred text editor.
vi /etc/systemd/system/httpd.service
vi /etc/systemd/system/php-fpm.service
After those changes, you need to restart systemd, as well as php-fpm and apache.
Restart systemd:
sudo systemctl daemon-reload
Restart apache:
sudo systemctl restart httpd
Restart php-fpm:
sudo systemctl restart php-fpm
Have read previous answers and understand that I must have two versions installed, but cannot locate where the 5.6 could be. I changed /etc/bin/php to point to the version 7.3 I installed using brew. I updated the /etc/apache2/httpd.conf to use php#7.3. I restarted the server to be sure it would start apache reading from the httpd.conf. Yet, when I run phpinfo from the webpage, It starts with 5.6 and does not include the http.conf info about the server administrator, yet it says it's using http.conf. For some reason sudo apachectl restart will not work saying that the port is already in use. I removed the /usr/local/php5 link ( renamed it to php5.bak ), so that it would not be used.
What other things should I look at?
When you use php -v command you use php-cli which can be diffrent version.
Also if you have multiple versions installed you may want disable apache module for old one.
sudo a2dismod php5 // disable php5.6
sudo a2enmod php7.3 // enable php7.3
There can be many different things that are causing it but I'm betting on MacOS Apache that's installed with the system. Try killing it from the startup:
sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist
I have found a "partial" answer. I am running Mac OS X 10.12.6 on a mac-mini as a web server. The location of the configuration file for apache is:
/Library/Server/web/config/apache2/httpd_server_app.conf
Thus all of the /etc/apache2/httpd.conf and other suggestions, while they work fine on many unix and even OS X ( non-server ) where one has used brew to install, they don't work here. I made some changes in the above file and verified that AFTER going to the Server app, selecting WebSites in the services menu, and clicking toggling the ON/OFF button to off, then back to on, the server is restarted. All of the attempts using different apache2ctl restart, etc. do not work.
I am still somewhat puzzled that I don't see the server administrator that I enter showing up in the phpinfo.php display, but some other changes did.
My next quest, and suggestions are welcome, is how to change the http_server_app.conf file so that instead of php5, it will use my php7 that is available from the command line. The attempt to change:
LoadModule php5_module libexec/apache2/libphp5.so
#LoadModule php7_module libexec/apache2/libphp7.so
did not work as libphp7.so could not be located. I'm now looking for it. At one point in the conference file, I find:
<IfModule php5_module>
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>
</IfModule>
Will I need to have one like this for php7_module, once I find it and use it above?
The only problem I have been facing using AMPPS is getting blank pages after installation or update sometimes. Other than that is great!
Here is a few hints to deal with that:
Apache:
sudo apachectl stop
sudo /Applications/AMPPS/apache/bin/httpd -k start
sudo /Applications/AMPPS/apache/bin/httpd -k restart
When MySQL doesn't starts on AMPPS, this might help:
1- Open AMPPS Application -> MySQL Tab -> Configuration.
2- In [mysqld] section, add the following line:
innodb_force_recovery = 1
3- Save the file and try starting MySQL
4- Remove that line which you just added and Save.
or
"/Applications/AMPPS/php/bin/php" -c "/Applications/AMPPS/php/etc/php.ini" "/Applications/AMPPS/ampps/softaculous/enduser/install.php"
"/Applications/AMPPS/php/bin/php" -c "/Applications/AMPPS/php/etc/php.ini" "/Applications/AMPPS/ampps/softaculous/cron.php"
PhP Errors:
1- Go to PhP tab -> PhP Extension
2- Enable those extensions you need for your codes one by one and test it (e.g. mysql.so, mysqli.so, ctype.so, dba.so, pdo_mysql.so)
3- Restart Apache and MySQL
Hope someone more knowledgeable would edit this post!
Cheers!
i'm your average college student interested in using PHP. Could anyone give me a 101 on how to install/enable it on a mac version 10.7.2 using simple, plain language? I will appreciate any and all help!!
Cheers
No Need to Install PHP or Apache, They already ship with Mac 10.7
These are the basic steps you need to take for PHP and Apache to work together:
Enable PHP in you httpd.conf file located - /etc/apache2/httpd.conf
Setup your php.ini - sudo cp /etc/php.ini.default /etc/php.ini
Enable the Apache web server located in the Sharing > Web Sharing
Enable PHP in Apache
Find this setting in your httpd.conf file
#LoadModule php5_module libexec/apache2/libphp5.so
And, uncomment it like
LoadModule php5_module libexec/apache2/libphp5.so
This guide explains setting up MySQL and VirtualHost on Mac. I have been using this setup for over six months. Also, worked on the 10.7 early releases just fine.
http://superfancy.net/coding/php-mysql-apache-in-mac-osx-leopard/
Shell Commands to Start and Stop Apache on Mac
Start Apache
sudo apachectl start
Restart Apache
sudo apachectl restart
(edited to remove typo in restart command)
PHP5 should be already installed, it's just disabled. Open the Apache config file with a text editor it's at
/private/etc/apache2/httpd.conf
Now find the line which reads: "#LoadModule php5_module libexec/apache2/libphp5.so" and delete the comment (hash) from the beginning of the line and save the file (you'll need admin permissions to do this)
Now restart Apache - from the Terminal app type: sudo apachectl graceful
It will ask for your admin password
PHP should now be working..
I have recently updated to Lion and enabled Web Sharing in the System Preferences but I am unable to get php working.
I added an info file to the web root directory and it outputs the file as text.
info.php
with the content
<?php phpinfo(); ?>
(Edit: This method appears to work fine for 10.9 (Mavericks), 10.10 (Yosemite) and 10.11 (El Capitan), so I figured I'd mention that for any new influx of slightly frustrated OS X updaters :D )
Edit your /etc/apache2/httpd.conf and make sure the line:
LoadModule php5_module libexec/apache2/libphp5.so
...exists. I think it's commented out by default in the standard OS X config, but from what I remember, you just need to uncomment it, then re-start Apache:
sudo apachectl restart
And you should be good to go.
UPDATE: Please note that this was written for OS X pre-(High) Sierra. If you run OSX 10.12 or newer, please follow this more than excellent guide by Andy Miller: macOS 10.15 Catalina Apache Setup: Multiple PHP Versions
I too like to use things that are basically already there. I don't see why anyone would use MAMP or AMPPS (or any other packed 3rd party out-of-box webserver app) when Mac OS X comes with apache and PHP by default.
Took me a couple of tries to get it working, so here is basically what did it for me and hopefully it'll help you guys save a little time.
Like Matt Gibson said, start terminal and type: (sudo requires your root password)
sudo nano /etc/apache2/httpd.conf
Then uncomment this line by removing the '#' in front of it (ctrl+v can be used as page-down)
LoadModule php5_module libexec/apache2/libphp5.so
To make sure you can include files etc in PHP, scroll to "User _www" (in my case) and change that to: (where "yourusername" is the user you login with)
User yourusername
You can leave the group as-is, "Group _www" by default on a fresh OS X Mountain Lion install.
On default apache only looks for index.html, so search for "DirectoryIndex index.html" and change that to: (adding index.html at the end is optional of course)
DirectoryIndex index.php index.html index.htm
Exit and save by pressing ctrl+x (and confirm with "y")
Then restart apache:
sudo apachectl restart
My phpinfo(); returned with a PHP Version 5.3.15
==================
Since I find it useful to have my local sites in my user dir, I created a directory /Users/yourusername/Sites (which isn't there on default anymore in Mountain Lion).
Again, edit httpd.conf via "sudo nano /etc/apache2/httpd.conf" and ...
Scroll down to "DocumentRoot" and change it to: (where "yourusername" is the username you login with)
DocumentRoot "/Users/yourusername/Sites/"
Scroll to where it says "# This should be changed to whatever you set DocumentRoot to." and change the next line to: (where "yourusername" is the username you login with)
<Directory "/Users/yourusername/Sites/">
Then exit and save by pressing ctrl+x (and confirm with "y")
Restart apache.
I have one word for you. MAMP.
Try it phpbrew
It's ease build, install tool for PHP, any version.
For the latest version of mac os i.e Mojave 10.14, follow the steps below to activate PHP server:
Open terminal. Press command+spacebar, type terminal and press enter.
Enter command $ sudo nano /etc/apache2/httpd.conf to edit httpd.conf file in nano, which is an inbuilt file editor in macOS.
Enter the password.
Now search loadmodule by pressing control+w.
Find file named #LoadModule php7_module libexec/apache2/libphp7.so
Uncomment the file by removing the # symbol present at the very beginning of the module.
Now exit the editor by pressing control+x, press y to save the changes and press enter to confirm changes to the httpd.conf file.
Now restart the apache server by entering the command
$ sudo apachectl restart
PHP server should be running now running.
Now you can check the working of your server by opening the PHP file from your default server directory or you can also change the directory as well.
After upgrading the MAC OSX to 10.14.5 My Apache config file was new and all my previous settings were replaced with default settings.
I was not able to open any PHP files in my browser. I followed the above steps and it resolved the issue.
Note - In OSX 10.14.5 there is Php7.1.23
Steps I followed -
Edit the httpd.conf file located under /etc/apache2/httpd.conf
This below given live was commented. I uncommented it by removing the # sign and saved
the httpd.conf file and restarted the apache service.
LoadModule php7_module libexec/apache2/libphp7.so
sudo apachectl restart
Thank you for the solution, appreciated your help friends.
Regards,
Vicky Jadhav (India - pune)