Linux-nginx安装
更新安装源:
rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
安装:
yum -y install nginx
Nginx命令:
service nginx start 开启
service nginx restart 重启
service nginx reload 重新载入
systemctl enable nginx 开机自启
Linux-php 安装
更新安装源
rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
安装(及其扩展):
yum install -y php70w php70w-opcache php70w-xml php70w-mcrypt php70w-gd php70w-devel php70w-MySQL php70w-intl php70w-mbstring php70w-gd php70w-ldap php70w-odbc php70w-pear php70w-xmlrpc php70w-snmp php70w-soap curl curl-devel
安装php-fpm(nginx-php扩展)
yum -y install php70w-fpm
systemctl start php-fpm 启动
systemctl enable php-fpm 开机自启动
systemctl reload php-fpm 重新载入
修改nginx配置文件,关联php
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
server {
listen 443;
listen 80;
server_name xxx.com;
root /data/www/xxx.com;
index index.html index.htm index.php;
charset utf-8;
ssl on;
ssl_certificate /usr/local/nginx/conf/cert/1_api.xiaoka.io_bundle.crt;
ssl_certificate_key /usr/local/nginx/conf/cert/2_api.xiaoka.io.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;
location / {
if (!-e $request_filename){
rewrite ^/(.*)$ /index.php/$1 last;
}
}
location ~ \.php {
root /data/www/xxx.com;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_split_path_info ^(.+\.php)(.*)$; #增加这一句
fastcgi_param PATH_INFO $fastcgi_path_info; #增加这一句
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
安装Linux-mysql
1.安装
yum -y install mariadb*
2.开启MySQL服务
systemctl start mariadb.service
3.设置开机启动MySQL服务
systemctl enable mariadb.service
4.设置root帐户的密码
mysql_secure_installation
然后会出现一串东西,可以仔细读一下,如果你懒得读,就在提示出来的时候,按Enter就好了,让你设置密码的时候,你就输入你想要的密码就行,然后继续在让你选择y/n是,Enter就好了;当一切结束的时候,你可以输入mysql -uroot -p的方式,验证一下;
六、将PHP和MySQL关联起来
yum search php,选择你需要的安装:yum -y install php70w-mysql
开启远程登录
mysql -uroot -proot 进入MySQL控制
进入MariaDB服务器,将mysql.user的host字段的值改为%就表示在任何客户端机器上能以root用户登录到mysql服务器,建议在开发时设为%。
1 MariaDB [(none)]> use mysql
2
3 Database changed
4 MariaDB [mysql]> update user set host = '%' where user = 'root';
5
6 Query OK, 1 row affected (0.11 sec)
7 Rows matched: 1 Changed: 1 Warnings: 0
授予任何主机访问数据的权限:
1 MariaDB [mysql]> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root'
2 WITH GRANT OPTION;
3 Query OK, 0 rows affected (0.00 sec)
刷新权限配置,使之生效:
1 MariaDB [mysql]> FLUSH PRIVILEGES;