I heard that Nginx is very strong. The company's O & M team mentioned Nginx. Today, I manually reinstalled my server. The server system still uses FreeBSD, and the new version 7.2 is used this time.
Required software:
Nginx 0.6.38
Spawn-fcgi-1.6.0
Php5-5.2.9
MySQL 5.0.77
Proftpd-1.3.2
Memcached-1.2.6_1
1. Install the system. It takes less than 15 minutes to install the system. Select the minimum number of packages, such as Ports, Perl, and Python. Enable ssh.
2. Use Ports to install php5, vim, spawn-fcgi, and memcached. The FreeBSD system automatically installs some basic lib. For example, libxml2, libzip, libgd2, libjpeg, and some common basic software will also be installed.
When mysql is installed on Ports, mysql cannot be downloaded. Php5 chooses ports instead of using it. Instead, it downloads, compiles, and installs it on its own.
3. download a copy of MySQL, compile and install it.
Sh code
#./Configure with_charset = utf8 with_charset = gbk with_charset = gb2312
With_xcharset = all with_proc_scope_pth = yes build_optimized = yes
Build_static = yes skip_dns_check = yes PREFIX =/usr/local/mysql # addgroup mysql
# Adduser mysql
# Cd/usr/local/mysql
#./Bin/mysql_install_db -- basedir =/usr/local/mysql/-- datadir =/wwwroot/databases
#. /Configure with_charset = utf8 with_charset = gbk with_charset = gb2312 with_xcharset = all rows = yes build_optimized = yes build_static = yes rows = yes PREFIX =/usr/local/mysql # addgroup mysql # adduser mysql # cd/usr/local/mysql #. /bin/mysql_install_db -- basedir =/usr/local/mysql/-- datadir =/wwwroot/databases
Copy my. cnf to/etc/my. cnf, and add
[Mysqld] datadir =/wwwroot/databases
./Bin/mysqld_safe -- user = mysql &
4. An elinks is installed, and elinks is sent to php.net. A php5.2.9 file is downloaded and decompressed.
Java code
# Tar xvf php5.2.9.tar.bz2
#./Configure -- prefix =/usr/local/php -- with-gd -- enable-fastcgi -- enable-ftp
-- With-zlib -- enable-mbstring -- with-mcrypt -- with-mysql =/usr/local/mysql -- with-pdo-mysql =/usr/local/mysql
-- Enable-zip -- with-pear
# Tar xvf php5.2.9.tar.bz2 #. /configure -- prefix =/usr/local/php -- with-gd -- enable-fastcgi -- enable-ftp -- with-zlib -- enable-mbstring -- with-mcrypt -- with-mysql = /usr/local/mysql -- with-pdo-mysql =/usr/local/mysql -- enable-zip -- with-pear
Copy php. ini-dist to/usr/local/php/lib/php. ini, modify the configuration file, and enable the required extension.
5. Nginx is also installed on ports.
Cd/usr/ports/www/nginx/
Make install clean PREFIX =/usr/local/nginx
Note: A pcre package is required before nginx is installed. Install pcre before installing ports. If pcre is automatically installed during nginx installation, the pcre will be installed to/usr/local/nginx, and nginx will not find the pcre of/usr/local and report an error.
6. Configure nginx
Java code
Events {
Worker_connections 1024;
Use kqueue; # enable kqueue in FreeSBD and epoll in Linux
}
Events {worker_connections 1024; use kqueue; # enable kqueue in FreeSBD and epoll in Linux}
Java code
Location ~ . Php $ {
Fcinclude gi. conf;
Fastcgi_pass 127.0.0.1: 9000;
Fastcgi_index index. php;
}
Location ~ . Php $ {include fcgi. conf; fastcgi_pass 127.0.0.1: 9000; fastcgi_index index. php ;}
The configuration file fastcgi_param that comes with fcgi. conf nginx is missing
Java code
Fastcgi_param SCRIPT_FILENAME $ document_root $ fastcgi_script_name;
Fastcgi_param SCRIPT_FILENAME $ document_root $ fastcgi_script_name;
$ Document_root is the root directory of the php program. If this field exists in the nginx Vm, You can reference the variable. If not, enter the absolute path. /Wwwroot $ fastcgi_script_name;
7. Now you can start the server.
Sh code
# Spawn-fcgi-a 127.0.0.1-C 10-p 9000-u www-g www-f/usr/local/php/bin/php-cgi
# Nginx
# Spawn-fcgi-a 127.0.0.1-C 10-p 9000-u www-g www-f/usr/local/php/bin/php-cgi # nginx
You can put phpmyadmin and phpinfo. php In the root directory of the website,/wwwroot, and view the effect.