首先添加必要的apt源,并使用下面的命令使服务器保持最新:
apt-get update
apt-get upgrade
安装mysql服务器
apt-get install mysql-server
配置mysql相关
mysql_secure_installation
安装nginx
apt-get install nginx
添加脚本到系统默认运行级别
/usr/sbin/update-rc.d -f nginx defaults
现在可以运行nginx了
/etc/init.d/nginx start
Installing PHP5
apt-get install php5-fpm php5-mysql
Configuring Nginx
vi /etc/nginx/nginx.conf
worker_processes 4;
keepalive_timeout 2;
vi /etc/nginx/sites-available/default
server {
listen 80; ## listen for ipv4; this line is default and implied
listen [::]:80 default_server ipv6only=on; ## listen for ipv6
root /usr/share/nginx/www;
index index.php index.html index.htm;
# Make site accessible from http://localhost/
server_name localhost;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ /index.html;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
}
location /doc/ {
alias /usr/share/doc/;
autoindex on;
allow 127.0.0.1;
allow ::1;
deny all;
}
# Only for nginx-naxsi used with nginx-naxsi-ui : process denied requests
#location /RequestDenied {
# proxy_pass http://127.0.0.1:8080;
#}
error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/www;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
# NOTE: You should 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;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
}
}
/etc/init.d/nginx reload
vi /etc/php5/fpm/php.ini
cgi.fix_pathinfo=0
/etc/init.d/php5-fpm reload
vi /usr/share/nginx/www/phpinfo.php
<?php
phpinfo();
?>
aptitude install nginx
aptitude install php5-fpm
aptitude install php5-mysql
service php5-fpm restart
service nginx restart
aptitude install mysql-server mysql-client
/etc/init.d/nginx start
/etc/init.d/nginx stop
/etc/init.d/nginx reload
/etc/init.d/php5-fpm reload
service php5-fpm restart
service nginx restart
最后安装PHPMyAdmin,使用下面的命令安装:
apt-get install phpmyadmin
注意会提示你选择Apache或者lighttpd服务器,我们用的是Nginx,所以这里按Esc退出选择,然后会提示你输入数据库root密码,输入后按OK确定。
安装完成后,phpmyadmin所有代码文件都默认位于/usr/share/phpmyadmin路径下,假设我们的Web主路径位于/var/www下,接下来做个链接就可以了:
ln -s /usr/share/phpmyadmin/ /home/www/
apt-get update
apt-get upgrade
安装mysql服务器
apt-get install mysql-server
配置mysql相关
mysql_secure_installation
安装nginx
apt-get install nginx
添加脚本到系统默认运行级别
/usr/sbin/update-rc.d -f nginx defaults
现在可以运行nginx了
/etc/init.d/nginx start
Installing PHP5
apt-get install php5-fpm php5-mysql
Configuring Nginx
vi /etc/nginx/nginx.conf
worker_processes 4;
keepalive_timeout 2;
vi /etc/nginx/sites-available/default
server {
listen 80; ## listen for ipv4; this line is default and implied
listen [::]:80 default_server ipv6only=on; ## listen for ipv6
root /usr/share/nginx/www;
index index.php index.html index.htm;
# Make site accessible from http://localhost/
server_name localhost;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ /index.html;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
}
location /doc/ {
alias /usr/share/doc/;
autoindex on;
allow 127.0.0.1;
allow ::1;
deny all;
}
# Only for nginx-naxsi used with nginx-naxsi-ui : process denied requests
#location /RequestDenied {
# proxy_pass http://127.0.0.1:8080;
#}
error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/www;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
# NOTE: You should 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;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
}
}
/etc/init.d/nginx reload
vi /etc/php5/fpm/php.ini
cgi.fix_pathinfo=0
/etc/init.d/php5-fpm reload
vi /usr/share/nginx/www/phpinfo.php
<?php
phpinfo();
?>
aptitude install nginx
aptitude install php5-fpm
aptitude install php5-mysql
service php5-fpm restart
service nginx restart
aptitude install mysql-server mysql-client
/etc/init.d/nginx start
/etc/init.d/nginx stop
/etc/init.d/nginx reload
/etc/init.d/php5-fpm reload
service php5-fpm restart
service nginx restart
最后安装PHPMyAdmin,使用下面的命令安装:
apt-get install phpmyadmin
注意会提示你选择Apache或者lighttpd服务器,我们用的是Nginx,所以这里按Esc退出选择,然后会提示你输入数据库root密码,输入后按OK确定。
安装完成后,phpmyadmin所有代码文件都默认位于/usr/share/phpmyadmin路径下,假设我们的Web主路径位于/var/www下,接下来做个链接就可以了:
ln -s /usr/share/phpmyadmin/ /home/www/