1. Installing Nginx
SOURCE Installation
I install the environment is Deepin (Ubuntu derivative version), so the simplest way is to execute
sudo Install Nginx
or under CentOS:
Yum Install Nginx
Compiling the installation
http://nginx.org/Download the latest version of 1.9.5, support HTTP/2 module, claiming to be faster and more secure, and can be backwards compatible, detailed view nginx_http2_white_paper_v4.pdf
Dependencies: openssl-1.0.0s,pcre-8.36,zlib-1.2.8
After the installation is done separately, compile:
./configure--sbin-path=/usr/local/nginx/nginx--conf-path=/usr/local/nginx/nginx.conf--pid-path=/usr/local/ Nginx/nginx.pid--with-http_ssl_module--with-pcre=/usr/local/src/pcre-8.36
--with-zlib=/usr/local/src/zlib-1.2.8--with-openssl=/usr/local/src/openssl-1.0.0s
Make && make install
Note:--with-pcre This article was not found in the source, I switched to--with-pcre-opt
Reference Reference Http://www.nginx.cn/install
After the installation is complete
sudo service nginx start
For convenience, the following direct use of the source installation method
Install mariadb ( direct replacement for MySQL)
sudo Install mariadb-server mariadb-client
Follow the prompts when the installation is complete
sudo vim/etc/mysql/my.cnf
127.0. 0.1 #注释掉之后就可以远程访问了
Why do you use MARIADB? What is MARIADB? Please own Baidu, here do not discuss in detail
Install PHP5-FPM:
sudo Install php5 php5-fpm php5-gd php5-mysql
For convenience, install a few useful expansion packs at once, which are used later
sudo vim/etc/php5/fpm/pool.d/www.cof
Modify the Listening port number
127.0. 0.1:9000sudo service php5-fpm restart
2. Configure the virtual host
Execute command:
sudo vim/etc/nginx/nginx.conf
To view and modify basic configuration information and optimize, The following lists only the items that can be optimized:
Worker_processes4; #进程核心数worker_connections1024x768; #请求连接数keepalive_timeout the; #连接超时数access_log off; #访问日志, set this to off to reduce disk IO and increase speed gizp_vary on; #开启gzip压缩gzip_proxied any;gzip_comp_level9; #数据压缩等级,1-9, 9 represents the slowest but highest proportion of compression gzip_buffers -8k; #缓冲区gzip_http_version1.1; #http协议版本gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml+rss text/JavaScript, #压缩文件类型 # Virtual host configs hosting configuration open include/etc/nginx/conf.d/*. conf;include/etc/nginx/sites-enabled/*;
Modify the Hosts file
sudo vim/etc/hosts
Added as: 127.0.0.1 www.dev.com
There are two files in the/etc/nginx/directory sites-available and sites-enabled
Sites-available is the actual configuration file, default, copy one:
sudo mv default./www.dev.com
Copy the default file and rename it to the www.dev.com configured in the hosts
To modify the contents of a file:
Server {Listen the; #监听端口 Root/home/kevin/workspace/html/advanced/frontend/web; #项目存放目录 index index.php index.html index.htm; #默认访问文件 server_name www.dev.com; #服务器名称Location/{try_files $uri $uri//index.php?$args; } Location~\.php$ {# default fastcgi.conf file is not actually, point to is fastcgi_params (here is a better way to configure, to be updated after my practice.) This configuration is not much affected now) # include fastcgi.conf include Fastcgi_params; Fastcgi_pass127.0.0.1:9000; } Location~ /\. (ht|svn|git) {Deny All; }}
sites-enabled is a soft link to the file within the sites-available, where the newly configured file is created with a corresponding soft link:
sudo LN -s/etc/nginx/sites-available/www.dev.com/etc/nginx/sites-enabled/www.dev.com
After the configuration is complete, test for success
sudo /etc/init.d/nginx configtestsudo service nginx Reload #加载配置项
Nignx the server can successfully run the configuration item without restarting
Nginx Learning notes-building a Linux +nginx+php+mariadb (MYSQL) Development environment