Ubuntu+nginx+mysql+php+zend+eaccelerator installation Configuration text version _nginx

Source: Internet
Author: User
Tags bz2 file upload fpm recode ssh filezilla phpmyadmin zend
I set up the process of setting up the LNMP site, I hope to set up a site for friends to help, if there is a better way to ask.
The reason for using Nginx is not Apache, because the nginx is more efficient, especially for some low configuration servers, such as my 256M memory in the unit of the old machine installed on the server.
1, installation of Ubuntu server 10.04 or 10.10, where the installation of the language selected en, time zone Shanghai, the service is only installed SSH, all others by default on the line.
Tip: After the above installation process is completed, it is recommended to use other computers to log on to the server, Windows system can use the Putty,linux system directly in the terminal command can:

Code:
SSH logon name @ server IP

Because the following procedure has to enter a large number of commands and code, paste directly on the client (in the putty in Windows to paste the contents of the Clipboard to the terminal).
2. Add Source:

Code:
Copy Code code as follows:

sudo vi/etc/apt/sources.list

The source of the lucid (10.04) is added as follows:
Code:
Copy code code as follows:

Deb Http://archive.ubuntu.com/ubuntu/lucid main restricted universe multiverse
Deb Http://archive.ubuntu.com/ubuntu/lucid-security main restricted universe multiverse
Deb Http://archive.ubuntu.com/ubuntu/lucid-updates main restricted universe multiverse
Deb Http://archive.ubuntu.com/ubuntu/lucid-backports main restricted universe multiverse
DEB-SRC http://archive.ubuntu.com/ubuntu/lucid main restricted universe multiverse
DEB-SRC http://archive.ubuntu.com/ubuntu/lucid-security main restricted universe multiverse
DEB-SRC http://archive.ubuntu.com/ubuntu/lucid-updates main restricted universe multiverse
DEB-SRC http://archive.ubuntu.com/ubuntu/lucid-backports main restricted universe multiverse
Deb Http://ppa.launchpad.net/nginx/stable/ubuntu Lucid Main
Deb Http://ppa.launchpad.net/brianmercer/php/ubuntu Lucid Main

Source of Maverick (10.10):

Code:
Copy Code code as follows:

Deb Http://archive.ubuntu.com/ubuntu/maverick main restricted universe multiverse
Deb Http://archive.ubuntu.com/ubuntu/maverick-security main restricted universe multiverse
Deb Http://archive.ubuntu.com/ubuntu/maverick-updates main restricted universe multiverse
Deb Http://archive.ubuntu.com/ubuntu/maverick-backports main restricted universe multiverse
DEB-SRC Http://archive.ubuntu.com/ubuntu/maverick main restricted universe multiverse
DEB-SRC http://archive.ubuntu.com/ubuntu/maverick-security main restricted universe multiverse
DEB-SRC http://archive.ubuntu.com/ubuntu/maverick-updates main restricted universe multiverse
DEB-SRC http://archive.ubuntu.com/ubuntu/maverick-backports main restricted universe multiverse
Deb Http://ppa.launchpad.net/nginx/stable/ubuntu Maverick Main

The last act Nginx the PPA source and needs to add key to run at the terminal:

Code:
Copy Code code as follows:

sudo apt-key adv--keyserver keyserver. Ubuntu.com--recv-keys c300ee8c

3, update

Code:
Copy Code code as follows:

sudo apt-get update

4, install the website system

Code:
Copy Code code as follows:

sudo apt-get install nginx php5-common php5-dev php5-cgi php5-fpm php-apc php5-mysql php5-curl php5-gd php5-idn php-pear p Hp5-mcrypt php5-memcache php5-ming php5-recode php5-tidy php5-xmlrpc php5-xsl mysql-server

The above is required installation, the following PHP components are optional installation, the general Web program may not need to:

Code:
Copy Code code as follows:

sudo apt-get install php5-imagick php5-imap php5-recode php5-snmp php5-sqlite php5-xmlrpc php5-suhosin php5-odbc Php5-ladp

5, modify the Nginx configuration file

Code:
Copy Code code as follows:

sudo vi/etc/nginx/sites-enabled/default

Take one of the following:

Code:
Copy Code code as follows:

Location/{
root/var/www;
Index index.html index.htm;
}

To

Code:
Copy Code code as follows:

Location/{
Root/var/www/nginx-default;
Index index.php index.html index.htm;
}

of which:

Code:
#location ~ \.php$ {
# Fastcgi_pass 127.0.0.1:9000;
# Fastcgi_index index.php;
# include Fastcgi_params;
#}

To

Code:
Copy Code code as follows:

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 Fastcgi_params;
}

6, change the Site Directory ownership:

Code:
sudo chown-r ubuntu nginx-default/

Note: Ubuntu is the user name for the system login.
7, installation Zendguardloader and eaccelerator:

Code:
Copy Code code as follows:

sudo mkdir/usr/zend
Mkdir/tmp/eaccelerator
chmod 0777/tmp/eaccelerator
wget http://phpcj.googlecode.com/files/ZendGuardLoader.so
sudo mv zendguardloader.so/usr/zend/zendguardloader.so
wget http://bart.eaccelerator.net/source/0.9.6.1/eaccelerator-0.9.6.1.tar.bz2
Tar xvjf eaccelerator-0.9.6.1.tar.bz2
CD eaccelerator-0.9.6.1
CP control.php/var/www/nginx-default/control.php//Copy Control program to Site Directory, via http://site name/ control.php access, the default account is admin, password is eaccelertor, you can edit this file modification.
Phpize
sudo./configure--enable-eaccelerator=shared
sudo make
sudo make install
sudo vi/etc/php5/fpm/php.ini

At the end of the configuration file, add:

Code:
Copy Code code as follows:

Zend_extension=/usr/zend/zendguardloader.so
Zend_loader.enable=1
Zend_loader.disable_licensing=0
Zend_loader.obfuscation_level_support=3
Zend_loader.license_path=
zend_extension= "/usr/lib/php5/20090626+lfs/eaccelerator.so"
Eaccelerator.shm_size= "16"
Eaccelerator.cache_dir= "/tmp/eaccelerator"
eaccelerator.enable= "1"
Eaccelerator.optimizer= "1"
Eaccelerator.check_mtime= "1"
eaccelerator.debug= "0"
Eaccelerator.filter= ""
eaccelerator.shm_max= "0"
Eaccelerator.shm_ttl= "0"
eaccelerator.shm_prune_period= "0"
eaccelerator.shm_only= "0"
eaccelerator.compress= "1"
Eaccelerator.compress_level= "9"
Eaccelerator.allowed_admin_path= "/var/www/nginx-default/control.php"

8. (Optional steps) installation phpMyAdmin:

Code:
Copy Code code as follows:

wget http://downloads.sourceforge.net/project/phpmyadmin/phpMyAdmin/3.3.9/phpMyAdmin-3.3.9-all-languages.tar.bz2
Tar xvjf phpmyadmin-3.3.9-all-languages.tar.bz2
MV Phpmyadmin-3.3.9-all-languages/var/www/nginx-default/phpmyadmin
Cd/var/www/nginx-default/phpmyadmin
CP config.sample.inc.php config.inc.php
VI config.inc.php

To include:

Code:
Copy Code code as follows:

$cfg [' blowfish_secret '] = ';

To

Code:
Copy Code code as follows:

$cfg [' blowfish_secret '] = ' web ';

The following:

Code:
Copy Code code as follows:

$cfg [' Servers '] [$i] [' controluser '] = ' PMA ';
$cfg [' Servers '] [$i] [' controlpass '] = ' pmapass ';
$cfg [' Servers '] [$i] [' pmadb '] = ' phpmyadmin ';
$cfg [' Servers '] [$i] [' bookmarktable '] = ' pma_bookmark ';
$cfg [' Servers '] [$i] [' relation '] = ' pma_relation ';
$cfg [' Servers '] [$i] [' table_info '] = ' pma_table_info ';
$cfg [' Servers '] [$i] [' table_coords '] = ' pma_table_coords ';
$cfg [' Servers '] [$i] [' pdf_pages '] = ' pma_pdf_pages ';
$cfg [' Servers '] [$i] [' column_info '] = ' pma_column_info ';
$cfg [' Servers '] [$i] [' history '] = ' pma_history ';
$cfg [' Servers '] [$i] [' tracking '] = ' pma_tracking ';
$cfg [' Servers '] [$i] [' designer_coords '] = ' pma_designer_coords ';
$cfg [' Servers '] [$i] [' auth_swekey_config '] = '/etc/swekey-pma.conf ';

Remove//All, and then put the following:

Code:
Copy Code code as follows:

$cfg [' Servers '] [$i] [' controluser '] = ' PMA ';
$cfg [' Servers '] [$i] [' controlpass '] = ' pmapass ';

PMA and Pmapass to your MySQL username and password, the last login phpmyadmin, the phpmyadmin/scripts directory Creat_tables.sql file into MySQL.
9, restart the system, upload files, website establishment success! Give it a try!
File upload recommended with FileZilla (http://filezilla-project.org/), free open-source FTP software, Windows and Linux can be used to support SSH 22 ports.

Attached: System and some software management operation
1. Operating system:

Code:
Copy Code code as follows:

sudo reboot now//reboot system
sudo halt//Shutdown system

2, Nginx configuration modification and entry into force:

Code:
Copy Code code as follows:

sudo vi/etc/nginx/nginx.conf//Modify Configuration
sudo vi/etc/nginx/sites-enabled/default//Modify Configuration
sudo service nginx restart//reboot Nginx

3, PHP configuration changes and effective:

Code:
Copy Code code as follows:

sudo vi/etc/php5/fpm/php.ini//Modify Configuration
sudo service php5-fpm restart//restart fastcgi process

3, the website directory:

Code:
Copy Code code as follows:

/var/www/nginx-default

4, Eaccelerator Management:

Code:
Copy Code code as follows:

http://your website/control.php

5, repair nginx+php The major vulnerabilities, modify the upload file size (you can see your own situation)

Code:
Copy Code code as follows:

sudo vi/etc/php5/fpm/php.ini
Cgi.fix_pathinfo = 0//fix vulnerability
Upload_max_filesize = 2M to 5M//modify upload file size

6, set the firewall

Code:
Copy Code code as follows:

sudo UFW enable
sudo ufw default deny
sudo UFW allow 80
sudo ufw allow 22

7, when starting PHP5-FPM, appear:

Code:
Copy Code code as follows:

PHP deprecated:comments starting with ' # ' are deprecated In/etc/php5/fpm/conf.d/ming.ini on line 1 in Unknown on line 0
[WARNING] [Pool www] pm.start_servers is not set. It ' s been set to 20.

Prompt, the first line of the reason is used in the configuration file, instead of # for comment. Modify the following file:

Code:
Copy Code code as follows:

Vi/etc/php5/fpm/conf.d/ming.ini

Change the # to;
The second row is due to the/etc/php5/fpm/pool.d/www.conf configuration file

Code:
;p m.start_servers = 20

Remove the front;
8, discuz background start URL static, will prompt 404 Not Found solution:
Open rewrite in Niginx, write the following in the server configuration file nignx.conf, and then restart Nginx.


Code:
Copy Code code as follows:

Rewrite ^/archiver/((Fid|tid)-[w-]+.html) $/archiver/index.php?$1 last;
Rewrite ^/forum-([0-9]+)-([0-9]+). html$/forumdisplay.php?fid=$1&page=$2 last;
Rewrite ^/thread-([0-9]+)-([0-9]+)-([0-9]+). html$/viewthread.php?tid=$1&extra=page%3d$3&page=$2 last;
Rewrite ^/space-(username|uid)-(. +). html$/space.php?$1=$2 last;
Rewrite ^/tag-(. +). html$/tag.php?name=$1 last;
Break

The following content is from: http://www.vpsee.com/2011/04/some-nginx-rewrite-examples-for-subdirectories/, not tested.
discuz! 7.2 Installed under the subdirectory/bbs:

Code:
Copy Code code as follows:

Rewrite ^/bbs/archiver/((Fid|tid)-[\w\-]+\.html) $/bbs/archiver/index.php?$1 last;
Rewrite ^/bbs/forum-([0-9]+)-([0-9]+) \.html$/bbs/forumdisplay.php?fid=$1&page=$2 last;
Rewrite ^/bbs/thread-([0-9]+)-([0-9]+)-([0-9]+) \.html$/bbs/viewthread.php?tid=$1&extra=page%3d$3&page=$ 2 last;
Rewrite ^/bbs/space-(username|uid)-(. +) \.html$/bbs/space.php?$1=$2 last;
Rewrite ^/bbs/tag-(. +) \.html$/bbs/tag.php?name=$1 last;

discuz! X1.5 installed under the subdirectory/bbs:

Code:
Copy Code code as follows:

rewrite ^ ([^\.] *)/topic-(. +) \.html$ $1/portal.php?mod=topic&topic=$2 last;
Rewrite ^ ([^\.] *)/article-([0-9]+)-([0-9]+) \.html$ $1/portal.php?mod=view&aid=$2&page=$3 last;
Rewrite ^ ([^\.] *)/forum-(\w+)-([0-9]+) \.html$ $1/forum.php?mod=forumdisplay&fid=$2&page=$3 last;
Rewrite ^ ([^\.] *)/thread-([0-9]+)-([0-9]+) \.html$ $1/forum.php?mod=viewthread&tid=$2&extra=page%3d$4&page=$3 last;
Rewrite ^ ([^\.] *)/group-([0-9]+)-([0-9]+) \.html$ $1/forum.php?mod=group&fid=$2&page=$3 last;
Rewrite ^ ([^\.] *)/space-(USERNAME|UID)-(. +) \.html$ $1/home.php?mod=space&$2=$3 last;
Rewrite ^ ([^\.] *)/([a-z]+)-(. +) \.html$ $1/$2.php?rewrite=$3 last;
if (!-e $request _filename) {
return 404;
}

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.