*** DISCLAIMER: All content provided here including the scripts is provided without any warranty. You use it at your own risk. I can not be held responsible for any damage that may occur because of it. By using the scripts I provide here you accept this terms.
*** Please bear in mind that this method is intended for development and testing purposes only. If you care about stability and security you should use the packages provided by your distribution.
An unattended script that installs everything can be found at GitHub. Check the README file for instructions on how to run the installer.
If you found this useful and you want to contribute, please consider sending a donation (click the button below).
In this tutorial I will compile the latest NginX (1.3.0) and PHP (5.4.3) with FPM, MySQL and APC (3.1.10) on Ubuntu Precise (12.04). For the moment, Suhosin 0.9.33 is not working with PHP 5.4.x. Apart for some version numbers for some dependencies, all the steps should be the similar for Ubuntu Lucid, Maverick, Natty and Oneiric.
I will not explain how to configure NginX here. You can find a lot of resources about that on the nginx wiki.
In order to compile these programs you will need the following dependencies (most of them should already be installed):
And also some libraries for PHP:
Now let's create a folder in which we can play:
and start downloading the sources:
You can visit each site in order to find faster mirrors. Now decompress them:
And now let's install them one by one. I like to put everything I compile by myself in one place, the /opt directory. By doing this I know where to find things like configuration files and libraries.
./configure \
--prefix=/opt/nginx \
--conf-path=/etc/nginx/nginx.conf \
--pid-path=/var/run/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--http-log-path=/var/log/nginx/access.log \
--error-log-path=/var/log/nginx/error.log \
--http-client-body-temp-path=/var/lib/nginx/body \
--http-proxy-temp-path=/var/lib/nginx/proxy \
--http-fastcgi-temp-path=/var/lib/nginx/fastcgi \
--http-uwsgi-temp-path=/var/lib/nginx/uwsgi \
--http-scgi-temp-path=/var/lib/nginx/scgi \
--with-http_stub_status_module \
--with-http_ssl_module \
--with-http_realip_module \
--with-http_gzip_static_module \
--user=www-data \
--group=www-data \
--without-mail_pop3_module \
--without-mail_imap_module \
--without-mail_smtp_module
make
sudo make install
You sould also create the file /etc/logrotate.d/nginx in order to compress the logs.
sudo vi /etc/logrotate.d/nginx
And add the following lines:
You can also find a very simple configuration for nginx at https://github.com/vladgh/VladGh.com/blob/master/nginx.conf
Starting with Ubuntu 11.04 the canonical team modified the path for some libraries so you might need to run the following set of commands:
Now let's compile the PHP packages:
./buildconf --force
./configure \
--prefix=/opt/php5 \
--with-config-file-path=/etc/php5 \
--with-config-file-scan-dir=/etc/php5/conf.d \
--with-curl \
--with-pear \
--with-gd \
--with-jpeg-dir \
--with-png-dir \
--with-zlib \
--with-xpm-dir \
--with-freetype-dir \
--with-t1lib \
--with-mcrypt \
--with-mhash \
--with-mysql \
--with-mysqli \
--with-pdo-mysql \
--with-openssl \
--with-xmlrpc \
--with-xsl \
--with-bz2 \
--with-gettext \
--with-fpm-user=www-data \
--with-fpm-group=www-data \
--disable-debug \
--enable-fpm \
--enable-exif \
--enable-wddx \
--enable-zip \
--enable-bcmath \
--enable-calendar \
--enable-ftp \
--enable-mbstring \
--enable-soap \
--enable-sockets \
--enable-sqlite-utf8 \
--enable-shmop \
--enable-dba \
--enable-sysvsem \
--enable-sysvshm \
--enable-sysvmsg
make
sudo make install
Because the executables are not in a standard location you can add the following lines to /etc/environment so that the new path is always loaded:
The next step is to configure PHP-FPM:
If you installed these somewhere custom like me you should also modify the init file for php-fpm (/etc/init.d/php-fpm):
Also, make the desired modifications to /opt/php5/etc/php-fpm.conf file. Pay attention to the pid file, socket, and dynamic processes. A sample conf file can be found here.
The newer versions of php complain if a time zone is not set on php.ini (so we grab the system's one)
Create /etc/logrotate.d/php-fpm with the following:
Now let's install the latest APC:
You will have to add the extension in php.ini:
sudo echo 'extension = apc.so
apc.enabled = 1
apc.shm_size = 128M
apc.shm_segments=1
apc.write_lock = 1
apc.rfc1867 = On
apc.ttl=7200
apc.user_ttl=7200
apc.num_files_hint=1024
apc.mmap_file_mask=/tmp/apc.XXXXXX
apc.enable_cli=1
; Optional, for "[apc-warning] Potential cache slam averted for key... errors"
; apc.slam_defense = Off
' > /etc/php5/conf.d/apc.ini
This is it! You can now start the servers:
If you want a MySQL server installed you can run the following command.
apt-get install mysql-server mysql-client
This should be enough to get MySQL up and running. If you have a separate database somewhere you can only install the mysql-client package. For additional config parameters look into the /usr/share/doc/mysql-server-5.1/examples folder and you will find a few configurations. You can also get the MySQLTuner.pl script which will give a lot more information on how to fine tune your mysql server:
wget mysqltuner.pl
You should now have a fully functional LEMP platform.
An unattended script that installs everything can be found at GitHub. Check the README file for instructions on how to run the installer.
If you found this useful and you want to contribute, please consider sending a donation (click the button below).
Comments
Thank you
Thank you for your feedback! Memcached is indeed on the todo list for this script. Most likely it will become an optional addition, in the "ext" folder, just to keep the script simpler and more efficient.
Nginx 1.0.1.2 / PHP 5.3.10
How to choose nginx stable?
oh nevermind I didn't see the
DNS
DNS
I wouldn't recommend using your own DNS. There are many cheap services out there (ex: AWS Route53). From the past experience I liked NSD from NLnet Labs.
git problem
GIT
You should probably use:
sudo apt-get install git-core screensendmail not working
Postfix
You should take a look at installing postfix as a null client: http://www.postfix.org/STANDARD_CONFIGURATION_README.html#null_client. This is the minimal configuration.
Pages
Add new comment