一、安装好CentOS,登陆CentOS
二、输入命令
yum install screen 或 apt-get install screen
yum install net-tools
screen -S lnmp
yum install wget
wget -c http://soft.vpser.net/lnmp/lnmp1.1-full.tar.gz && tar zxf lnmp1.1-full.tar.gz && cd lnmp1.1-full && ./centos.sh
安装过程中需要输入Mysql root的密码,和询问安装PHP、MariaDB等模块的版本,选择后按任意键开始。
安装结束以后,LNMP脚本就会自动安装编译Nginx、MySQL、PHP、phpMyAdmin、Zend Optimizer这几个软件。
三、虚拟主机
新增:
/root/vhost.sh
删除命令:
ssh登陆执行命令:rm /usr/local/nginx/conf/vhost/域名.conf
如,前面我们添加的主域名是www.vpser.net,则该命令为:rm /usr/local/nginx/conf/vhost/www.vpser.net.conf
虚拟主机配置文件在:/usr/local/nginx/conf/vhost/域名.conf
伪静态规则文件需要放在/usr/local/nginx/conf/ 下面。
四、其它
1、eAccelerator
在lnmp解压后的目录(我这里目录是/lnmp1.1-full),执行./eaccelerator.sh
2、xcache
./xcache.sh
3、memcached
./memcached.sh
4、imageMagick
./imageMagick.sh
5、Redis
./redis.sh
6、mysql 远程登陆权限
grant all PRIVILEGES on databasename.* to 'user'@'%' identified by '123456';
flush privileges;
my.cnf位置:/etc/my.cnf
使用中遇到:
socket=/var/lib/mysql/mysql.sock
五、状态管理
LNMP状态管理命令:
LNMP状态管理: /root/lnmp {start|stop|reload|restart|kill|status}
Nginx状态管理:/etc/init.d/nginx {start|stop|reload|restart}
MySQL状态管理:/etc/init.d/mysql {start|stop|restart|reload|force-reload|status}
Memcached状态管理:/etc/init.d/memcached {start|stop|restart}
PHP-FPM状态管理:/etc/init.d/php-fpm {start|stop|quit|restart|reload|logrotate}
PureFTPd状态管理: /etc/init.d/pureftpd {start|stop|restart|kill|status}
ProFTPd状态管理: /etc/init.d/proftpd {start|stop|restart|reload}
如重启LNMP,输入命令:/root/lnmp restart 即可,单独重启mysql:/etc/init.d/mysql restart
LNMPA状态管理命令:
LNMPA状态管理: /root/lnmpa {start|stop|reload|restart|kill|status}
Nginx状态管理:/etc/init.d/nginx {start|stop|reload|restart}
MySQL状态管理:/etc/init.d/mysql {start|stop|restart|reload|force-reload|status}
Memcached状态管理:/etc/init.d/memcached {start|stop|restart}
PureFTPd状态管理: /etc/init.d/pureftpd {start|stop|restart|kill|status}
ProFTPd状态管理: /etc/init.d/proftpd {start|stop|restart|reload}
Apache状态管理:/etc/init.d/httpd {start|stop|restart|graceful|graceful-stop|configtest|status}
安装参考:
http://lnmp.org/install.html
问题处理:
如果安装以后session不可用:
1.通过phpinfo找到php.ini位置,也通过命令php --ini找一下php.ini位置。可能有两个,最好保持内容一样
2.找到session_savepath设置,指向一个有读写权限的目录(如/tmp, chmod -R +rw /tmp)
3.有的程序可能需要设置session.auto_start=on,设置以后需要重启整个服务 : /root/lnmp restart
Nginx多站点配置
cd /usr/local/nginx/conf/vhost
vim test.com.conf
server {
listen 80 ;
#listen [::]:80 default ipv6only=on;
server_name test.com;
index index.html index.htm index.php;
root /home/wwwroot/test.com;
#error_page 404 /404.html;
location ~ [^/]\.php(/|$)
{
# comment try_files $uri =404; to enable pathinfo
try_files $uri =404;
fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_index index.php;
include fastcgi.conf;
#include pathinfo.conf;
}
location /nginx_status {
stub_status on;
access_log off;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 12h;
}
access_log /home/wwwlogs/access.log access;
}
站点放到/home/wwwroot/test.com下,重启nginx即可。