阿裏雲Centos7上搭建LNMP辦事器情況,爲小我博客和Laravel商城開辟做預備。
裝置
1、裝置 Nginx :
yum install nginx18 -y
systemctl start nginx.service #啓動nginx
systemctl stop nginx.service #停滯nginx
systemctl restart nginx.service #重啓nginx
systemctl enable nginx.service #設置nginx開機啓動
2、裝置MariaDB(CentOS 7.0中,曾經應用MariaDB替換了MySQL數據庫)
裝置
yum install mariadb mariadb-server -y #裝置
systemctl start mariadb.service #啓動MariaDB
systemctl stop mariadb.service #停滯MariaDB
systemctl restart mariadb.service #重啓MariaDB
systemctl enable mariadb.service #設置開機啓動
cp /usr/share/mysql/my-huge.cnf /etc/my.cnf #拷貝設置裝備擺設文件(留意:假如/etc目次上面默許有一個my.cnf,直接籠罩便可)
設置Root暗碼
mysql_secure_installation
#回車,依據提醒輸出Y
#輸出2次暗碼,回車
#依據提醒一路輸出Y
#最初湧現:Thanks for using MySQL!
#MariaDB暗碼設置完成,從新啓動 MariaDB:
systemctl restart mariadb.service #重啓MariaDB
3、裝置 PHP :
建議將上面插件一次性裝置,如mbstring、openssl插件,防止零丁裝置湧現的坑~~!
yum install php71w-fpm php71w-mysql php71w-mysqli php71w php71w-opcache php71w-gd php71w-intl php71w-mbstring php71w-exif php71w-mcrypt php71w-openssl -y
php辦事相幹操作
systemctl start php-fpm.service #啓動php-fpm
systemctl stop php-fpm.service #停滯php-fpm
systemctl restart php-fpm.service #重啓php-fpm
systemctl enable php-fpm.service #設置開機啓動
設置裝備擺設
1、設置裝備擺設php-fpm:
vi /etc/php-fpm.d/www.conf
#修正user和group
user = nginx
group = nginx
2、設置裝備擺設 Nginx:
server {
listen 80 default_server;
# listen [::]:80 default_server;
server_name www.geek720.com;
# set $root_path /var/www/laravel/market/public/;
set $root_path /var/www/websites/blog;
root $root_path;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
index index.html index.htm index.php;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
location ~ \.php {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index /index.php;
include /etc/nginx/fastcgi_params;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
location ~* ^/(css|img|js|flv|swf|download)/(.+)$ {
root $root_path;
}
location ~/\.ht {
deny all;
}
}
3、重啓nginx辦事
service nginx restart
4、在設置裝備擺設目次/var/www/websites/blog下,創立測試文件index.php,如能正常訪問,則裝置正常。