Linux
版本为CentOS7
Nginx
装默认版本MySQL
为MariaDB
PHP
装的版本为PHP71
HTTP
服务HTTPS
服务(可选)MySQL
服务yum install nginx -y
nginx
systemctl enable nginx
server
层(图中红色圈中部分),统一在/etc/nginx/conf.d/*.conf
配置include /etc/nginx/conf.d/
添加配置即可vi /etc/nginx/conf.d/blog.conf
# 每一个 .conf 文件就写这么多配置即可
server {
# 监听的端口,多个配置文件汇总 listen和server_name不能完全相同,必须两个之中有一个不同
listen 80;
# 监听的域名(如果有域名解析到服务器,填在这里,多个用空格隔开)
server_name localhost;
# 网站根路径,我喜欢把网站放在 /var/www/ ,个人随意
root /var/www/blog;
# 网站默认首页
index index.php index.html index.htm;
# 这个并不是必须的,如果使用 Laravel 会需要到
location / {
try_files $uri $uri/ /index.php?$query_string;
}
# 如果只是运行静态文件,可以忽略
# 但要运行 PHP 必须配置 Nginx 反向代理
location ~ .php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
nginx -s reload
MySQL
的社区版本MariaDB
yum -y install mariadb mariadb-server
systemctl start mariadb
systemctl enable mariadb
mysql_secure_installation
Enter current password for root (enter for none):
<–初次运行直接回车Set root password? [Y/n]
<– 是否设置root用户密码,输入y并回车或直接回车New password:
<– 设置root用户的密码Re-enter new password:
<– 再输入一次你设置的密码Remove anonymous users? [Y/n]
<– 是否删除匿名用户,回车Disallow root login remotely? [Y/n]
<–是否禁止root远程登录,回车,Remove test database and access to it? [Y/n]
<– 是否删除test数据库,回车Reload privilege tables now? [Y/n]
<– 是否重新加载权限表,回车mysql -uroot -p
Enter password:
输入配置中设置的密码进入数据库create user username@localhost identified by 'password';
grant all privileges on *.* to username@'%' identified by 'password';
FLUSH PRIVILEGES;
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
php71w
和各种拓展,选自己需要的即可。 yum install php71w php71w-cli php71w-common php71w-devel php71w-embedded php71w-fpm php71w-gd php71w-mbstring php71w-mysqlnd php71w-opcache php71w-pdo php71w-xml
php -v
systemctl start php-fpm
systemctl enable php-fpm
/var/www/blog;
mkdir /var/www/blog
vi /var/www/blog/index.php
<?php
phpinfo();