最近在hostos上买了个香港的 vps, 装的 centos7, 在架设了 pptp vpn, 效果还行,就想顺便架设个 laravel 看看.下面是架设的过程.
准备工作
- 更新 yum 源,自带的源没有 PHP5.6 :
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
- 安装 epel:
yum install epel-release
- 然后更新下系统:
yum update
准备工作完成,开始安装!
- 安装 Mariadb:
yum -y install mariadb.x86_64 mariadb-server.x86_64 mariadb-devel.x86_64
然后使用下面命令设置root密码:mysql_secure_installation
- 安装 Nginx :
yum install nginx18
- 安装 PHP :
yum install php56w-fpm php56w-mysql php56w-mysqli php56w php56w-opcache php56w-gd php56w-intl php56w-mbstring php56w-exif php56w-mcrypt php56w-openssl
之前试过没装够php extension , laravel 死活报错,现在怕了,一次装够他
安装大概就是这样了,下面是配置:
1.首先配置下 php.ini 我的系统默认安装后 php.ini 的位置是 /etc/php.ini 主要需要修改的有下面这些:cgi.fix_pathinfo=0
--这个原先是注释的,取消注释把值改成0就行
下面这些加在最后,好像不加也可以.
extension=gd.so
extension=intl.so
extension=mbstring.so
extension=exif.so
extension=mysql.so
extension=mysqli.so
extension=pdo.so
2.配置 Nginx:vi /etc/nginx/nginx.conf
把配置文件里面的 server{ ****}这部分替换成下面这段就可以了
server {
listen 80;
server_name example.com;
location / {
root /usr/share/nginx/html/laravel/public;
try_files $uri $uri/ /index.php?$query_string;
index index.php index.html index.htm;
}
error_page 404 /404.html;
location = /404.html {
root /usr/share/nginx/html/laravel/public;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html/laravel/public;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
root /usr/share/nginx/html/laravel/public;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
- 配置 php-fpm :
vi /etc/php-fpm.d/www.conf
修改user和groupuser = nginx` group = nginx
环境搭建完就可以安装Laravel了 也就是那几条命令:curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer
composer global require "laravel/installer=~1.1"
cd /usr/share/nginx/html/
laravel new laravel
时间: 2024-10-05 23:54:44