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
Related
I have a server that uses Nginx and PHP-FPM. It was working as well, I executed the following command for some reasons:
apt-get --purge remove php-common
After that, I executed this:
apt-get install php-common php-mysql php-cli
Commands executed successfully, but I get 502 error when I want to access websites on the servers:
It should be noted, there are several projects on this server. And I have nothing inside /etc/nginx/sites-available. I have all configurations under /etc/nginx/conf.d. See:
Each of them is a project. Now, I guess I need to set to PHP-FPM to use conf.d instead of sites-available. Any idea how can I do that?
Could you please help me how can I debug it?
I am trying to install a LAMP working environnement but for some reason nothing happen. The lack of error messages makes me wonder what to look for.
I followed the Ubuntu installation process :
sudo apt install apache2 php libapache2-mod-php mysql-server php-mysql
At that stage, localhost should display the "It works!" message but it doesn't.
I have been restarting the apache service several times with no effect:
sudo service apache restart
it looks to be fine anyway.
I have checked the following files as advices on some online tutorial :
/etc/apache2/sites-available/000-default.conf
/etc/apache2/apache2.conf
I am atually clueless on what to troubleshoot at that point.
Any ideas ?
You have apache2 installed. Try running this instead:
sudo service apache2 restart
I tried installing LAMP on WSL too. But I was lucky. I followed these steps:
Step 1: Update and Upgrade the ubuntu subsystem
sudo apt-get update && sudo apt-get upgrade
Step 2: Start bash.exe type:
sudo apt-get install lamp-server^
remember the caret (^) at the end of the command.
add these 2 lines in /etc/apache2/apache2.conf :
Servername localhost
AcceptFilter http none
then you can start apache :
/etc/init.d/apache2 start
Step 3: Test Web Server, PHP and MySQL
Test Apache: Open Web Browser and type this URL:
http://127.0.0.1 or http://localhost
Test PHP: Create below file (info.php) and place it in /var/www/html
<?php
phpinfo();
?>
Open Web Browser and type this URL:
http://127.0.0.1/info.php or http://localhost/info.php
Test MySQL: Type below command in bash prompt
service mysql start
mysql -uroot -ppassword
Hope it works for you.
I am using ubnutu server in atlantic vps. I have installed lamp stack and all the required configuration for php. I have installed curl and it is also enabled. in php.ini allow_url_fopen = On; ; but it still not working.
You need to install the php cURL extension by logging into the command line of your vps and entering the following command...
sudo apt-get install php5-curl
You then need to restart the server using the command
sudo service apache2 restart
If you are using php-fpm you will need to restart php5-fpm instead using the command
sudo service php5-ftp restart
cURL is the better option anyway as it isn't affected by security configurations in PHP such as forbidden fopen of remote URI's etc.
I recently discovered NginX, and decided to try it out on my server. I have NginX running and able to serve PHP and HTML files. But now I want to try to install drupal. When trying to install it and check the requirements, I am stopped by one requirement.
PHP extensions Disabled
Drupal requires you to enable the PHP extensions in the following list (see the system requirements page for more information):
gd
I have tried to install gd by doing apt-get install php5-gd, and it says it is already installed. So I created a phpinfo() file, and checked to see if gd was enabled and I wasn't able to find it. Does this have to do with NginX or PHP? What do I do to fix this?
Since you are using Nginx - that must mean you are running PHP with PHP-FPM.
After you install stuff you need to:
sudo /etc/init.d/php-fpm restart
or
service php5-fpm restart
in newer ubuntu versions
so that PHP will pickup the new extensions.
If your web server setup is in order, only install the php gd extension and restart php scripting interpreter and web server.
sudo apt-get install php5-gd
sudo /etc/init.d/php-fastcgi stop
sudo /etc/init.d/php-fastcgi start
sudo /etc/init.d/nginx stop
sudo /etc/init.d/nginx start
Here's a great LEMP tutorial http://library.linode.com/web-servers/nginx/php-fastcgi/ubuntu-10.04-lucid
For future me if I forget this.
If you've been messing around with /etc/php/fpm then you may have accidentally lost the symlink to conf.d which means the gd and PDO load files won't be booted with FPM.
This will be an issue if you're just using the basic config that comes with PHP5-FPM. If you have a custom config you may included the files in a different place.
Solution: Recreate the sym-link.
cd /etc/php5/fpm
sudo ln -s /etc/php5/conf.d /etc/php5/fpm/conf.d
PHP extensions have only to do with PHP. Your choice of webserver (apache, nginx, etc) do not affect them. Most likely you just need to enable the gd extension. If you are on Ubuntu, check /etc/php5/conf.d folder and add a gd.ini with the following line:
extension=gd.so
if you are using centos 7 and you can't find /etc/init.d/php-fpm, you may try systemctl restart php-fpm, that worked for me.
I encountered the same problem with making sudo apt-get install php5-gd to work. Console output suggested to do sudo apt-get update. Just basic updating on all your packages.
After updating, I run sudo apt-get instal php5-gd and it did all heavy lifting for me, including restarting php5-fpm and correctly installing everything in between.
When I try to run something on Netbeans using Ubuntu, a window opens but nothing actually works. I'm pretty sure it's because my http://localhost/ isn't working. So, how do I get that to work so I run files on Netbeans? Any specific step-by-step instructions would be great. I heard I had to install Apache, but I'm not sure.
If you want to run PHP stuff outside NetBeans, there are several steps you have to take:
Install apache web server - sudo apt-get install apache2
Install PHP and connect it with apache - sudo apt-get install php5 sudo apt-get install libapache2-mod-php5
Restart apache - sudo /etc/init.d/apache2 restart
Now, your Document Root (web root) should be at /var/www.
Place your files there and access them with http://localhost/desired_file.php with some web browser or just execute them with php compiler on the command line.
Depending on your distro/version, there might be some configurations to be done, but that's the basic stuff you need to run PHP outside NetBeans