腾迅云 php nginx配置,腾讯云服务器centos上新装php+nginx以及虚拟机centos7.0
作为正式环境使用1.安装epel-release软件包,这个软件包会自动配置yum的软件仓库。当然你也可以不安装这个包,自己配置软件仓库也是一样的。yum install epel-release2.安装php7yum install -y --skip-broken php71w php71w-opcache php71w-bcmath php71w-cli php71w-common php7
作为正式环境使用
1.安装epel-release软件包,这个软件包会自动配置yum的软件仓库。当然你也可以不安装这个包,自己配置软件仓库也是一样的。
yum install epel-release
2.安装php7
yum install -y --skip-broken php71w php71w-opcache php71w-bcmath php71w-cli php71w-common php71w-dba php71w-devel php71w-embedded php71w-enchant php71w-fpm php71w-gd php71w-imap php71w-interbase php71w-intl php71w-ldap php71w-mbstring php71w-mcrypt php71w-mysqlnd php71w-odbc php71w-opcache php71w-pdo php71w-pdo_dblib php71w-pear php71w-pecl-apcu php71w-pecl-imagick php71w-pecl-xdebug php71w-pgsql php71w-phpdbg php71w-process php71w-pspell php71w-recode php71w-snmp php71w-soap php71w-tidy php71w-xml php71w-xmlrpc php71w-pecl-redis.x86_64
3.安装报错,升级一些源,包含php7和nginx
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el6/latest.rpm
rpm -Uvh http://repo.mysql.com/mysql-community-release-el6-5.noarch.rpm
4.重复2步骤安装nginx
yum install nginx
vim conf.d/default.conf
server {
listen 80 default_server;
server_name _;
root /usr/share/nginx/html;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location / {
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
5.按项目名添加nginx配置
vim /etc/nginx/conf.d/project.conf
server {
listen 80;
server_name project.website.com;
index index.php index.html;
root /data/web/work/project/web;
location / {
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php last;
}
}
location ~ .*\.php?$ {
try_files $uri =404;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_read_timeout 300;
limit_rate_after 200k; #当传输量大于此值时,超出部分将限速传送
limit_rate 30k;
}
access_log off;
}
6.按项目名添加https配置,证书需要在腾讯云上申请后下载
vim /etc/nginx/conf.d/project_https.conf
server {
listen 443;
server_name project.website.com;
ssl on;
ssl_certificate 1_project.website.com_bundle.crt;
ssl_certificate_key 2_project.website.com.key;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; #°´ÕÕÕâ¸öÐÒéÅäÖÃ
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;#°´ÕÕÕâ¸öÌ×¼þÅäÖÃ
ssl_prefer_server_ciphers on;
index index.php index.html;
root /data/web/work/project/web;
location / {
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php last;
}
}
location ~ .*\.php?$ {
try_files $uri =404;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_read_timeout 300;
}
access_log off;
}
7.启动php和nginx(7.0需要安装fpm,关闭防火墙,修改selinux=disabled)
8.git拉取项目代码,安装git,创建工作目录
mkdir /data/web/work
cd /data/web/work/
yum install git
ssh-keygen -t rsa -C "nothingpp@youremail.com" -b 4096
cat ~/.ssh/id_rsa.pub /*将key添加到git站点ssh*/
git clone https://github.com/nothdo/mycode.git
魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。
更多推荐

所有评论(0)