版权声明:如需转载,请注明作者及出处 https://blog.csdn.net/qq_33317586/article/details/85237778
一直以来,都是在ubuntu上部署的,今天突然来了一个centos7.4的机器要部署环境
先说下坑:没怎么在centos7上装过php7,关键在于源
网上第一次找的php7源如下:
#rpm -Uvh https:
//dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
#rpm -Uvh https:
//mirror.webtatic.com/yum/el7/webtatic-release.rpm
web需要用到memcache的php插件,这个插件应该有两个
php7-memcache,php7-memcached,但是这个源中没有php7-memcache,如下图
所以一直搞不定,索性再查,查到下面源
大概是从这个网站先看到:https://xieye.iteye.com/blog/2429305,然后在搜索这个源用的人多不多,发现还可以
yum install -y http://rpms.remirepo.net/enterprise/remi-release-7.rpm
于是乎解决:
下面说下整个操作流程:一切建立在centos7.4上
一、装nginx
[root@qqq ~]# wget https://raw.githubusercontent.com/uscwifi/yum-repository/master/nginx-centos7.repo -O /etc/yum.repos.d/nginx.repo
[root@qqq ~]# yum repolist
[root@qqq ~]# yum install nginx -y
二、装php7及相关插件
[root@qqq ~]# yum install -y http://rpms.remirepo.net/enterprise/remi-release-7.rpm
[root@qqq ~]# yum repolist
[root@qqq ~]# yum install php70-php php70-php php70-php-bcmath php70-php-common php70-php-devel php70-php-fpm php70-php-gd php70-php-mbstring php70-php-mcrypt php70-php-mysqlnd php70-php-pecl-memcache php70-php-pecl-memcached -y
三、装memcache
[root@qqq ~]# yum install memcached libmemcached -y
四、拉代码,写nginx配置文件
[root@qqq ~]# mkdir -p /var/www
[root@qqq ~]# cd /var/www/
[root@qqq www]# git clone https://gitlab.x.xxx.com/cactus/xxx_banckend.git
[root@qqq www]# cd /etc/nginx/conf.d/
[root@qqq conf.d]# vim xxx.xxx.com.conf
[root@qqq conf.d]# cat xxx.xxx.com.conf
server {
listen 80 ;
server_name xxx.xxx.com;
if ($host ~ xxx.xxx.com)
{
rewrite ^/(.*)$ https://xxx.xxx.com.com$request_uri? permanent;
}
access_log /var/log/nginx/xxx.xxx.com-access.log;
error_log /var/log/nginx/xxx.xxx.com-error.log;
}
server {
listen 443;
server_name xxx.xxx.com;
root /var/www/Tianzige_banckend/web;
index index.html index.htm index.php ;
ssl on ;
ssl_certificate /etc/nginx/ssl/xxx.xxx.com.cer;
ssl_certificate_key /etc/nginx/ssl/xxx.xxx.com.key;
ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_ciphers ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AES:RSA+3DES:!aNULL:!MD5:!DSS;
access_log /var/log/nginx/xxx.xxx.com-access.log;
error_log /var/log/nginx/xxx.xxx.com-error.log;
location ~ \.(gif|jpg|jpeg|png|css|js|ico)$ {
}
location ~ ^/favicon\.ico$ {
root /var/www/sites/8083/xxxx-backend/web/;
}
location / {
rewrite ^/(.+)$ /index.php last;
}
location ^~ /api/ {
proxy_pass xxx.xxx.com/;
proxy_redirect default ;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
#fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_index index.php;
fastcgi_buffer_size 128k;
fastcgi_buffers 64 128k;
fastcgi_intercept_errors on;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param HTTP_AUTHORIZATION $http_authorization;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_connect_timeout 300;
fastcgi_read_timeout 300;
fastcgi_send_timeout 300;
client_max_body_size 100m;
}
location ~ /.git
{
deny all;
}
}
五、调节nginx进程数,php的进程数
[root@qqq conf.d]# vim /etc/nginx/nginx.conf
worker_processes auto;
[root@qqq conf.d]# vim /etc/opt/remi/php70/php-fpm.d/www.conf
pm.max_children = 50
pm.start_servers = 5
pm.min_spare_servers = 5
pm.max_spare_servers = 35
user = nginx
group = nginx
六、启动相关服务
[root@qqq ~]# systemctl start nginx
[root@qqq ~]# nginx -t
[root@qqq ~]# nginx -s reload
[root@qqq ~]# systemctl enable nginx
[root@qqq ~]# systemctl start memcached
[root@qqq ~]# systemctl enable memcached
[root@qqq ~]# systemctl start php70-php-fpm.service
[root@qqq ~]# systemctl enable php70-php-fpm.service
应该没了