Next Spaceship

Driving into future...

Set Up a Server Environment on Arch

| Comments

This article is about how to set up a PHP production environment on Arch system.

First, install php:

1
$sudo pacman –Syu php php-fpm php-memcache php-memcached php-pear php-curl

Configure php:

$sudo emacs /etc/php/php.ini
--------------------------------------------------
open_basedir = /srv/http:/:/home/:/tmp/:/Something else/
...
extension=curl.so
extension=json.so
extension=mysql.so
extension=zip.so
extension=memcache.so
extension=memcached.so
extension=mongo.so
...
date.timezone = Asia/Shanghai

Second, install mongodb and mysql:

1
2
$sudo pacman –Syu mongodb mysql
$sudo pecl install mongo

Reset mysql password:

1
$mysqladmin -u root -p password 'NEW_PASSWORD'

Start mongodb:

1
$sudo rc.d start mongodb

Start mysqld:

1
$sudo rc.d start mysqld

Add mongodb to auto-start list on boot:

1
$sudo emacs /etc/rc.conf

and add mongodb and mysqld to the DAEMONS variable:

DAEMONS=(syslog-ng network … mongodb mysqld)

Third, install nginx:

1
$sudo pacman –Syu nginx

Configure nginx:

1
$sudo emacs /etc/nginx/conf/nginx.conf

Start nginx:

1
$sudo rc.d start nginx

and add nginxto auto-start list:

$sudo emacs /etc/rc.conf
---------------------------------------------------
DAEMONS=(syslog-ng network ... nginx)

Configure php-fpm:

$sudo emacs /etc/php/php-fpm.conf
----------------------------------------------------
listen = 127.0.0.1:9000
;listen = /var/run/php-fpm/php-fpm.sock

Start php-fpm:

1
$sudo rc.d start php-fpm

To add php-fpm to auto-start list:

$sudo emacs /etc/rc.conf
---------------------------------------------------
DAEMONS=(syslog-ng network ... php-fpm)

Then, install some others:

1
$sudo pacman –Syu memcached mercurial autoconf

Start memcached:

1
$sudo rc.d start memcached

and add memcached to auto-start list:

$sudo emacs /etc/rc.conf
------------------------------------------
DAEMONS=(syslog-ng network ... memcached)

You can add some memcache:

$sudo emacs /etc/rc.local
------------------------------
/usr/bin/memcached -d -m 256 -p 11211 -u nobody -l 127.0.0.1
/usr/bin/memcached -d -m 64 -p 11220 -u nobody -l 127.0.0.1
/usr/bin/memcached -d -m 1024 -p 11300 -u nobody -l 127.0.0.1

Comments