Ubuntu-based LAMP optimization and Reinforcement

Source: Internet
Author: User
Many of my friends like to use Ubuntu. The major reason is that it is very simple to install LAMP. Although the LAMP installed by default can work well, the system administrator can still find some space for optimization and reinforcement. 1. php acceleration facts have proved that php interpretation of cache can improve php efficiency. apc, xcache, zendopcache, and other accelerators have similar principles and have similar performance. It can be confirmed that php explains cache, when used or not, the performance may differ several times or more. Apt-getinstal

Many of my friends like to use Ubuntu. The major reason is that it is very simple to install LAMP. Although the LAMP installed by default can work well, the system administrator can still find some space for optimization and reinforcement.

1. php Acceleration

Facts have proved that php interpretation of cache can improve php efficiency. The principles of apc, xcache, zendopcache, and other accelerators are similar, and the performance is not much different. It can be affirmed that php interpretation of cache, when used or not, the performance may differ several times or more.

Apt-get install php-apc

2. Simplified php5-mysql Module

By default, the php5-mysql package contains three mysql Connection Methods: mysql, pdo_mysql, and mysqli,

Although the three have their own advantages and disadvantages, you must use only one of them, usually mysql.

Cd/etc/php5/conf. d/

Mv mysqli. ini mysqli. ini. bak

Mv pdo_mysql.ini pdo_mysql.ini.bak

Mv pdo. ini pdo. ini. bak


3. Hide apache and php version information

Sed-I's/ServerTokens OS/ServerTokens Prod/G'/etc/apache2/conf. d/security

Sed-I's/ServerSignature On/ServerSignature Off/G'/etc/apache2/conf. d/security

Sed-I '/expose_php/{s/On/Off/g}'/etc/php5/apache2/php. ini


4. Install mod_security

Mod_security is a security module that can prevent multiple attacks.

Apt-get install libapache-mod-security

Cd/etc/modsecurity/

Cp modsecurity. conf-recommended modsecurity. conf

5. Set compression and browser cache

Compressing data can increase throughput, setting browser cache can reduce the number of requests, and reverse improve apache performance.

Cat/etc/apache2/httpd. conf

# Insert filter

SetOutputFilter DEFLATE

# Netscape 4.x has same problems...

BrowserMatch ^ Mozilla/4 gzip-only-text/html

# Netscape 4.06-4.08 have some more problems

BrowserMatch ^ Mozilla/4 \. 0 [678] no-gzip

# MSIE masquerades as Netscape, but it is fine

# BrowserMatch \ bMSIE! No-gzip! Gzip-only-text/html

# NOTE: Due to a bug in mod_setenvif up to Apache 2.0.48

# The above regex won't work. You can use the following

# Workaround to get the desired effect:

BrowserMatch \ bMSI [E]! No-gzip! Gzip-only-text/html

# Don't compress images and other

SetEnvIfNoCase Request_URI .(? : Gif | jpe? G | png) $ no-gzip dont-vary

SetEnvIfNoCase Request_URI .(? : Exe | t? Gz | zip | bz2 | sit | rar) $ no-gzip dont-vary

SetEnvIfNoCase Request_URI .(? : Pdf | doc) $ no-gzip dont-vary

AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css

AddOutputFilterByType DEFLATE application/x-javascript

# Make sure proxies don't deliver the wrong content

# Header append Vary User-Agent env =! Dont-vary

 

ExpiresActive On

ExpiresByType image/* "access plus 1 month"

ExpiresByType text/css "access plus 1 month"

ExpiresByType text/javascript "access plus 1 month"

ExpiresByType application/x-javascript "access plus 1 month"

Header unset Server

Header unset X-Powered-

 

Install the LAMP \ Vsftpd \ Webmin \ phpMyAdmin service and settings in Ubuntu 13.04Http://www.linuxidc.com/Linux/2013-06/86250.htm

Compile and install LAMP (Apache 2.2.44 + MySQL 5.6.10 + PHP 5.4.12) http://www.linuxidc.com/Linux/2013-03/80333p3.htm in CentOS 5.9

Source code construction of Web Server Architecture in RedHat 5.4 LAMP environment and application PHPWind http://www.linuxidc.com/Linux/2012-10/72484p2.htm

LAMP source environment to build WEB Server Linux + Apache + MySQL + PHP http://www.linuxidc.com/Linux/2013-05/84882.htm

For more information about Ubuntu, see Ubuntu special page http://www.linuxidc.com/topicnews.aspx? Tid = 2

This article permanently updates the link address: Http://www.linuxidc.com/Linux/2014-07/104092.htm

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.