So I was playing with the sleep method of php. I coded sleep(99999); Now my website won't load lol. Is it because of that? How can I fix it?
I think you can just restart apache, or php-fpm if you are using php-fpm. And why in the world would you try that!
You must restart your server if restarting your web server didn't work. Or, it will just be stuck in a delay until the sleep time ends.
I would advise you not to play with a production server. Use a test server for these tests. Because it is not as easy to reset these issues.
For example, when you are using shared hosting, you cannot restart apache yourself.
How do I setup a test server:
Install some software like XAMPP if you are using Windows in your home PC. Or, if you are using Linux, you can just install apache and php using the following commands on:
Ubuntu/Debian: sudo apt install apache2 php
CentOS/Fedora: sudo yum install epel-release, and sudo yum install httpd php or sudo dnf install httpd php
Arch Linux/Manjaro: sudo pacman -S apache php php-apache
I want to remove output_buffering and want to make change to memory_limit by editing etc/php.ini file
But none of my changes are taking effect.
After editing etc/php.ini file as a super user. I've restarted httpd.service using following command
sudo systemctl restart httpd.service
I am using centOS 8
[root#backend adminuser]# cat /etc/*release
CentOS Linux release 8.0.1905 (Core)
NAME="CentOS Linux"
VERSION="8 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="8"
PLATFORM_ID="platform:el8"
PRETTY_NAME="CentOS Linux 8 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:8"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"
CENTOS_MANTISBT_PROJECT="CentOS-8"
CENTOS_MANTISBT_PROJECT_VERSION="8"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="8"
CentOS Linux release 8.0.1905 (Core)
CentOS Linux release 8.0.1905 (Core)
php-common packages are as below
[root#backend adminuser]# rpm -qc php-common
/etc/php-zts.d/20-bz2.ini
/etc/php-zts.d/20-calendar.ini
/etc/php-zts.d/20-ctype.ini
/etc/php-zts.d/20-curl.ini
/etc/php-zts.d/20-exif.ini
/etc/php-zts.d/20-fileinfo.ini
/etc/php-zts.d/20-ftp.ini
/etc/php-zts.d/20-gettext.ini
/etc/php-zts.d/20-iconv.ini
/etc/php-zts.d/20-phar.ini
/etc/php-zts.d/20-sockets.ini
/etc/php-zts.d/20-tokenizer.ini
/etc/php.d/20-bz2.ini
/etc/php.d/20-calendar.ini
/etc/php.d/20-ctype.ini
/etc/php.d/20-curl.ini
/etc/php.d/20-exif.ini
/etc/php.d/20-fileinfo.ini
/etc/php.d/20-ftp.ini
/etc/php.d/20-gettext.ini
/etc/php.d/20-iconv.ini
/etc/php.d/20-phar.ini
/etc/php.d/20-sockets.ini
/etc/php.d/20-tokenizer.ini
/etc/php.ini
For SSE Script I want to make output_buffer as null or Off like my another server but its not taking any change. I tested by changing php.ini as a root user and restarted httpd services.
I am assuming you are using php-fpm
Following command worked for me.
Connect via terminal and Make sure you are Super(Root) user
sudo su
Now run following command
sudo systemctl restart php-fpm.service
Note : Test by making small change like increasing or decreasing memory_limit in php config file and run above command and review change using phpinfo()
You don't mention whether you're using mod_php or php-fpm. Running sudo systemctl restart httpd.service only helps for mod_php. If you're using php-fpm, you need sudo systemctl restart php-fpm.service instead.
Changing etc/php.ini does not work any more.
You need to add your own .ini file now under "/etc/php.d" and restart php
confirm the path from phpinfo. Look for
"Scan this dir for additional .ini files /etc/php.d"
create file (30 prefix to file name is like priority or how late to load):
sudo vi /etc/php.d/30-user.ini
Add entries like:
max_execution_time=200
post_max_size=100M
upload_max_filesize=100M
Restart PHP (restarting Apache does not help)
Check the service (if not present ..restarting Apache should work: sudo systemctl restart httpd )
sudo systemctl status php-fpm
Resart the service
sudo systemctl restart php-fpm
I am using PHP-FPM with default settings. My server is running the latest Arch Linux.
I issue command sudo systemctl restart php-fpm and it takes five minutes to restart and get back to the prompt.
Is there a known solution to this problem?
This is caused by the way the systemctl script for PHP-FPM was created. I too had this exact same problem. Here is how I've resolved it.
First find your start-up script, if you don't know you can do systemctl status php-fpm and you'll see something like: /etc/systemd/system/php.service
Now edit this file and it should look like this:
[Unit]
Description=The PHP FastCGI Process Manager
After=syslog.target network.target
[Service]
Type=notify
PIDFile=/run/php-fpm/php-fpm.pid
PrivateTmp=true
ExecStart=/usr/bin/php-fpm --nodaemonize --pid /run/php-fpm/php-fpm.pid
ExecReload=/bin/kill -USR2 $MAINPID
[Install]
WantedBy=multi-user.target
Change it to this:
[Unit]
Description=The PHP FastCGI Process Manager
After=syslog.target network.target
[Service]
ExecStart=/usr/bin/php-fpm --nodaemonize
ExecReload=/bin/kill -HUP $MAINPID
Restart=always
[Install]
WantedBy=multi-user.target
One the file is changed run this command to refresh systemctl -> systemctl daemon-reload
Now restart FPM. I'd recommend to shutdown FPM first before making changes to this file. Once the changes are made FPM will start/stop/restart instantly.
Now I don't know why as of just yet, but sometimes after I've made this change it would appear that FPM still takes forever to start/stop/restart. So I just went ahead and rebooted my machine and from then on it was instant. So I'm guessing something was hanging that I haven't found yet but a reboot resolved that. I know you shouldn't have to reboot, but until I can find where exactly it's hanging this did the trick for now.
I'm on OSX Lion 10.7.5. As advised at How do I upgrade PHP in Mac OS X?, I used:
curl -s http://php-osx.liip.ch/install.sh | bash -s 5.4
Everything appeared to go well, no errors, I'm on a 64bit system, etc., but when I run "php -v" I still see the same version I had before (5.3.15). On a scale of 1-10 I'm probably a 2 when it comes to installing stuff via the command line, so, please factor that into any responses.
UPDATE: I took a closer look at the Terminal output after running curl -s http://php-osx.liip.ch/install.sh | bash -s 5.4 and I noticed the following:
Installing package tools-memcached into root /
./pkg/pre-install
pkg/pre-install
Skipping existing directory
Skipping existing directory usr/
Skipping existing directory usr/local/
...then at the end of the installation:
Create symlink /usr/local/php5/entropy-php.conf /etc/apache2/other/+php-osx.conf
Removed /usr/lib from DYLD_LIBRARY_PATH in /usr/sbin/envvars
Restarting Apache
httpd: Could not reliably determine the server's fully qualified domain name
Can anybody elaborate on precisely what that means? As explained in the comments, it seems I've got the files installed, but, I'm having trouble resolving what appears to be a $PATH issue.
create a sym link to the path of your new php install like this:
ln -s /usr/local/php5/bin/php php
If you use Apache first disable current php module
sudo a2dismod php5
sudo a2dismod php5.6
then enable
sudo a2enmod php7.0
and restart apache
sudo service apache2 restart
I think that my server became slow since I installed XDebug.
So, in order to test my hypothesis I want to disable XDebug completely.
I've been searching for tutorials on how to do this but I can't find such information.
Find your php.ini and look for XDebug.
Set xdebug autostart to false
xdebug.remote_autostart=0
xdebug.remote_enable=0
Disable your profiler
xdebug.profiler_enable=0
Note that there can be a performance loss even with xdebug disabled but loaded. To disable loading of the extension itself, you need to comment it in your php.ini. Find an entry looking like this:
zend_extension = "/path/to/php_xdebug.dll"
and put a ; to comment it, e.g. ;zend_extension = ….
Check out this post XDebug, how to disable remote debugging for single .php file?
An easy solution working on Linux distributions similar to Ubuntu
sudo php5dismod xdebug
sudo service apache2 restart
In Linux Ubuntu(maybe also another - it's not tested) distribution with PHP 5 on board, you can use:
sudo php5dismod xdebug
And with PHP 7
sudo phpdismod xdebug
And after that, please restart the server:
sudo service apache2 restart
Also, you can add xdebug_disable() to your code. Try:
if(function_exists('xdebug_disable')) { xdebug_disable(); }
I renamed the config file and restarted server:
$ mv /etc/php/7.0/fpm/conf.d/20-xdebug.ini /etc/php/7.0/fpm/conf.d/20-xdebug.ini.bak
$ sudo service php7.0-fpm restart && sudo service nginx restart
It did work for me.
Comment extension in php.ini and restart Apache. Here is a simple script (you can assign shortcut to it)
xdebug-toggle.php
define('PATH_TO_PHP_INI', 'c:/xampp/php/php.ini');
define('PATH_TO_HTTPD', 'c:/xampp/apache/bin/httpd.exe');
define('REXP_EXTENSION', '(zend_extension\s*=.*?php_xdebug)');
$s = file_get_contents(PATH_TO_PHP_INI);
$replaced = preg_replace('/;' . REXP_EXTENSION . '/', '$1', $s);
$isOn = $replaced != $s;
if (!$isOn) {
$replaced = preg_replace('/' . REXP_EXTENSION . '/', ';$1', $s);
}
echo 'xdebug is ' . ($isOn ? 'ON' : 'OFF') . " now. Restarting apache...\n\n";
file_put_contents(PATH_TO_PHP_INI, $replaced);
passthru(PATH_TO_HTTPD . ' -k restart');
in xubuntu I totally disabled xdebug for the CLI with this...
sudo rm /etc/php5/cli/conf.d/*xdebug*
On Windows (WAMP) in CLI ini file:
X:\wamp\bin\php\php5.x.xx\php.ini
comment line
; XDEBUG Extension
;zend_extension = "X:/wamp/bin/php/php5.x.xx/zend_ext/php_xdebug-xxxxxx.dll"
Apache will process xdebug, and composer will not.
If you are using php-fpm the following should be sufficient:
sudo phpdismod xdebug
sudo service php-fpm restart
Notice, that you will need to tweak this depending on your php version. For instance running php 7.0 you would do:
sudo phpdismod xdebug
sudo service php7.0-fpm restart
Since, you are running php-fpm there should be no need to restart the actual webserver. In any case if you don't use fpm then you could simply restart your webserver using any of the below commands:
sudo service apache2 restart
sudo apache2ctl restart
Ubuntu 16.04 remove xdebug from PHP.
Find your php.ini file and make sure xdebug is there:
grep -r "xdebug" /etc/php/
This might come up with different versions, if so run php -v to find your version.
Edit the php.ini file, like:
sudo vi /etc/php/5.6/mods-available/xdebug.ini
Comment the line:
//zend_extension=xdebug.so
Save the file
Inspired by PHPStorm right click on a file -> debug -> ...
www-data#3bd1617787db:~/symfony$
php
-dxdebug.remote_enable=0
-dxdebug.remote_autostart=0
-dxdebug.default_enable=0
-dxdebug.profiler_enable=0
test.php
the important stuff is -dxdebug.remote_enable=0 -dxdebug.default_enable=0
Two options:
1: Add following code in the initialization Script:
if (function_exists('xdebug_disable')) {
xdebug_disable();
}
2: Add following flag to php.ini
xdebug.remote_autostart=0
xdebug.remote_enable=0
1st option is recommended.
Find your PHP.ini and look for XDebug.
normally in Ubuntu its path is
/etc/php5/apache2/php.ini
Make following changes (Better to just comment them by adding ; at the beginning )
xdebug.remote_autostart=0
xdebug.remote_enable=0
xdebug.profiler_enable=0
then restart your server
again for Ubuntu
sudo service apache2 restart
Disable xdebug
For PHP 7: sudo nano /etc/php/7.0/cli/conf.d/20-xdebug.ini
For PHP 5: sudo nano /etc/php5/cli/conf.d/20-xdebug.ini
Then comment out everything and save.
UPDATE -- Disable for CLI only
As per #igoemon's comment, this is a better method:
PHP 7.0 (NGINX)
sudo mv /etc/php/7.0/cli/conf.d/20-xdebug.ini /etc/php/7.0/cli/conf.d/20-xdebug.ini.old
sudo service nginx restart
Note: Update the path to your version of PHP.
I created this bash script for toggling xdebug. I think it should work at least on Ubuntu / Debian. This is for PHP7+. For PHP5 use php5dismod / php5enmod.
#!/bin/bash
#
# Toggles xdebug
#
if [ ! -z $(php -m | grep "xdebug") ] ; then
phpdismod xdebug
echo "xdebug is now disabled"
else
phpenmod xdebug
echo "xdebug is now enabled"
fi
# exit success
exit 0
I ran into a similar issue. Sometimes, you wont find xdebug.so in php.ini. In which case, execute phpinfo() in a php file and check for Additional .ini files parsed. Here you'll see more ini files. One of these will be xdebug's ini file. Just remove (or rename) this file, restart apache, and this extension will be removed.
I had following Problem:
Even if I set
xdebug.remote_enable=0
Xdebug-Error-Message-Decoration was shown.
My solution:
xdebug.default_enable=0
Only if I use this Flag, Xdebug was disabled.
(This is for CentOS)
Rename the config file and restart apache.
sudo mv /etc/php.d/xdebug.ini /etc/php.d/xdebug.ini.old
sudo service httpd restart
Do the reverse to re-enable.
Since xdebug 3 came out the settings in pnp.ini have slightly changed.
Setting:
xdebug.mode=off
Will disable all processing According to the docs:
Nothing is enabled. Xdebug does no work besides checking whether
functionality is enabled. Use this setting if you want close to 0
overhead.
Disable xdebug only for certain PHP version or sapi.
On this case PHP 7.2 fpm
sudo phpdismod -v 7.2 -s fpm xdebug
sudo service php7.2-fpm nginx restart
You can disable Xdebug on PHP CLI on runtime using the -d flag:
php -d xdebug.mode=off -i | grep xdebug.mode
Result: xdebug.mode => off => off
Example, running unit tests with Xdebug disabled, so it's faster:
php -d xdebug.mode=off ./vendor/bin/phpunit
You can also create an alias for it to make it easier to use.
If you are using MAMP Pro on Mac OS X it's done via the MAMP client by unchecking Activate Xdebug under the PHP tab:
So, yeah, all what you need, just comment line in INI file like zend_extension=xdebug.so or similar.
Comments can be made by adding semicolon.
But, such kind of answer already added, and I'd like to share ready solution to switch Xdebug status.
I've made quick switcher for Xdebug. Maybe it would be useful for someone.
Xdebug Switcher
For WAMP, click left click on the Wamp icon in the taskbar tray. Hover over PHP and then click on php.ini and open it in your texteditor.
Now, search for the phrase 'zend_extension' and add ; (semicolon) in front it.
Restart the WAMP and you are good to go.
Apache/2.4.33 (Win64) PHP/7.2.4 myHomeBrew stack
At end of php.ini I use the following to manage Xdebug for use with PhpStorm
; jch ~ Sweet analizer at https://xdebug.org/wizard.php for matching xdebug to php version.
; jch ~ When upgrading php versions check if newer xdebug.dll is needed in ext directory.
; jch Renamed... zend_extension = E:\x64Stack\PHP\php7.2.4\ext\php_xdebug-2.6.0-7.2-vc15-x86_64.dll
zend_extension = E:\x64Stack\PHP\php7.2.4\ext\php_xdebug.dll
; jch !!!! Added the following for Xdebug with PhpStorm
[Xdebug]
; zend_extension=<full_path_to_xdebug_extension>
; xdebug.remote_host=<the host where PhpStorm is running (e.g. localhost)>
; xdebug.remote_port=<the port to which Xdebug tries to connect on the host where PhpStorm is running (default 9000)>
xdebug.remote_enable=1
xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.profiler_enable=1
xdebug.profiler_output_dir="E:\x64Stack\Xdebug_profiler_output"
xdebug.idekey=PHPSTORM
xdebug.remote_autostart=1
; jch ~~~~~~~~~To turn Xdebug off(disable) uncomment the following 3 lines restart Apache~~~~~~~~~
;xdebug.remote_autostart=0
;xdebug.remote_enable=0
;xdebug.profiler_enable=0
; !!! Might get a little more speed by also commenting out this line above...
;;; zend_extension = E:\x64Stack\PHP\php7.2.4\ext\php_xdebug.dll
; so that Xdebug is both disabled AND not loaded
For those interested in disabling it in codeship, run this script before running tests:
rm -f /home/rof/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini
I was receiving this error:
Use of undefined constant XDEBUG_CC_UNUSED - assumed 'XDEBUG_CC_UNUSED' (this will throw an Error in a future version of PHP)
which is now gone!
In CLI:
sudo phpdismod xdebug
disable xdebug
sudo phpenmod xdebug
enable xdebug
And restart the server