Install nginx + php + memcached + mariadb in ubuntu

Source: Internet
Author: User
1. apt-get installation 1. Install nginxsudoapt-getinstallnginx. All the configuration files are under etcng.pdf, the VM is configured in etcnginxsites-available. The program file in usrsbinnginx logs is placed in varlognginx and is already in etcinit. d. The default virtual master of the startup script nginx is created.

1. install apt-get 1. install nginx sudo apt-get install nginx. All the configuration files of nginx are under/etc/nginx, the VM is configured with the program file in/etc/nginx/sites-available and stored in/usr/sbin/nginx logs in/var/log/nginx and in/etc/init. d/, the default virtual master with the startup script nginx is created.

1. apt-get Installation

1. Install nginx

sudo apt-get install nginx

All configuration files are in/etc/nginx, and the virtual host is configured in/etc/nginx/sites-available.

Program file in/usr/sbin/nginx

Logs are stored in/var/log/nginx.

The Startup Script nginx has been created under/etc/init. d /.

The default virtual host directory is/var/www/nginx-default.

Start nginx

sudo /etc/init.d/nginx startsudo /etc/init.d/nginx reload

2. install php

Fpm

sudo apt-get install php5-fpm
/etc/init.d/php5-fpm start

Fcor Gi

sudo apt-get install php5-cli php5-cgi php5-mysql

3. InstallFastCgi

 apt-get install php5-cgi

You can also install spawn-fcgi. spawn-fcgi is the fastcgi Management Program, which is a project independent of Lighthttpd. In actual operation, you can use php-fpm (fastcgi php manager of php). php 5.3.3 to bring php-fpm, but my current version is php 5.3.2.

Run with spawn-fcgi

sudo /usr/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -C 5 -u www-data -g www-data -f /usr/bin/php5-cgi -P /var/run/fastcgi-php.pid

Parameter meaning:

*-F specifies the location of the execution program of the process that calls FastCGI, set *-a to bind to the address addr *-p to the port *-s to bind to the path *-C of the unix socket according to the PHP installed on the system. fastCGI process count, the default value is 5 (for PHP only) *-P, which specifies the PID file path of the generated process *-u and-g FastCGI (-u user-g user group, www-data can be used in Ubuntu. Other configurations, such as nobody and apache, can be used as needed.

Restart fcgi

Php-cgi: First kill the process

sudo killall -HUP php5-cgi

Restart fcgi

4. Configure nginx to support php

Modify the nginx configuration file:/etc/nginx/sites-available/default modify the Host Name:

server_name localhost;

Modify the row of index:

index index.php index.html index.htm;

Remove the following comments to support php scripts:

location ~ \.php$ {    fastcgi_pass 127.0.0.1:9000; #    fastcgi_index index.php;    fastcgi_param SCRIPT_FILENAME /var/www/nginx-default$fastcgi_script_name;    include /etc/nginx/fastcgi_params;}

Restart nginx:

/etc/init.d/nginx stop/etc/init.d/nginx start

Start fastcgi php:

sudo /usr/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -C 5 -u www-data -g www-data -f /usr/bin/php5-cgi -P /var/run/fastcgi-php.pid

6. Install the memcached server.

sudo apt-get install memcached

Start memcached Service

memcached -d -m 128 -p 11111 -u root

Parameter description:

-P listening port-l connection IP address, the default value is local-d start to start memcached service-d restart to restart memcached service-d stop | shutdown to disable the running memcached service-d install to install memcached service-d uninstall to uninstall memcached service-u run as (only valid when running as root) -MB maximum memory usage, in MB. By default, an error is returned when 64MB-M memory is used up, instead of deleting the maximum number of concurrent connections in item-c. The default value is 1024-f, and the default value is 1.25-n, key + value + flags are 48-H display help by default

Check whether the service is started

ps aux | grep memcached

  

7. Install the memcached php extension.

sudo apt-get install php5-memcached

After the installation is complete, restart nginx and fcgi to make memcached take effect.

References:

Http://www.gaojinbo.com/ubuntu12-04-apt-get-install-php5-5%E5% AE %89%E8%A3%85.html

8 install mariadb

sudo apt-get install mariadb-server/etc/init.d/mysql start

Ii. source code compilation method

1. Prepare the compiling environment

apt-get install build-essential

2. Download the php source code.

cd /usr/local/srcwget http://cn2.php.net/distributions/php-5.5.13.tar.gzsudo tar -zxvf php-5.5.13.tar.gzcd php-5.5.13./configure --prefix=/etc/php-5.5.13 --without-pear --with-config-file-path=/etc/php-5.5.13/etc/ --enable-shared=yes --with-zlib-dir=/usr/local/lib --with-pcre-dir=/usr/local/lib --enable-zip --enable-mysqlnd --with-libxml-dir=/usr/local/lib --with-iconv-dir=/usr/local/lib --enable-sockets --enable-soap --enable-opcache --enable-embedded-mysqli --with-mysqli --with-mysql --with-mcrypt=/usr/local/lib --enable-mbstring --with-mhash --enable-gd-native-ttf --with-freetype-dir=/usr/local/lib --with-png-dir --with-jpeg-dir=/usr/local/lib --with-gd --enable-fpm --with-fpm-user=www-data --with-fpm-group=www-data --enable-ftp --enable-dba --with-curlmakemake install

The first configure will appear

configure: error: mcrypt.h not found. Please reinstall libmcrypt.

This is due to copyright. The mcrypt package is not included and must be installed first:

cd /usr/local/srcwget http://softlayer.dl.sourceforge.net/sourceforge/mcrypt/libmcrypt-2.5.8.tar.gztar -zxvf libmcrypt-2.5.8.tar.gzcd /usr/local/src/libmcrypt-2.5.8./configure --prefix=/usr/localmakemake install 

For more information about how to handle missing dependent packages during other installation processes, see: http://zgadzaj.com/how-to-install-php-53-and-52-together-on-ubuntu-1204

If the compiling environment is not installed, the following error occurs:

root@ubuntu:/usr/local/src/libmcrypt-2.5.8# ./configure --prefix=/usr/localchecking build system type... x86_64-unknown-linux-gnuchecking host system type... x86_64-unknown-linux-gnuchecking target system type... x86_64-unknown-linux-gnuchecking for a BSD-compatible install... /usr/bin/install -cchecking whether build environment is sane... yeschecking for gawk... nochecking for mawk... mawkchecking whether make sets $(MAKE)... yeschecking whether to enable maintainer-specific portions of Makefiles... nochecking whether make sets $(MAKE)... (cached) yeschecking for g++... nochecking for c++... nochecking for gpp... nochecking for aCC... nochecking for CC... nochecking for cxx... nochecking for cc++... nochecking for cl... nochecking for FCC... nochecking for KCC... nochecking for RCC... nochecking for xlC_r... nochecking for xlC... nochecking for C++ compiler default output file name... configure: error: C++ compiler cannot create executablesSee `config.log' for more details.

Copy the php. ini file:

root@ubuntu:/etc/php-5.5.13/etc# cp /usr/local/src/php-5.5.13/php.ini-development php.ini

Start php-fpm on startup and run php-fpm:

/Usr/local/src/php-5.5.13 is the source code path.

root@ubuntu:/usr/local/src/php-5.5.13/sapi/fpm# cp php-fpm /etc/init.d/root@ubuntu:/etc/php-5.5.13/etc# cp php-fpm.conf.default php-fpm.confroot@ubuntu:/etc/php-5.5.13/etc# /etc/init.d/php-fpm root@ubuntu:/etc/php-5.5.13/etc# ps aux|grep fpmroot      3565  0.0  0.0 130124  4980 ?        Ss   16:25   0:00 php-fpm: master process (/etc/php-5.5.13/etc/php-fpm.conf)www-data  3566  0.0  0.0 130124  4280 ?        S    16:25   0:00 php-fpm: pool www  www-data  3567  0.0  0.0 130124  4280 ?        S    16:25   0:00 php-fpm: pool www  root      3569  0.0  0.0  12256   940 pts/2    S+   16:25   0:00 grep --color=auto fpm

Stop fpm and kill related processes.

Re-compile php and add a -- with-openssl option, but it does not always work. Finally, the source code is deleted, and it takes effect only after the source code is decompressed and compiled.

This is the reason:

Php needs to be re-installed. However, after the make clean command is executed in the source code package, configure, make, and make install are executed. It is found that the parameters are the same as those in the previous compilation and remain unchanged. The Makefile file generated by configure has not been deleted. After checking the information, you cannot use make clean to delete files including Makefile files. Recompile.

References:

Http://asange.blog.51cto.com/7125040/1229976

Http://my.oschina.net/ruiorz/blog/280289

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.