安装nginx
1.yum安装
yum -y install gcc //gcc是linux下的编译器
yum install -y pcre pcre-devel //pcre是一个perl库,包括perl兼容的正则表达式库,nginx的http模块使用pcre来解析正则表达式
yum install -y zlib zlib-devel //zlib库提供了很多种压缩和解压缩方式nginx使用zlib对http包的内容进行gzip
yum install -y openssl openssl-devel //openssl是web安全通信的基石
yum install -y nginx --nogpgcheck //安装nginx
2.访问不了欢迎页面时
firewall-cmd --list-all //查看防火墙状态
systemctl start firewalld //启动防火墙
firewall-cmd --permanent --zone=public --add-port=80/tcp //新增80端口
systemctl restart firewalld //重启
3.nginx.conf
server_name server_domain_name_or_101.37.70.99; //加上访问地址
安装PHP7
1.更新yum源
//CentOS/RHEL 7.x:
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
//CentOS/RHEL 6.x:
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el6/latest.rpm
2.安装扩展
yum install php70w-common php70w-fpm php70w-opcache php70w-gd php70w-mysqlnd php70w-mbstring php70w-pecl-redis php70w-pecl-memcached php70w-devel
参考:https://blog.csdn.net/zhezhebie/article/details/73325663
php -v //版本
php -m //扩展
3.nginx配置
//nginx.conf
listen 8080 default_server;
listen [::]:8080 default_server;
server_name _;
root /home/smartweb;
//conf.d/default.conf
server {
listen 80;
server_name server_domain_name_or_101.37.70.99;
# note that these lines are originally from the "location /" block
root /home/smartweb;
index index.php index.html index.htm;
location / {
if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php/$1 last;
break;
}
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /home/smartweb;
}
location ~ \.php$ {
root /home/smartweb;
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
4.配置php
// /etc/php.ini
cgi.fix_pathinfo=0;
// /etc/php-fpm.d/www.conf
user = nginx
group = nginx
listen = /var/run/php-fpm/php-fpm.sock
listen.owner = nginx
listen.group = nginx
参考:https://www.cnblogs.com/huangju6/p/10367628.html
mariadb安装
yum install mariadb-server mariadb
systemctl start mariadb
mysqladmin -u root password 123456
mysql -uroot -p123456
//输入下面两条命令在数据库命令行里面
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'Spark008' WITH GRANT OPTION;
FLUSH PRIVILEGES;
set password for root@localhost = password('Spark008');
quit; //退出
注:远程连接不上 阿里云安全组增加3306端口
开机自启
systemctl enable php-fpm.service
systemctl enable nginx.service
systemctl enable mariddb