• 欢迎访问开心洋葱网站,在线教程,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站,欢迎加入开心洋葱 QQ群
  • 为方便开心洋葱网用户,开心洋葱官网已经开启复制功能!
  • 欢迎访问开心洋葱网站,手机也能访问哦~欢迎加入开心洋葱多维思维学习平台 QQ群
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏开心洋葱吧~~~~~~~~~~~~~!
  • 由于近期流量激增,小站的ECS没能经的起亲们的访问,本站依然没有盈利,如果各位看如果觉着文字不错,还请看官给小站打个赏~~~~~~~~~~~~~!

Ubuntu14.04 服务器 配置nginx、php5-fpm、mysql、redis

Linux 开心洋葱 2805次浏览 0个评论

Ubuntu14.04 服务器 配置nginx、php5-fpm、mysql、redis 

 

直接上配置脚本,ubuntu配置太省事了

 

注意:记得要给网站访问目录用户权限,默认是www-data用户

 

apt-get update
#在此命令后会输入root管理员密码

apt-get install mysql-server mysql-client apt-get install nginx /etc/init.d/nginx start apt-get install php5-fpm vi /etc/nginx/nginx.conf vi /etc/nginx/sites-available/default #以上两个配置文件随后附上 /etc/init.d/nginx restart /etc/init.d/nginx reload apt-get install php5-mysql php5-curl php5-gd php5-intl php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-ming php5-ps php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl /etc/init.d/php5-fpm restart #查看是不是有9000端口监听如果有则正常 netstat -tln /etc/init.d/nginx reload /etc/init.d/php5-fpm restart service php5-fpm status service nginx status /etc/init.d/nginx start service nginx status ps ax | grep nginx ps ax | grep php5-fpm ps aux | grep php5-fpm ps aux | grep nginx /etc/init.d/nginx reload #配置redis服务器 apt-get install redis-server apt-get install php5-redis #查看是否有6379监听,如果有则正常 netstat -tln apt-get install sysv-rc-conf #配置开机启动 将2、3、4、5选中即可 sysv-rc-conf

 

/etc/nginx/nginx.conf配置文件
里修改CPU核数及超时时间
worker_processes 2; #cpu个数,一般默认是系统个数 
keepalive_timeout 5;#指定客户端连接保持活动的超时时间

/etc/nginx/sites-available/default 配置文件

 

# You may add here your
# server {
#	...
# }
# statements for each of your virtual hosts to this file

##
# You should look at the following URL's in order to grasp a solid understanding
# of Nginx configuration files in order to fully unleash the power of Nginx.
# http://wiki.nginx.org/Pitfalls
# http://wiki.nginx.org/QuickStart
# http://wiki.nginx.org/Configuration
#
# Generally, you will want to move this file somewhere, and start with a clean
# file but keep this around for reference. Or just disable in sites-enabled.
#
# Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.
##

server {
	listen 80 default_server;
	listen [::]:80 default_server ipv6only=on;

	root /data/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/ =404;
		# Uncomment to enable naxsi on this location
		# include /etc/nginx/naxsi.rules
	}

	# 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/html;
	}

	# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
	#
	location ~ \.php$ {
		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;
		fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
	}

	# deny access to .htaccess files, if Apache's document root
	# concurs with nginx's one
	#
	#location ~ /\.ht {
	#	deny all;
	#}

	location ~ .*\.(sh|bash)?$ {
		return 403;
	}
}


# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
#	listen 8000;
#	listen somename:8080;
#	server_name somename alias another.alias;
#	root html;
#	index index.html index.htm;
#
#	location / {
#		try_files $uri $uri/ =404;
#	}
#}


# HTTPS server
#
#server {
#	listen 443;
#	server_name localhost;
#
#	root html;
#	index index.html index.htm;
#
#	ssl on;
#	ssl_certificate cert.pem;
#	ssl_certificate_key cert.key;
#
#	ssl_session_timeout 5m;
#
#	ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
#	ssl_ciphers "HIGH:!aNULL:!MD5 or HIGH:!aNULL:!MD5:!3DES";
#	ssl_prefer_server_ciphers on;
#
#	location / {
#		try_files $uri $uri/ =404;
#	}
#}

 


开心洋葱 , 版权所有丨如未注明 , 均为原创丨未经授权请勿修改 , 转载请注明Ubuntu14.04 服务器 配置nginx、php5-fpm、mysql、redis
喜欢 (0)

您必须 登录 才能发表评论!

加载中……