Skip to content


Optimasi Apache, PHP dan MySQL

Matikan layanan Apache dan MySQL :

server# /usr/local/etc/rc.d/mysql-server stop
server# /usr/local/etc/rc.d/apache22 stop

Optimasi PHP

Hapus remark atau komentar pada file /usr/local/etc/php.ini, sehingga isi file menjadi seperti berikut :

[PHP]
engine = On
zend.ze1_compatibility_mode = Off
short_open_tag = On
asp_tags = Off
precision    =  12
y2k_compliance = On
output_buffering = Off
zlib.output_compression = Off
implicit_flush = Off
unserialize_callback_func=
serialize_precision = 100
allow_call_time_pass_reference = On
safe_mode = Off
safe_mode_gid = Off
safe_mode_include_dir =
safe_mode_exec_dir =
safe_mode_allowed_env_vars = PHP_
safe_mode_protected_env_vars = LD_LIBRARY_PATH
disable_functions =
disable_classes =
expose_php = On
max_execution_time = 30
max_input_time = 60
memory_limit = 128M
error_reporting  =  E_ALL & ~E_NOTICE
display_errors = Off
display_startup_errors = Off
log_errors = On
log_errors_max_len = 1024
ignore_repeated_errors = Off
ignore_repeated_source = Off
report_memleaks = On
track_errors = Off
error_log = "/var/log/php_error.log"
variables_order = "EGPCS"
register_globals = On
register_long_arrays = On
register_argc_argv = On
auto_globals_jit = On
post_max_size = 8M
magic_quotes_gpc = On
magic_quotes_runtime = Off
magic_quotes_sybase = Off
auto_prepend_file =
auto_append_file =
default_mimetype = "text/html"
doc_root =
user_dir =
enable_dl = On
file_uploads = On
upload_max_filesize = 8M
allow_url_fopen = On
allow_url_include = Off
default_socket_timeout = 60
[Date]
[filter]
[iconv]
[sqlite]
[xmlrpc]
[Pcre]
[Syslog]
define_syslog_variables  = Off
[mail function]
SMTP = localhost
smtp_port = 25
[SQL]
sql.safe_mode = Off
[ODBC]
odbc.allow_persistent = On
odbc.check_persistent = On
odbc.max_persistent = -1
odbc.max_links = -1
odbc.defaultlrl = 4096
odbc.defaultbinmode = 1
[MySQL]
mysql.allow_persistent = On
mysql.max_persistent = -1
mysql.max_links = -1
mysql.default_port =
mysql.default_socket =
mysql.default_host =
mysql.default_user =
mysql.default_password =
mysql.connect_timeout = 60
mysql.trace_mode = Off
[MySQLi]
mysqli.max_links = -1
mysqli.default_port = 3306
mysqli.default_socket =
mysqli.default_host =
mysqli.default_user =
mysqli.default_pw =
mysqli.reconnect = Off
[mSQL]
msql.allow_persistent = On
msql.max_persistent = -1
msql.max_links = -1
[OCI8]
[PostgresSQL]
pgsql.allow_persistent = On
pgsql.auto_reset_persistent = Off
pgsql.max_persistent = -1
pgsql.max_links = -1
pgsql.ignore_notice = 0
pgsql.log_notice = 0
[Sybase]
sybase.allow_persistent = On
sybase.max_persistent = -1
sybase.max_links = -1
sybase.min_error_severity = 10
sybase.min_message_severity = 10
sybase.compatability_mode = Off
[Sybase-CT]
sybct.allow_persistent = On
sybct.max_persistent = -1
sybct.max_links = -1
sybct.min_server_severity = 10
sybct.min_client_severity = 10
[bcmath]
bcmath.scale = 0
[browscap]
[Informix]
ifx.default_host =
ifx.default_user =
ifx.default_password =
ifx.allow_persistent = On
ifx.max_persistent = -1
ifx.max_links = -1
ifx.textasvarchar = 0
ifx.byteasvarchar = 0
ifx.charasvarchar = 0
ifx.blobinfile = 0
ifx.nullformat = 0
[Session]
session.save_handler = files
session.use_cookies = 1
session.name = PHPSESSID
session.auto_start = 0
session.cookie_lifetime = 0
session.cookie_path = /
session.cookie_domain =
session.cookie_httponly =
session.serialize_handler = php
session.gc_probability = 1
session.gc_divisor     = 100
session.gc_maxlifetime = 1440
session.bug_compat_42 = 1
session.bug_compat_warn = 1
session.referer_check =
session.entropy_length = 0
session.entropy_file =
session.cache_limiter = nocache
session.cache_expire = 180
session.use_trans_sid = 0
session.hash_function = 0
session.hash_bits_per_character = 4
url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=,fieldset="
[MSSQL]
mssql.allow_persistent = On
mssql.max_persistent = -1
mssql.max_links = -1
mssql.min_error_severity = 10
mssql.min_message_severity = 10
mssql.compatability_mode = Off
mssql.secure_connection = Off
[Assertion]
[COM]
[mbstring]
[FrontBase]
[gd]
[exif]
[Tidy]
tidy.clean_output = Off
[soap]
soap.wsdl_cache_enabled=1
soap.wsdl_cache_dir="/tmp"
soap.wsdl_cache_ttl=86400

Siapkan file log error PHP :

server# touch /var/log/php_error.log
server# chmod 666 /var/log/php_error.log


Optimasi Apache

Hapus module-module yang tidak dibutuhkan beserta remark atau komentar pada file /usr/local/etc/apache22/httpd.conf. Sehingga menjadi :

ServerRoot "/usr/local"
Listen 80
LoadModule authn_file_module libexec/apache22/mod_authn_file.so
LoadModule authz_host_module libexec/apache22/mod_authz_host.so
LoadModule auth_basic_module libexec/apache22/mod_auth_basic.so
LoadModule authz_user_module libexec/apache22/mod_authz_user.so
LoadModule deflate_module libexec/apache22/mod_deflate.so
LoadModule log_config_module libexec/apache22/mod_log_config.so
LoadModule mime_magic_module libexec/apache22/mod_mime_magic.so
LoadModule unique_id_module libexec/apache22/mod_unique_id.so
LoadModule setenvif_module libexec/apache22/mod_setenvif.so
LoadModule mime_module libexec/apache22/mod_mime.so
LoadModule cgi_module libexec/apache22/mod_cgi.so
LoadModule vhost_alias_module libexec/apache22/mod_vhost_alias.so
LoadModule dir_module libexec/apache22/mod_dir.so
LoadModule alias_module libexec/apache22/mod_alias.so
LoadModule rewrite_module libexec/apache22/mod_rewrite.so
LoadModule status_module libexec/apache22/mod_status.so
LoadModule php5_module libexec/apache22/libphp5.so
LoadModule expires_module libexec/apache22/mod_expires.so
LoadModule headers_module libexec/apache22/mod_headers.so
User nobody
Group nobody
ServerAdmin me@devilian.com
ServerName 192.168.0.100
DocumentRoot "/usr/local/www/apache22/data"

  AllowOverride None
  Order deny,allow
  Deny from all


  Options FollowSymLinks
  AllowOverride None
  Order allow,deny
  Allow from all

DirectoryIndex index.php index.html

  Order allow,deny
  Deny from all
  Satisfy All

ErrorLog "/var/log/httpd-error.log"
LogLevel warn
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
SetEnvIf Remote_Addr "127.0.0.1" dontlog
CustomLog "/var/log/httpd-access.log" combined env=!dontlog
ScriptAlias /cgi-bin/ "/usr/local/www/apache22/cgi-bin/"

  AllowOverride None
  Options None
  Order allow,deny
  Allow from all

DefaultType text/plain
TypesConfig etc/apache22/mime.types
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
Header unset ETag
FileETag None

  Header unset Last-Modified
  Header set Expires "Fri, 08 Jun 2020 00:00:00 GMT"
  Header set Cache-Control "public, no-transform"
  SetOutputFilter DEFLATE

Include etc/apache22/extra/httpd-mpm.conf
Include etc/apache22/extra/httpd-vhosts.conf
Include etc/apache22/extra/httpd-default.conf
Include etc/apache22/Includes/*.conf

Edit MPM worker file di /usr/local/etc/apache22/extra/httpd-mpm.conf :

PidFile "/var/run/httpd.pid"
LockFile "/var/log/accept.lock"
StartServers         150
MinSpareServers       25
MaxSpareServers       35
ServerLimit          435
MaxClients           435
MaxRequestsPerChild 1000

Edit Virtual Host pada file /usr/local/etc/apache22/extra/httpd-vhost.conf :

NameVirtualHost 192.168.0.100

Edit konfigurasi default pada file /usr/local/etc/apache22/extra/httpd-default.conf :

Timeout 60
KeepAlive Off
MaxKeepAliveRequests 100
KeepAliveTimeout 15
UseCanonicalName Off
AccessFileName .htaccess
ServerTokens productonly
ServerSignature Off
HostnameLookups Off

Aktifkan mod_deflate dengan membuat file /usr/local/etc/apache22/Includes/mod_deflate.conf berisi :

AddOutputFilterByType DEFLATE text/html text/plain
#Highest 9 - Lowest 1
DeflateCompressionLevel 9

#Optional
#Skip browsers with known problems
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

#Optional
#Logging
DeflateFilterNote ratio
LogFormat '"%r" %b (%{ratio}n) "%{User-agent}i"' deflate
CustomLog /var/log/deflate_log deflate

Cek konfigurasi Apache :

server# apachectl configtest

Syntax OK


Optimasi MySQL

server# ee /var/db/mysql/my.cnf

Isi file /var/db/mysql/my.cnf :

[client]
port            = 3306
socket          = /tmp/mysql.sock

[mysqld]
port            = 3306
socket          = /tmp/mysql.sock
skip-locking
key_buffer_size = 16M
max_allowed_packet = 1M
table_open_cache = 64
sort_buffer_size = 512K
net_buffer_length = 8K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M

[mysqldump]
quick
max_allowed_packet = 16M

[mysql]
no-auto-rehash

[myisamchk]
key_buffer_size = 20M
sort_buffer_size = 20M
read_buffer = 2M
write_buffer = 2M

[mysqlhotcopy]
interactive-timeout

Jalankan semua layanan dengan mengetikkan :

server# /usr/local/etc/rc.d/mysql-server start
server# /usr/local/etc/rc.d/apache22 start
Share

Posted in FreeBSD.

Tagged with , , , .

The On Demand Global Workforce - oDesk


One Response

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

  1. Yonaldi says

    saya suka dengan blog ini, terima kasih mas…beberapa postingan mas saya linking ke blog saya,..takut kelupaan URLnya hehe



Some HTML is OK

or, reply to this post via trackback.