Recently, I went back to my company and found that all my computers were replaced with linux systems... Very weak...
It took one day to configure the environment and run the project... Amount... Record here ~~
The system is ubuntu 12.04.
1. Install nginx
1: because of the security policy of ubuntu, the root user is usually disabled. Therefore, sudo is usually required for each command execution. To perform other subsequent operations, you can first switch to the root user so that sudo does not need to be added each time.
Sudo su-(switch user)
2: By default, ubuntu is the official source, which may be slow for domestic users. Therefore, we will change the official source to 163. The modification method is not described here, check the ubuntu wiki help manual.
Access: http://wiki.ubuntu.org.cn/Qref/Source
3: after the source is modified, refresh the list:
Apt-get update
Install nginx now
There are many ways to install nginx. You can download the nginx source code package, compile and install it, or install it in the form of ubuntu software package. Consider the following factors:
1) if the system is compiled and installed through the source code, the system performance will be relatively high. In this case, it is better to install the software through the source code. If the system is installed in ubuntu and other release versions, the compilation of the software through the source code does not significantly improve the performance. Of course, if you want to exercise or be satisfied with yourself, you can also try to install it through the source code.
2) If you build an environment to test, learn, or build a small website, you are not advised to install it using the source code, source code installation methods may cause many problems, and also increase the difficulty of maintenance for small webmasters in the future.
3) The online package management mechanism supported by ubuntu is certainly very mature, and there is no need to worry about its stability and security.
4) Of course, the advantage of source code compilation is that customization is relatively high. So it depends on your needs.
Okay, you don't have to talk about it anymore.
4: Install nginx
Run the command: apt-get install nginx
5. Start nginx after installation. For Nginx 0.8.x and later versions, start, stop, and smoothly start nginx.
Enable the service:
/Etc/init. d/nginx start
There is also another way to enable the Service.
/Usr/sbin/nginx-c/etc/nginx. conf
The preceding is the nginx installation path.-c indicates the path of the nginx configuration file.
Stop Service
/Etc/init. d/nginx-s stop
Heavy Load
/Etc/init. d/nginx-s reload
After the nginx installation is complete, open the browser and access http: // localhost to check whether nginx is properly installed and started. If there are firewall restrictions, such as vps, you may not be able to directly access through ip addresses, but you need to configure domain names for access. The way nginx configures virtual hosts is described later.
Ii. Install MySQL
Installing mysql in ubuntu is relatively simple.
1. Install the mysql server
Apt-get install mysql-server
During installation, you need to enter the password of the root user.
2. Install the mysql client
Apt-get install mysql-client
3. After installation, you generally need to reset the character set.
1) view the current encoding: show variables like 'character % ';
2) modify my. cnf and add default-character-set = utf8 under [client ].
Command: vi/etc/mysql/my. cnf
3) add default-character-set = utf8, init_connect = 'set NAMES utf8; 'under [server ;'
4) Restart mysql
/Etc/init. d/mysql restart
3. Install php5-fpm
Apt-get install php5-cgi
Apt-get install php5-fpm
Apt-get install php5-curl (client URL library Library)
Apt-get install php5-gd (GD library image library)
Apt-get install php5-mysql (Added support for mysql)
Apt-get install php5-mcrypt (Mcrypt encryption function library)
Apt-get install php5-memcache (Memcache client)
Apt-get install php5-memcached (Memcache server)
Apt-get install php5-dev (Development Support Module)
If you are in trouble, you can write a sentence.
Apt-get install php5-cgi
1: module description:
What is CGI?
CGI is a Common Gateway Interface. It is a tool for the HTTP server to "talk" with programs on your or other machines, the program must run on the network server.
What is FastCGI?
FastCGI is like a long-live CGI. It can be executed all the time, it will not take time to fork every time (this is the most criticized fork-and-execute mode for CGI ). It also supports distributed operations, that is, FastCGI programs can run on hosts other than website servers and receive requests from other website servers.
What is PHP-CGI?
PHP-CGI is the FastCGI manager that comes with PHP.
What is PHP-FPM?
The PHP-FPM is a PHP FastCGI manager and is only for PHP.
PHP-FPM is actually a patch of PHP source code, designed to integrate FastCGI process management into the PHP package.
PHP5.3.3 has already integrated php-fpm and is no longer a third-party package. PHP-FPM provides a better PHP process management method, can effectively control the memory and process, can smoothly load PHP configuration, so PHP officially included. You can enable PHP-fpm with the-enable-FPM parameter in./configure.
Use PHP-FPM to control FastCGI processes of PHP-CGI
2: After installation, You need to modify the fastcgi configuration.
Vi/etc/nginx/fastcgi_params
Comment the following line
# Fastcgi_param SCRIPT_FILENAME $ request_filename;
Add this line
Fastcgi_param SCRIPT_FILENAME $ document_root $ fastcgi_script_name;
3: optimization of php5-fpm Configuration
Vi/etc/php5/fpm/pool. d/www. conf
The meanings of the following four parameters are:
Pm. max_children: Number of php-fpm processes enabled in static mode.
Pm. start_servers: number of initial php-fpm processes in dynamic mode.
Pm. min_spare_servers: the minimum number of php-fpm processes in dynamic mode.
Pm. max_spare_servers: Maximum number of php-fpm processes in dynamic mode.
Note: For VPS with a memory of MB, we recommend that you set the following parameters for your reference only:
Pm = dynamic
Pm. max_children = 20
Pm. start_servers = 5
Pm. min_spare_servers = 5
Pm. max_spare_servers = 20
4. Install apc accelerator
APC significantly accelerates PHP applications. Adding APC to an application increases the application response speed and reduces server load.
Apt-get install php-apc
5. Restart php-fpm and nginx
Sudo/etc/init. d/php5-fpm restart
Sudo/etc/init. d/nginx restart
Possible Errors
1. An error occurred while installing sudo apt-get install xxx through the terminal:
E: cocould not get lock/var/lib/dpkg/lock-open (11: Resource temporarily unavailable)
E: Unable to lock the administration directory (/var/lib/dpkg/), is another process using it?
This problem may occur when another program is running, causing the resource to be locked and unavailable. The reason for the resource lock may be that the last installation or update was not completed properly, and this problem occurs. The solution is actually very simple:
Enter the following two sentences in the terminal:
Sudo rm/var/cache/apt/archives/lock
Sudo rm/var/lib/dpkg/lock
2. Permission denied Error
Add sudo in front of the command, or run sudo later !! Command.
Reference http://www.duwaiweb.com/blog/20120920_54cdb80f-1992-4642-aab7-346cc7d39266.html