Lắp đặt này đã được kiểm tra trên Ubuntu 14.04LTS nhưng cũng có thể được sử dụng cho máy chủ sản xuất Debian.
Cài đặt Gói Cơ Bản
sudo apt-get install \
build-essential \
fakeroot dh-make \
debconf execstack \
dh-modaliases \
xserver-xorg-dev \
automake \
autoconf \
libaprutil1 \
libaprutil1-dev \
libsvn-dev \
wx2.8-headers \
libwxgtk2.8-dev \
libxml2-dev \
libpcre3-dev \
libbz2-dev \
libcurl4-openssl-dev \
libjpeg-dev \
libpng12-dev \
libxpm-dev \
libfreetype6-dev \
libmysqlclient-dev \
libt1-dev \
libgd2-xpm-dev \
libgmp-dev \
libsasl2-dev \
libmhash-dev \
unixodbc-dev \
freetds-dev \
libpspell-dev \
libsnmp-dev \
libtidy-dev \
libxslt1-dev \
libmcrypt-dev \
apache2 \
apache2-threaded-dev \
libxml2 \
libaprutil1-dev \
libxml2 \
libxml2-dev \
libssl-dev \
pkg-config \
curl \
libcurl4-nss-dev \
enchant \
libenchant-dev \
libjpeg8 \
libjpeg8-dev \
libpng12-0 \
libpng12-dev \
libvpx1 \
libvpx-dev \
libfreetype6 \
libfreetype6-dev \
libt1-5 \
libt1-dev \
libgmp10 \
libgmp-dev \
libicu52 libicu-dev \
mcrypt \
libmcrypt4 \
libmcrypt-dev \
libpspell-dev \
libedit2 \
libedit-dev libsnmp30 \
libsnmp-dev \
libxslt1.1 \
libxslt1-dev
Cập nhật cho Ubuntu 15.01
sudo \
apt-get \
install \
build-essential \
fakeroot \
dh-make \
debconf \
execstack \
dh-modaliases \
xserver-xorg-dev \
automake \
autoconf \
libaprutil1 \
libaprutil1-dev \
libsvn-dev \
wx2.8-headers \
libwxgtk2.8-dev \
libxml2-dev \
libpcre3-dev \
libbz2-dev \
libcurl4-openssl-dev \
libjpeg-dev \
libpng12-dev \
libxpm-dev \
libfreetype6-dev \
libmysqlclient-dev \
libgd-dev \
libgmp-dev \
libsasl2-dev \
libmhash-dev \
unixodbc-dev \
freetds-dev \
libpspell-dev \
libsnmp-dev \
libtidy-dev \
libxslt1-dev \
libmcrypt-dev \
apache2 \
apache2-dev \
libxml2 \
libaprutil1-dev \
libxml2 \
libxml2-dev \
libssl-dev \
pkg-config \
curl \
libcurl4-openssl-dev \
enchant \
libenchant-dev \
libjpeg8 \
libjpeg8-dev \
libpng12-0 \
libpng12-dev \
libvpx-dev \
libfreetype6 \
libfreetype6-dev \
libgmp10 \
libgmp-dev \
libicu-dev \
mcrypt \
libmcryp4t \
libmcrypt-dev \
libpspell-dev \
libedit2 \
libedit-dev \
libsnmp30 \
libsnmp-dev \
libxslt1.1 \
libxslt1-dev \
postgresql-server-dev-9.4 \
postgresql-server-dev-all
Biên Dịch PHP
Chúng ta bắt đầu bằng cách tạo một liên kết tượng trưng cho một thư viện có thể bị thiếu trong quá trình biên dịch
sudo ln -s /usr/include/x86_64-linux-gnu/gmp.h /usr/include/gmp.h
On récupère les sources de PHP
sudo wget -O php-5.6.2.tar.gz http://fr2.php.net/get/php-5.6.2.tar.gz/from/this/mirror && tar xzvf php-5.6.2.tar.gz && cd php-5.6.2
Cập nhật PHP 5.6.16
sudo wget -O php-5.6.16.tar.gz http://fr2.php.net/get/php-5.6.16.tar.gz/from/this/mirror &&\
tar xzvf php-5.6.16.tar.gz &&\
cd php-5.6.16
Sau đó chúng ta biên dịch
sudo \
./configure \
--prefix=/usr/local/php \
--with-apxs2=/usr/bin/apxs2 \
--with-config-file-path=/usr/local/php/conf \
--with-config-file-scan-dir=/usr/local/php/conf.d \
--enable-debug \
--with-openssl \
--with-kerberos \
--with-zlib \
--enable-calendar \
--with-curl \
--with-enchant \
--enable-exif \
--enable-ftp \
--with-gd \
--with-jpeg-dir=/usr \
--with-png-dir=/usr \
--with-vpx-dir=/usr \
--with-freetype-dir=/usr \
--with-t1lib \
--enable-exif \
--enable-gd-native-ttf \
--enable-gd-jis-conv \
--with-gettext \
--with-gmp \
--with-mhash \
--enable-intl \
--enable-mbstring \
--with-mcrypt \
--with-mysql \
--with-mysqli \
--enable-pcntl \
--with-pdo-mysql \
--with-pdo-pgsql \
--with-pgsql \
--with-pspell \
--with-libedit \
--with-readline \
--enable-shmop \
--enable-soap \
--enable-sockets \
--enable-sysvmsg \
--enable-sysvshm \
--with-xsl \
--enable-zip \
--with-pear \
--enable-zend-signals \
--enable-maintainer-zts \
--enable-bcmath &&\
sudo make &&\
sudo make install
Cập nhật cho Ubuntu 15.01
sudo \
./configure \
--prefix=/usr/local/php \
--with-apxs2=/usr/bin/apxs2 \
--with-config-file-path=/usr/local/php/conf \
--with-config-file-scan-dir=/usr/local/php/conf.d \
--enable-debug \
--with-openssl \
--with-kerberos \
--with-zlib \
--enable-calendar \
--with-curl \
--with-enchant \
--enable-exif \
--enable-ftp \
--with-gd \
--with-jpeg-dir=/usr \
--with-png-dir=/usr \
--with-vpx-dir=/usr \
--with-freetype-dir=/usr \
--enable-exif \
--enable-gd-native-ttf \
--enable-gd-jis-conv \
--with-gettext \
--with-gmp \
--with-mhash \
--enable-intl \
--enable-mbstring \
--with-mcrypt \
--with-mysql \
--with-mysqli \
--enable-pcntl \
--with-pdo-mysql \
--with-pdo-pgsql \
--with-pgsql \
--with-pspell \
--with-libedit \
--with-readline \
--enable-shmop \
--enable-soap \
--enable-sockets \
--enable-sysvmsg \
--enable-sysvshm \
--with-xsl \
--enable-zip \
--with-pear \
--enable-zend-signals \
--enable-maintainer-zts \
--enable-bcmath &&\
sudo make && \
sudo make install
Biên Dịch suPHP
Chúng ta lấy nguồn
sudo wget -O suphp-0.7.2.tar.gz http://www.suphp.org/download/suphp-0.7.2.tar.gz &&\
sudo tar xzvf suphp-0.7.2.tar.gz &&\
cd suphp-0.7.2
Chúng ta tạo các thư mục quản lý khác nhau
sudo mkdir /etc/suphp && \
sudo mkdir /var/log/suphp
Sau đó chúng ta cần chạy một số lệnh để việc biên dịch được thực hiện đúng cách. Chúng ta sẽ sử dụng các lệnh sau
sudo libtoolize --force #provides libtool support and replaces the default libtool files
sudo aclocal #creates the aclocal.m4 file by consolidating various macro files
sudo autoheader #creates a template file of C ‘#define’ statements
sudo automake --force-missing --add-missing #generates Makefile.in files
sudo autoconf #produces shell scripts for the automatic configuration
Chúng ta đã có thể kiểm tra xem chúng ta có tất cả các công cụ trên máy để thực hiện biên dịch cuối cùng bằng cách khởi chạy các lệnh sau:
sudo libtoolize --force &&\
sudo aclocal && sudo autoheader &&\
sudo automake --force-missing --add-missing && sudo autoconf
Chúng ta tạo các liên kết tượng trưng để các tiêu đề được tìm thấy đúng cách (thông thường điều này nên hoạt động mà không cần bước này)
sudo ln -s /usr/include/apr-1.0/*.h /usr/include/apache2/
sudo autoreconf -f -i && sudo libtoolize --force && sudo aclocal && sudo autoheader && sudo automake --force-missing --add-missing && sudo autoconf && sudo ./configure --prefix=/usr --sysconfdir=/etc/suphp --with-apache-user=www-data --with-setid-mode=owner --with-apr=/usr/bin/apr-1-config --with-min-uid=33 --with-min-gid=33 --with-logfile=/var/log/suphp
Sau đó tìm tệp src/Makefile và chỉnh sửa dòng MAYBE_AP=apache thành MAYBE_AP=apache2.
Chúng ta có thể cuối cùng biên dịch.
sudo make && sudo make install
Cấu Hình suPHP
Đầu tiên chúng ta kích hoạt các mô-đun phổ biến nhất (chúng ta có thể vô hiệu hóa chúng nếu cần với "a2dismod")
sudo a2enmod rewrite
sudo a2enmod suphp
Sau đó chúng ta xóa tất cả thông tin có trong tệp conf
sudo a2enmod suphp
Bây giờ chúng ta cấu hình tệp conf suPhp
sudo vi /etc/suphp/suphp.conf
[global]
;Path to logfile
logfile=/var/log/suphp/suphp.log
;Loglevel
loglevel=info
;User Apache is running as
webserver_user=www-data
;Path all scripts have to be in
docroot=/var/www:${HOME}/public_html
;Path to chroot() to before executing script
;chroot=/mychroot
; Security options
allow_file_group_writeable=false
allow_file_others_writeable=false
allow_directory_group_writeable=false
allow_directory_others_writeable=false
;Check wheter script is within DOCUMENT_ROOT
check_vhost_docroot=true
;Send minor error messages to browser
errors_to_browser=false
;PATH environment variable
env_path="/bin:/usr/bin"
;Umask to set, specify in octal notation
umask=0077
; Minimum UID
min_uid=33
; Minimum GID
min_gid=33
[handlers]
;Handler for php-scripts
application/x-httpd-suphp-php-cgi-562="php:/usr/local/php/bin/php-cgi-5.6.2"
;Handler for CGI-scripts
x-suphp-cgi="execute:!self"
Và bước cuối cùng, chúng ta tạo một vhost cho dự án của chúng ta.
sudo vi /etc/apache2/sites-enabled/000-default.conf
<VirtualHost *:80>
ServerAdmin contact@localhost
ServerName spikly.melis.dev
DocumentRoot /var/www/spikly-hyundai/trunk/melis/front/www
DirectoryIndex index.php
<Directory /var/www/spikly-hyundai/trunk/melis/front/www>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
DirectoryIndex index.php
</Directory>
suPHP_Engine on
suPHP_ConfigPath /var/www/spikly-hyundai/php.ini
suPHP_AddHandler application/x-httpd-suphp-php-cgi-562
AddHandler application/x-httpd-suphp-php-cgi-562 .php .php3 .php4 .php5
ErrorLog /var/log/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
suPHP_UserGroup tbourdin tbourdin
CustomLog /var/log/access.log combined
</VirtualHost>