Every installation environment to go to Baidu several articles, today simply write an article, after the trouble of Baidu, this article is introduced in the Ubuntu14.04 under the LANMP Environment (apache+nginx+mysql+php), if you only want to install lamp or LNMP are universal, Take it straight away.
First, take two steps:
Each, first update the system and then install the necessary dependencies (this step provides a cushion for future extensions)
Second, install MySQL apache2 php
sudo apt-get updatesudo apt-get install build-essential gcc g++ autoconf libiconv-hook-dev Libmcrypt-dev libxml2-dev libmysqlclient-dev libcurl4-openssl-dev libjpeg8-dev libpng12-dev libfreetype6-Dev SNMP MCrypt sudo apt-get install mysql-server mysql-clientsudo apt-get Install Apache2sudo apt-get install php5 php5-common php5-mysql php5-curl php5-gd php5-intl php-pear Php5-imagick p Hp5-imap php5-mcrypt php5-memcache php5-ming php5-ps php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc Php5-xsl Php5-xcache Php5-mcrypt
Restart Apache2
sudo service apache2 restart
Ubuntu under Apache2 Virtual host configuration
cd/etc/apache2/sites-availablels000-default.conf default-ssl.confsudo CP 000-default.conf 000- Default.conf.baksudo Vim 000-default.conf
The file is modified to the following content
<virtualhost *:80> ServerAdmin [email protected] documentroot/data/www errorlog ${apache_log_dir }/error.log customlog ${apache_log_dir}/access.log combined <directory/> Options Indexes FollowSymLinks allowoverride None Require all granted </Directory> </VirtualHost>
Restart Apache2 Test Effect
sudo service apache2 restart
CD chmod 777/data/www vim info.php <?phpphpinfo ();
http://localhost/info.php on the browser
PS aux | grep apache2root 3749 0.0 0.7 568604 28152? Ss 10:05 0:00/usr/sbin/apache2-k startwww-data 3753 0.0 0.6 797128 24504? S 10:05 0:00/usr/sbin/apache2-k startwww-data 3754 0.0 0.7 574664 30756? S 10:05 0:00/usr/sbin/apache2-k startwww-data 3755 0.0 0.5 571040 22676? S 10:05 0:00/usr/sbin/apache2-k startwww-data 3756 0.0 0.4 569892 18596? S 10:05 0:00/usr/sbin/apache2-k startwww-data 3757 0.0 0.4 569884 18660? S 10:05 0:00/usr/sbin/apache2-k startwww-data 3808 0.0 0.5 570500 21040? S 10:05 0:00/usr/sbin/apache2-k startzzs 4187 0.0 0.0 15960 924 pts/0 s+ 10:53 0:00 grep--color=auto apache2
Step three, install Nginx
sudo apt-get install nginxsudo apt-get install Php5-fpmcd/etc/nginx/sites-availablesudo cp default Default.bak
Configure the Nginx to support PHP
cd/etc/nginx/sites-available sudo vim default
Nginx Host configuration (port changed to 8080, root directory and just apache2 to directory as/data/www)
server { listen 8080 default_server; #修改端口 Listen [::]:8080 default_server ipv6only=on; #修改端口 root/data/ www #修改网站根目录 index index.php index.html index.htm; #添加index. php index file # make site accessible from http://localhost/< C5/>server_name localhost; Location/{ # First attempt-serve request as file, then # as directory, then fall back to displaying a 404.
try_files $uri $uri/=404; # Uncomment to enable Naxsi in this location # include/etc/nginx/naxsi.rules } location ~ \.php$ { FA Stcgi_split_path_info ^ (. +\.php) (/.+) $; # note:you should has "cgi.fix_pathinfo = 0;" In php.ini # with php5-cgi alone: #fastcgi_pass 127.0.0.1:9000;< c18/># with php5-fpm: fastcgi_pass unix:/var/run/php5-fpm.sock; #使用套接字方式启动 fastcgi_index index.php; Include Fastcgi_params; } }
Restart the service to view the process
sudo service nginx restartsudo service php5-fpm Restartps aux | grep php-fpmroot 3803 0.0 0.6 522716 26760? Ss 10:05 0:00 php-fpm:master process (/etc/php5/fpm/php-fpm.conf) www-data 3806 0.0 0.4 751104 16396? S 10:05 0:00 php-fpm:pool www www-data 3807 0.0 0.2 522716 8432? S 10:05 0:00 php-fpm:pool www zzs 4234 0.0 0.0 15956 924 pts/0 s+ 11:06 0:00 grep--color=auto php-fpmps aux | grep nginxroot 3782 0.0 0.0 85868 1360? Ss 10:05 0:00 nginx:master process/usr/sbin/nginxwww-data 3783 0.0 0.0 86164 2032? S 10:05 0:00 nginx:worker processwww-data 3784 0.0 0.0 86164 2520? S 10:05 0:00 nginx:worker processwww-data 3785 0.0 0.0 86164 2032? S 10:05 0:00 nginx:worker processwww-data 3786 0.0 0.0 86164 1776? S 10:05 0:00 nginx:worker processzzs 4236 0.0 0.0 15956 916 pts/0 s+ 11:06 0:00 grep--color=au To
Attached Apache2 Virtual Host configuration method:
In Apache2, valid site information is stored in the/etc/apache2/sites-available/file. We can add the format of the following information to increase a valid virtual space, the default file is copied a copy of the inside of the path can be, to enable the configuration will be a soft link to the file/etc/apache2/sites-enabled/directory
Here is an example:
$ cd/etc/apache2/sites-available/$ sudo cp 000-default.conf test.conf$ mkdir/data/www/logs<virtualhost *:80> #ServerAdmin [email protected] ServerName test.com serveralias www.test.com documentroot/data/www/test errorlog/data/www/logs/ Test-error.log customlog/data/www/logs/test-access.log combined <directory/> Options Indexes FollowSymLinks allowoverride None Require all granted </Directory> </VirtualHost>
Add a soft link to the/etc/apache2/sites-enabled directory
$ sudo ln-s/etc/apache2/sites-available/test.conf/etc/apache2/sites-enabled/test.conf
$ cd/etc/apache2/sites-enabled $ ls-aldrwxr-xr-x 2 root root 4096 December 11:48./drwxr-xr-x 8 root root 4096 December 14 00:1 3.. /lrwxrwxrwx 1 root root 35 December 00:00 000-default.conf. /sites-available/000-default.conflrwxrwxrwx 1 root root 38 December 11:48 test.conf-/etc/apache2/ Sites-available/test.conf
Attention:
Viewing the FPM process is
PS aux | grep php-fpm
Restart Service is
sudo service php5-fpm restart
Do not know why the two names are not unified, it is best to use PS aux| grep fpm to view
Building LANMP Environment under Ubuntu14.04 (apache+nginx+mysql+php)