Ubuntu + Nginx + Mysql + Php + Zend + eaccelerator install and configure the text version

Source: Internet
Author: User
Tags recode filezilla ssh port

Write down the process of setting up an lnmp website. I hope it will be helpful to anyone who wants to set up the website. If you have any better solutions, please come up with me.
The reason why nginx is useless to apache is that nginx is more efficient, especially for low-configuration servers, such as servers I set up on an old machine with a memory unit of MB.
1. Install ubuntu server 10.04 or 10.10. The installation language is selected as en and the time zone is shanghai. Only ssh is installed for the service, and all others are installed by default.
Tip: After the above installation is complete, it is recommended to log on to the server with another computer. putty can be used in windows, and the linux system can directly use commands on the terminal:

Code:
Ssh Login Name @ Server ip Address

In the following process, you must enter a large number of commands and code and paste them directly on the client (right-click putty in windows to paste the content in the clipboard to the terminal ).
2. Add Source:

Code:Copy codeThe Code is as follows: sudo vi/etc/apt/sources. list

Add the following source for lucid (10.04:
Code:Copy codeCode: 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
The deb-src http://archive.ubuntu.com/ubuntu/ lucid main restricted universe multiverse
The deb-src http://archive.ubuntu.com/ubuntu/ lucid-security main restricted universe multiverse
The 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 codeThe Code is 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 line is the ppa source of nginx. You need to add the key and run it on the terminal:

Code:Copy codeThe Code is as follows: sudo apt-key adv -- keyserver keyserver.Ubuntu.com -- recv-keys C300EE8C

3. Update

Code:Copy codeThe Code is as follows: sudo apt-get update

4. Install the website system

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

The above is a required installation. The following php components are optional for installation. Generally, website programs may not need to be installed:

Code:Copy codeThe Code is 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 codeThe Code is as follows: sudo vi/etc/nginx/sites-enabled/default

Put the following:

Code:Copy codeThe Code is as follows: location /{
Root/var/www;
Index index.html index.htm;
}

Changed:

Code:Copy codeThe Code is as follows: location /{
Root/var/www/nginx-default;
Index. php index.html index.htm;
}

Where:

Code:
# Location ~ \. Php $ {
# Fastcgi_pass 127.0.0.1: 9000;
# Fastcgi_index index. php;
# Include fastcgi_params;
#}

Changed:

Code:Copy codeThe Code is 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 website directory ownership:

Code:
Sudo chown-R ubuntu nginx-default/

Note: ubuntu is the user name used to log on to the system.
7. Install ZendGuardLoader and eaccelerator:

Code:Copy codeThe Code is 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 the control program to the website directory through http: // website name/control. php access. The default account is admin and the password is eAccelertor. You can edit this file.
Phpize
Sudo./configure -- enable-eaccelerator = shared
Sudo make
Sudo make install
Sudo vi/etc/php5/fpm/php. ini

Add the following at the end of the configuration file:

Code:Copy codeThe Code is 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) install phpmyadmin:

Code:Copy codeThe Code is 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
Music 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

Replace the following:

Code:Copy codeThe Code is as follows: $ cfg ['blowfish _ secret'] = '';

Changed:

Code:Copy codeThe Code is as follows: $ cfg ['blowfish _ secret'] = 'web ';

Below:

Code:Copy codeThe Code is 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 _ page'] = '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 ';

Delete // all, and then:

Code:Copy codeThe Code is as follows: $ cfg ['servers'] [$ I] ['controluser'] = 'pma ';
$ Cfg ['servers'] [$ I] ['controlpass'] = 'pmapass ';

Change pma and pmapass to your mysql user name and password, log on to phpmyadmin, and import the creat_tables. SQL file in the phpmyadmin/scripts directory to mysql.
9. restart the system and upload files. The website is successfully created! Try it!
Filezilla (http://filezilla-project.org/), free open source ftp software, windows and linux can be used, support ssh port 22.

Appendix: system and some software management operations
1. Operating System:

Code:Copy codeCode: sudo reboot now // restart the system
Sudo halt // shut down the system

2. Modify and take effect of nginx Configuration:

Code:Copy codeThe Code is as follows: sudo vi/etc/nginx. conf // modify the configuration
Sudo vi/etc/nginx/sites-enabled/default // modify the configuration
Sudo service nginx restart // restart nginx

3. Modify and take effect of php configuration:

Code:Copy codeThe Code is as follows: sudo vi/etc/php5/fpm/php. ini // modify the configuration
Sudo service php5-fpm restart // restart fastcgi Process

3. website directory:

Code:Copy codeThe Code is as follows:/var/www/nginx-default

4. eaccelerator management:

Code:Copy codeThe Code is as follows: http: // your website/control. php

5. Fix major vulnerabilities in nginx + php and modify the size of uploaded files (depending on your situation)

Code:Copy codeThe Code is as follows: sudo vi/etc/php5/fpm/php. ini
Cgi. fix_pathinfo = 0 // fix the Vulnerability
Upload_max_filesize = 2 MB to 5 MB // modify the size of the uploaded file

6. Set a firewall

Code:Copy codeThe Code is as follows: sudo ufw enable
Sudo ufw default deny
Sudo ufw allow 80
Sudo ufw allow 22

7, when starting the php5-fpm, appear:

Code:Copy codeThe Code is 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.

The reason for the first line is that it has been used in the configuration file; instead of # for comment. Modify the following files:

Code:Copy codeThe Code is as follows: vi/etc/php5/fpm/conf. d/ming. ini

Change #.
The reason for the second line is in the/etc/php5/fpm/pool. d/www. conf configuration file.

Code:
; Pm. start_servers = 20

Remove the previous one.
8. When the Discuz background starts URL static, the system will prompt the solution of 404 Not Found:
Enable Rewrite in nginx, write the following content in the server configuration file "nginx. conf", and then restart nginx.

Code:Copy codeThe Code is as follows: rewrite ^/archiver/(fid | tid0000-0000w-00000000.html) $/archiver/index. php? $1 last;
Rewrite ^/forum-(%0-9%%%%-(%0-9%%%%%%.html $/forumdisplay. php? Fid = $1 & page = $2 last;
Rewrite ^/thread-(0-9000000000000-(0-9000000000000-(0-90000000000000000.html $/viewthread. php? Tid = $1 & extra = page % 3D $3 & page = $2 last;
Rewrite ^/space-(username | uid316-(.20.0000.html $/space. php? $1 = $2 last;
Rewrite ^/tag-(.20.20..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 install it in the subdirectory/bbs:

Code:Copy codeThe Code is 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! Install X1.5 In the subdirectory/bbs:

Code:Copy codeThe Code is 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.