Personal Project

Thursday, February 4, 2016

How to optimize Apache, setup Memcached and PHP on Ubuntu ?

Install and setup Apache

// Install Apache2  
sudo apt-get install apache2

// Edit Config
vim /etc/apache2/apache2.conf

<IfModule mpm_prefork_module>
StartServers       10
MinSpareServers    10
MaxSpareServers   10
ServerLimit      256
MaxClients       256
MaxRequestsPerChild 10000
</IfModule>


// check module

apachectl -V | grep -i mpm


// disable event

a2dismod mpm_prefork


// Enable Prefork

a2enmod mpm_prefork

// Restart Apache

service apache restart


Install Memcahced

// Install memcached

sudo apt-get update
sudo apt-get install php5 php5-memcache
sudo apt-get install memcached
sudo apt-get install php-pear
sudo apt-get install build-essential
sudo pecl install memcache

// restart memcached

sudo service memcached restart 

You should add "extension=memcache.so" to php.ini  and restart Apache 
 

// Check Memcache
ps aux | grep memcache 

Install PHP

sudo apt-get install php5 php5-mysql
sudo apt-get install --purge mysql-client mysql-common 

// Remove MYSQL
sudo apt-get remove --purge mysql-server mysql-client mysql-common
sudo apt-get autoremove
sudo apt-get autoclean

Solutions to common problems

Problem1:  
The mcrypt extension is missing. Please check your PHP configuration.

Solution:
sudo apt-get install php5-mcrypt
sudo apt-get install mcrypt

Problem2:  
Need CURL PHP extension to connect facebook

Solution:
sudo apt-get install curl libcurl3 libcurl3-dev php5-curl

Problem3:
Echo PHP Not Support at HTML

Solution:
vim /etc/php5/apache2/php.ini
short_open_tag = On  
service apache2 stop

service apache2 start

   
chown -R www-data /var/www/html/
chmod -R u+w /var/www/html/


No comments:

Post a Comment