CentOS LNMP安装

LNMP一键安装包是一个用Linux Shell编写的可以为CentOS/RadHat、Debian/Ubuntu VPS(VDS)或独立主机安装LNMP(Nginx、MySQL、PHP、phpMyAdmin)生产环境的Shell程序。

一、安装好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;

然后设置iptables


my.cnf位置:/etc/my.cnf

使用中遇到:

  • Error connecting to database: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
修改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即可。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

编程圈子

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值