一、PHP7.2安装步骤
php-7.2.14.tar.bz2
链接: https://pan.baidu.com/s/1gmrGbk6ar3RsyzpS5bFYjA 提取码: 7smr
http://cn2.php.net/distributions/php-7.2.14.tar.bz2
1.安装依赖
apt-get update
apt-get install -y build-essential
apt-get install -y autoconf
apt-get install -y bison
apt-get install -y libxml2
apt-get install -y libxml2-dev
apt-get install -y libssl1.0
apt-get install -y libssl1.0-dev
apt-get install -y libmhash2
apt-get install -y libmhash-dev
apt-get install -y mcrypt
apt-get install -y libmcrypt4
apt-get install -y libjpeg-dev
apt-get install -y libpng-dev
apt-get install -y libfreetype6-dev
apt-get install -y libcurl4-openssl-dev
2.编译
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-libdir=/lib/x86_64-linux-gnu --with-mhash --with-gd -with-jpeg-dir=/usr -with-png-dir=/usr -with-freetype-dir=/usr --enable-sockets --enable-pdo --enable-tokenizer --enable-ctype --enable-json --enable-bcmath --with-openssl --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --enable-mysqlnd-compression-support --enable-mbstring --enable-zip --enable-fpm
[ 注意事项 ]
如果是在Windows Linux subsystem子系统安装,则找到main/php_config.h。
做如下修改:
[ ======================== ]
-- #define HAVE_LQ_TCP_INFO 1
++ //#define HAVE_LQ_TCP_INFO 1
[ ======================== ]
make && make install
3.配置
groupadd nobody
4.部署
cp php.ini-production /usr/local/php/etc/php.ini -rf
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf -rf
cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf -rf
cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm -rf
chmod +x /etc/init.d/php-fpm
ln -s /etc/init.d/php-fpm /usr/bin/
vi /etc/profile
export PATH=/usr/local/php/bin:$PATH
source /etc/profile
如果需要单独编译模块
cd ./php-7.2.14/ext/sockets
/usr/local/php/bin/phpize
./configure --prefix=/usr/local/php/lib --with-php-config=/usr/local/php/bin/php-config --enable-sockets
make
make test
make install
如果配置完成以后总是返回500错误
vi /usr/local/php/etc/php.ini
找到display_errors,默认为
display_errors = Off
修改为
display_errors = On
保存,重启php-fpm。即可看到完整的错误信息
启动php-fpm
service php-fpm start
二、Nginx安装步骤
apt-get install -y nginx
配置PHP
vi /etc/nginx/sites-enabled/default
============================================================================================================
##
# You should look at the following URL's in order to grasp a solid understanding
# of Nginx configuration files in order to fully unleash the power of Nginx.
# https://www.nginx.com/resources/wiki/start/
# https://www.nginx.com/resources/wiki/start/topics/tutorials/config_pitfalls/
# https://wiki.debian.org/Nginx/DirectoryStructure
#
# In most cases, administrators will remove this file from sites-enabled/ and
# leave it as reference inside of sites-available where it will continue to be
# updated by the nginx packaging team.
#
# This file will automatically load configuration files provided by other
# applications, such as Drupal or Wordpress. These applications will be made
# available underneath a path with that package name, such as /drupal8.
#
# Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.
##
# Default server configuration
#
server {
# 此处修改nginx默认http服务端口(默认80,根据自己需要修改)
listen 8081 default_server;
listen [::]:8081 default_server;
# SSL configuration
#
# listen 443 ssl default_server;
# listen [::]:443 ssl default_server;
#
# Note: You should disable gzip for SSL traffic.
# See: https://bugs.debian.org/773332
#
# Read up on ssl_ciphers to ensure a secure configuration.
# See: https://bugs.debian.org/765782
#
# Self signed certs generated by the ssl-cert package
# Don't use them in a production server!
#
# include snippets/snakeoil.conf;
root /var/www/html/footwash/public;
# Add index.php to the list if you are using PHP
index index.php index.html index.htm index.nginx-debian.html;
server_name _;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
#try_files $uri $uri/ =404;
try_files $uri $uri/ /index.php?$query_string;
}
# pass PHP scripts to FastCGI server
#
#location ~ \.php$ {
# include snippets/fastcgi-php.conf;
#
# # With php-fpm (or other unix sockets):
# fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
# # With php-cgi (or other tcp sockets):
# fastcgi_pass 127.0.0.1:9000;
#}
# pass PHP scripts to FastCGI server
# 此处添加php解析,支持php文件访问
location ~ \.php$ {
include snippets/fastcgi-php.conf;
# With php-fpm (or other unix sockets):
#fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
# With php-cgi (or other tcp sockets):
fastcgi_pass 127.0.0.1:9000;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
# Virtual Host configuration for example.com
#
# You can move that to a different file under sites-available/ and symlink that
# to sites-enabled/ to enable it.
#
#server {
# listen 80;
# listen [::]:80;
#
# server_name example.com;
#
# root /var/www/example.com;
# index index.html;
#
# location / {
# try_files $uri $uri/ =404;
# }
#}
============================================================================================================
启动Nginx
service nginx start
三、Laravel5.7安装并创建工程
1.安装composer
官网:https://getcomposer.org/
下载地址:https://getcomposer.org/download/1.8.0/composer.phar
wget https://getcomposer.org/download/1.8.0/composer.phar
如果提示https或ssl错误,可以尝试:
wget https://getcomposer.org/download/1.8.0/composer.phar --no-check-certificate
下载完成后:
mv composer.phar composer
chmod +x composer
安装完成。(也可将composer放到系统bin下,根据自己需要)
2.composer创建laravel工程
./composer create-project --prefer-dist laravel/laravel footwash "5.7.*"
或
./composer create-project --prefer-dist laravel/laravel footwash "5.7.21"
设置存储目录权限
chmod 777 ./footwash/storage -R
四、至此已经完成搭建。