阿里云服务器建立LNMP环境小记

阿里云服务器建立LNMP环境小记
1添加账户work
useradd work
passwd work
2为work添加sudo权限
vim /etc/sudoers
添加 work ALL=(ALL) ALL
3 安装php环境

[转]PHP7 快速编译安装


4 安装nginx
sudo yum install nginx
5 配置nginx和php环境

[转]使用socket方式连接Nginx优化php-fpm性能


nginx 中 nginx.conf可以设置共存

    upstream php {
        server unix:/home/work/var/run/php.sock  weight=1 max_fails=2 fail_timeout=30s;
    }   

    upstream php7 {
        server unix:/home/work/var/run/php7.sock  weight=1 max_fails=2 fail_timeout=30s;
    }  

子配置的文件


server {
    listen 80;
    root /path/to;

    location @php {
        include fastcgi_params;
        fastcgi_param  SCRIPT_FILENAME "$document_root/index.php";
        fastcgi_pass php7;
    }   

    location ~ /robots\.(txt|php) {
        include fastcgi_params;
        fastcgi_param  SCRIPT_FILENAME "$document_root/robots.php";
        fastcgi_pass php;
    }   

    location ~ \.php$ {
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_pass php7;
        fastcgi_index index.php;
    }   


    location / { 
        try_files $uri @php;
    }   
}

php-fpm.conf

[www]
user = work
group = work
listen = /home/work/var/run/php7.sock

6安装mysql
sudo yum install -y mysql-server mysql mysql-deve
sudo service mysqld start
sudo chkconfig mysqld on
/usr/bin/mysqladmin -u root password ‘newpassword’
7安装redis和memcache

1CentOs安装redis和memcached扩展


因为是php7环境,用新的phpredis扩展
https://github.com/edtechd/phpredis

发表评论

电子邮件地址不会被公开。 必填项已用*标注


*