CentOS7 httpd MySQL PHP memcached SElinux

/omg

CentOS7 minimal

httpd
# yum install httpd
# systemctl start httpd.service
# systemctl enable httpd.service

firewalld
# firewall-cmd –zone=public –add-service=http –permanent
# firewall-cmd –zone=public –add-service=https –permanent
# firewall-cmd –reload

mariadb
# yum install mariadb-server mariadb
# systemctl start mariadb.service
# systemctl enable mariadb.service
# mysql_secure_installation

php
# yum install php php-mysql php-gd php-pear php-mbstring php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-snmp php-soap curl curl-devel
# chcon -R -t httpd_sys_content_t /home/sourcode/domains/sourcode.net/public_html
# systemctl restart httpd.service

memcached
# yum install php-pecl-memcached memcached
# vi /etc/httpd/conf.d/php.conf

#
# Apache specific PHP configuration options
# those can be override in each configured vhost
#
# php_value session.save_handler "files"
# php_value session.save_path "/var/lib/php/session"
php_value session.save_handler "memcached"
php_value session.save_path "127.0.0.1:11211"

# setsebool -P httpd_can_network_memcache 1
# getsebool httpd_can_network_memcache

# vi /etc/httpd/conf.d/sourcode.conf

</VirtualHost *:80>
ServerAdmin admin@sourcode.net
DocumentRoot "/home/sourcode/domains/sourcode.net/public_html"
<Directory "/home/sourcode/domains/sourcode.net/public_html">
Require all granted
</Directory> 
ServerName sourcode.net
ServerAlias www.sourcode.net
ErrorLog “/var/log/httpd/sourcode.net/error_log”
CustomLog “/var/log/httpd/sourcode.net/access_log” common
<VirtualHost>

# end

apache 2.4.1

# aptitude install libapr1-dev uuid-dev libaprutil1-dev libmysqlclient15-dev libpq-dev libsqlite3-dev rcconf build-essential -y
# wget http://mirrors.issp.co.th/apache//httpd/httpd-2.4.1.tar.gz
tar -xvf httpd-2.4.1.tar.gz
# cd httpd-2.4.1/
# ./configure
# make
# make install

## Script start|stop|restart

#!/bin/bash
# description: apache2 httpd 2.4.1 server
# Start the service httpd
start() {
/usr/local/apache2/bin/httpd &
echo “Up and running”
}
# Restart the service httpd
stop() {
killall httpd
echo “Killing httpd”
}
### main logic ###
case “$1″ in
start)
start
;;
stop)
stop
;;
*)
echo $”Usage: $0 {start|stop}”
exit 1
esac
exit 0

แต่..​ถ้าเป็น lenny หรือ centos5 จะเจอเหตุการณ์แบบนี้!!

configure: error: APR version 1.3.0 or later is required

แก้โดยการ
CentOS
yum remove apr-util-devel apr apr-util-mysql apr-docs apr-devel apr-util apr-util-docs
yum install expat
yum remove apr-util-devel apr apr-util-mysql apr-docs apr-devel apr-u

Debian
aptitude install build-essential

Debian/CentOS
cd /usr/src
wget http://mirrors.issp.co.th/apache//apr/apr-1.4.6.tar.gz
tar xzvf apr-1.4.2.tar.gz
cd apr-1.4.2
./configure –prefix=/usr/local/apr
make
make install

cd /usr/src
wget http://mirrors.issp.co.th/apache//apr/apr-util-1.4.1.tar.gz
tar xzvf apr-util-1.4.1.tar.gz
cd apr-util-1.4.1
./configure –prefix=/usr/local/apr-util –with-apr=/usr/local/apr
make
make install

cd /usr/src
wget http://mirrors.issp.co.th/apache//apr/apr-iconv-1.2.1.tar.gz
tar xzvf apr-iconv-1.2.1.tar.gz
cd apr-iconv-1.2.1
./configure –with-apr=/usr/local/apr
make
make install

cd /usr/src/
wget http://mirrors.issp.co.th/apache//httpd/httpd-2.4.1.tar.gz
tar xzvf httpd-2.4.1.tar.gz
cd httpd-2.4.1
./configure \
–prefix=/usr/local/apache2 \
–enable-mods-shared=all \
–enable-so \
–enable-rewrite \
–enable-cache \
–enable-file-cache \
–enable-mem-cache \
–enable-disk-cache \
–enable-static-support \
–enable-static-htpasswd \
–enable-static-htdigest \
–enable-static-rotatelogs \
–enable-static-logresolve \
–enable-static-htdbm \
–enable-static-ab \
–enable-static-checkgid \
–enable-cgid \
–with-apr=/usr/local/apr/ \
–with-apr-util=/usr/local/apr/ \
–enable-cgi \
–with-expat=builtin \
–enable-ssl \

# make
# make install

# nano /etc/init.d/httpd

#!/bin/bash
# description: apache2 httpd 2.4.1 server
# Start the service httpd
start() {
/usr/local/apache2/bin/httpd &
echo “Up and running”
}
# Restart the service httpd
stop() {
killall httpd
echo “Killing httpd”
}
### main logic ###
case “$1″ in
start)
start
;;
stop)
stop
;;
*)
echo $”Usage: $0 {start|stop}”
exit 1
esac
exit 0

# /etc/init.d/httpd start

source:
http://hi.baidu.com/taiyangx/blog/item/944c9c583f730797810a18d5.html
http://verahill.blogspot.com/2012/02/debian-testing-wheezy-64-building_23.html
http://www.debian-tutorials.com/mysql/how-to-install-apache2-4-php5-and-mysql-from-source-on-debian-linux

apache2 over centos and ubuntu

CentOS
2.6.24-22-xen

$ ab -n 1000 -c 100 http://192.168.1.50/
This is ApacheBench, Version 2.0.40-dev <$Revision: 1.146 $> apache-2.0
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright 2006 The Apache Software Foundation, http://www.apache.org/

Benchmarking 192.168.1.50 (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Finished 1000 requests

Server Software: Apache/2.2.3
Server Hostname: 192.168.1.50
Server Port: 80

Document Path: /
Document Length: 5043 bytes

Concurrency Level: 100
Time taken for tests: 2.92797 seconds
Complete requests: 1000
Failed requests: 0
Write errors: 0
Non-2xx responses: 1000
Total transferred: 5240000 bytes
HTML transferred: 5043000 bytes
Requests per second: 477.83 [#/sec] (mean)
Time per request: 209.280 [ms] (mean)
Time per request: 2.093 [ms] (mean, across all concurrent requests)
Transfer rate: 2445.05 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.4 0 7
Processing: 1 2 11.4 1 208
Waiting: 0 1 11.3 1 207
Total: 1 2 11.4 1 208

Percentage of the requests served within a certain time (ms)
50% 1
66% 2
75% 2
80% 2
90% 2
95% 2
98% 3
99% 4
100% 208 (longest request)

Ubuntu
2.6.24-22-xen

$ ab -n 1000 -c 100 http://192.168.1.51/
This is ApacheBench, Version 2.0.40-dev <$Revision: 1.146 $> apache-2.0
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright 2006 The Apache Software Foundation, http://www.apache.org/

Benchmarking 192.168.1.51 (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Finished 1000 requests

Server Software: Apache/2.2.8
Server Hostname: 192.168.1.51
Server Port: 80

Document Path: /
Document Length: 5043 bytes

Concurrency Level: 100
Time taken for tests: 0.750044 seconds
Complete requests: 1000
Failed requests: 0
Write errors: 0
Total transferred: 5297000 bytes
HTML transferred: 5043000 bytes
Requests per second: 1333.26 [#/sec] (mean)
Time per request: 75.004 [ms] (mean)
Time per request: 0.750 [ms] (mean, across all concurrent requests)
Transfer rate: 6895.60 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 7 5.6 7 30
Processing: 2 40 104.1 12 694
Waiting: 1 39 104.1 11 693
Total: 2 47 104.2 21 706

Percentage of the requests served within a certain time (ms)
50% 21
66% 25
75% 29
80% 32
90% 45
95% 257
98% 285
99% 698
100% 706 (longest request)

Requests per second:
CentOS

731.19 [#/sec]
740.07 [#/sec]
810.05 [#/sec]
852.98 [#/sec]
746.45 [#/sec]

Ubuntu

1018.12 [#/sec]
1355.45 [#/sec]
1169.16 [#/sec]
1391.87 [#/sec]
1371.14 [#/sec]