最近在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