I recently tried to install lnmp on ubuntu to test the blog code. Record the process below.
Create a new/var/www/Directory. Of course, you have to place the directory on your own. Remember to set the nginx code after modification.
Sudo mkdir/var/www
Sudo chmod-R 777/var/www
Install nginx
Apt-get install nginx-full
All configuration files are under/etc/nginx, and each virtual host is already under/etc/nginx/sites-available.
Program file in/usr/sbin/nginx
Logs are stored in/var/log/nginx.
The startup script nginx has been created under/etc/init. d/.
The default virtual host directory is/var/www/nginx-default.
Modify the default website directory:
Sudo vim/etc/nginx/sites-available/default
Replace all codes with the following code:
Server {
Listen [:]: 80 default ipv6only = on; # listen for ipv6
Listen 80;
Server_name localhost;
Root/var/www/; # If you modify the preceding Directory, modify it here.
Location /{
Index. php index.html index.htm;
}
Location ~ \. Php $ {
Fastcgi_split_path_info ^ (. + \. php) (/. +) $;
# NOTE: You shoshould have "cgi. fix_pathinfo = 0;" in php. ini
#
# With php5-cgi alone:
Fastcgi_pass 127.0.0.1: 9000;
# With php5-fpm:
# Fastcgi_pass unix:/var/run/php5-fpm.sock;
Fastcgi_index index. php;
Include fastcgi_params;
}
}
Modify/etc/nginx/fastcgi_params and add the following content directly at the end:
Fastcgi_param SCRIPT_FILENAME $ document_root $ fastcgi_script_name;
Fastcgi_param PATH_INFO $ fastcgi_script_name;
Fastcgi_connect_timeout 60;
Fastcgi_send_timeout 180;
Fastcgi_read_timeout 180;
Fastcgi_buffer_size 128 k;
Fastcgi_buffers' 4 256 k;
Fastcgi_busy_buffers_size 256 k;
Fastcgi_temp_file_write_size 256 k;
Fastcgi_intercept_errors on;
Install php and mysql
Install PHP
Sudo apt-get install php5-fpm php5-gd php5-common php5-curl php5-imagick php5-mcrypt php5-memcache php5-mysql php5-cgi
Install mysql
Sudo apt-get install-y mysql-server mysql-client
Note: the root user password of Mysql is required during installation. Remember the Super Password of Mysql.
Modify the php. Ini file:
Sudo vim/etc/php5/fpm/php. ini
Modify cgi. fix_pathinfo = 1
Cgi. fix_pathinfo = 0
Create site
Sudo vim/etc/nginx/conf. d/example.com. conf
Content is
Server {
Listen 80;
# Ipv6
# Listen [:]: 80 default_server;
Root/var/www/example.com.net;
# Default homepage file name
Index. php index.html index.htm;
# Bind a domain name
Server_name example.com;
Location /{
Try_files $ uri // index.html;
# Pseudo-static rules
Enter pseudo-static rules here
}
# Define error page
# Error_page 404/404 .html;
Location ~ \. Php $ {
Fastcgi_split_path_info ^ (. + \. php) (/. +) $;
Fastcgi_pass 127.0.0.1: 9000;
Fastcgi_index index. php;
Include fastcgi_params;
}
}
Restart nginx and php-fpm
Sudo/etc/init. d/nginx restart
Sudo/etc/init. d/php5-fpm reload
Use phpmyadmin
Finally, for mysql management problems, download the phpmyadmin source code package and decompress it to/var/www/. Open the browser: http: // localhost/phpmyadmin/to access the database, note the case sensitivity of "phpmyadmin. The username and password are the username and password set during mysql installation.