I’ve been developing web apps with LAMP, the Apache is on my hard drive, wasn’t using virtual hosts, just a simlink to the htdocs folder. Everything was fast and good.
Then I’ve started playing with Laravel for some time, virtual box, vagrant, virtual hosts etc. Laravel seemed pretty fast, maybe because I haven’t made heavy DBs.
Now I went back to my localhost and find it extreeeeeeemly slow. It takes about 10 s to load any page from my local site which used to load in 1-2 s before. I thought it might be something to do with the virtual hosts and all. So I’ve removed them all, I’ve even reinstalled Apache and PHP, I’ve deleted ALL settings and configs, removed all rewrites etc. - same thing, the server is very slow. I tried the sites in Chromium - same slow.
I have not touched any MySql settings or configs ever, so it should not be the cause.
Would you have any ideas what might have caused this and how I can fix this?
First,
You might reboot and see if that improves performance.
You can also run top and free to monitor system resource usage.
You should also know that Apache, particularly as part of a LAMP configuration can require tuning.
A lot will depend on the type of website code you’re running.
If you’re running a website that serves non-interactive content, a script-based webserver like nginx, or many from your choice of coding (nodejs, ruby, python, etc) can perform better and might not require any tuning.
There’s a ton of articles written about Apache tuning, and there are many tools that can test various settings.
Bottom line,
This is a topic that’s hard to discuss in a Forum.
Every situation is individual to the hardware you’re running on, other software running and your website.
Troubleshooting SOP should be same as everything else,
Try to narrow down your problem bit by bit which is why I suggest the reboot and system monitoring to start… try to first determine if something in your system other than your LAMP might be the cause before you start looking at your webserver/website itself.
That’s exactly the reason why I wrote here because I’ve exhausted all other options, i.e. rebooting, reinstalling, tuning and all. I’m basically running a fresh install of LAMP here but it’s still slow.
As I said, everything was running fast and ok a few weeks ago.
I’m wondering what might have caused it to run much slower with the exactly same code (I haven’t touched any of the server files, as I said I was playing with Laravel from my home folder and virtual hosts, the site file remain in the htdocs unchanged). Because it’s never happened before on Linux. I haven’t had a single problem with openSuse for years, this post is like the first one in 5 years. That’s why I’m so puzzled.
It may not even be LAMP, maybe something else on Linux. What should I check for?
I’ve checked the memory usage, it’s got a few mysql, 6 Web processes, a dozen of httpd-prefork - are these quantities normal? WebExtensions take >300,000 K. I have 16 GB of RAM though.
I’ve disabled all desktop search stuff and cleared everything with the Sweeper. It improved the server speed a lot, now a simple page loads in 5 sec vs > 10 sec before. But this is still not enough, still too long. The pages opened within a second or two before. Something else is still interfering or slowing it down.
Reading what deano_ferrari](https://forums.opensuse.org/member.php/122-deano_ferrari) posted, they say “This MPM is not suitable for use with non-thread-safe modules like mod_php, for which a replacement such a PHP-FPM must be used instead”. I have the prefork module installed, the other two (worker and event) are not installed, and I’m using the mod-php. Could this be the problem? Should I uninstall the mpm and install either the worker or event? Or can I have all 3 installed? PHP-FPM i snot installed either. What’s the best combination of modules with Apache and PHP for my local dev machine (not production server)?
I have seen similar messages and fixed /etc/hosts:
erlangen:~ # cat /etc/hosts
#
# hosts This file describes a number of hostname-to-address
# mappings for the TCP/IP subsystem. It is mostly
# used at boot time, when no name servers are running.
# On small systems, this file can be used instead of a
# "named" name server.
# Syntax:
#
# IP-Address Full-Qualified-Hostname Short-Hostname
#
# special IPv6 addresses
127.0.0.1 localhost
::1 localhost ipv6-localhost ipv6-loopback
fe00::0 ipv6-localnet
ff00::0 ipv6-mcastprefix
ff02::1 ipv6-allnodes
ff02::2 ipv6-allrouters
ff02::3 ipv6-allhosts
**192.168.178.2 erlangen.fritz.box erlangen
192.168.178.3 erlangen.fritz.box erlangen**
erlangen:~ #
erlangen:~ # grep MODULES /etc/sysconfig/apache2
# * In the APACHE_MODULES variable, you can use mod_xyz or just xyz syntax.
# APACHE_MODULES="authz_host alias auth dir log_config mime setenvif"
# APACHE_MODULES="authz_host actions alias asis auth autoindex cgi dir imap include log_config mime negotiation setenvif status userdir"
APACHE_MODULES="actions alias auth_basic authn_core authn_file authz_host authz_groupfile authz_core authz_user autoindex cgi dir env expires include log_config mime negotiation setenvif ssl socache_shmcb userdir reqtimeout"
erlangen:~ #
You may want to do a clean reinstall starting with removing everything:
erlangen:~ # zypper rm --clean-deps --type pattern lamp_server
Reading installed packages...
Resolving package dependencies...
The following 21 packages are going to be REMOVED:
apache2 apache2-doc apache2-example-pages apache2-mod_php7 apache2-prefork apache2-utils git-web patterns-server-lamp_server perl-CGI php7 php7-ctype php7-dom php7-iconv php7-json php7-pdo php7-sqlite php7-tokenizer php7-xmlreader
php7-xmlwriter system-user-wwwrun yast2-http-server
The following pattern is going to be REMOVED:
lamp_server
21 packages to remove.
After the operation, 52.3 MiB will be freed.
Continue? [y/n/v/...? shows all options] (y): n
erlangen:~ #
I’m getting close. I forgot I made a new /etc/php7/fpm/php-fpm.d/www.conf following that Howto where is says it’s listening for 127.0.0.1:9000. When I change it to port 80, it fails with: “unable to bind listening socket for address ‘127.0.0.1:80’: Address already in use”
I got it! FFS, I finally got it to work after 3 hours… It’s faster but still nothing like it used to be. Anyway, here are the steps if anyone find themselves in a similar situation or just want to change the mod:
In /usr/sbin/ create (overwrite) new link ‘httpd’ for either httpd2-worker or httpd2-event
Change the line in /etc/apache2/conf.d/mod_fcgid.conf:
SetHandler “proxy:fcgi://localhost:9000/” <- the server and host must match those in /etc/php7/fpm/php-fpm.d/www.conf