Software Engineering,

MAC OSX Kullanarak Localhost üzerinde LEMP Stack ve PHP-FPM Yüklemesi

Bu yazının sonunda MAC OSX üzerine LEMP Stack ve PHP-FPM'i kurup konfigüre etmiş olacaksınız.

Step 1: Update your XCode from App Store

Step 2: Install and update Homebrew

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew update
brew doctor

Make sure you don’t get any major errors after running brew doctor command. Small warnings are okay.

Step 3: Install PHP-FPM

brew tap homebrew/dupes
brew tap homebrew/php
brew install –without-apache –with-fpm –with-mysql php56

Setup PHP CLI binary

Update the $PATH environment variable of your shell profile for using PHP Command Line Tools.

echo 'export PATH="/usr/local/sbin:$PATH"' >> ~/.bash_profile && . ~/.bash_profile

Setup Auto Start

Create a folder for the LaunchAgents and symlink the start/stop service:

mkdir -p ~/Library/LaunchAgents
ln -sfv /usr/local/opt/php56/homebrew.mxcl.php56.plist ~/Library/LaunchAgents/

Start PHP-FPM

launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.php56.plist

MariaDB

Install the latest MariaDB

brew remove mysql
brew install mariadb
unset TMPDIR

Now check your MariaDB version first and run the following commands according to your version.

brew info mariadb
cd /usr/local/Cellar/mariadb/10.1.8/(change with your version)
mysql_install_db

Now start MariaDB

mysql.server start

Secure the MariaDB Installation

mysql_secure_installation

Set the root password as you wish.

Now connect to MariaDB

mysql -u root -p

Enter your password and try to run the basic commands to see if you have any errors with the installation.

show databases;
show engines;
exit;

Install Nginx

brew install nginx

Start Nginx for the first time

sudo launchctl load /Library/LaunchDaemons/homebrew.mxcl.nginx.plist

Setup auto launch Nginx as root

sudo cp -v /usr/local/opt/nginx/*.plist /Library/LaunchDaemons/
/usr/local/opt/nginx/homebrew.mxcl.nginx.plist
sudo chown root:wheel /Library/LaunchDaemons/homebrew.mxcl.nginx.plist
sudo launchctl load /Library/LaunchDaemons/homebrew.mxcl.nginx.plist

Stop Nginx

sudo launchctl unload /Library/LaunchDaemons/homebrew.mxcl.nginx.plist

Create the following folders for logs, virtual servers and etc.

mkdir -p /usr/local/etc/nginx/logs
mkdir -p /usr/local/etc/nginx/sites-available
mkdir -p /usr/local/etc/nginx/sites-enabled
mkdir -p /usr/local/etc/nginx/conf.d
mkdir -p /usr/local/etc/nginx/ssl
sudo mkdir -p /var/www
sudo chown :staff /var/www
sudo chmod 775 /var/www

Remove the current Nginx configuration file.

rm /usr/local/etc/nginx/nginx.conf

The file is also available in /usr/local/etc/nginx/nginx.conf.default.

Create a new file then copy and paste the following content;

sudo vi /usr/local/etc/nginx/nginx.conf

worker_processes 1;

error_log /usr/local/etc/nginx/logs/error.log debug;

events {
worker_connections 1024;
}

http {
include mime.types;
default_type application/octet-stream;

log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

access_log /usr/local/etc/nginx/logs/access.log main;

server_names_hash_bucket_size 64;
sendfile on;
keepalive_timeout 65;
index index.php index.htm index.html;

include /usr/local/etc/nginx/sites-enabled/*;
}

That’s it for Nginx configuration! I will be adding the configuration samples for virtual hosts soon.

0no comment

writer

The author didnt add any Information to his profile yet

Bir Cevap Yazın

tr_TRTurkish
en_USEnglish tr_TRTurkish
%d blogcu bunu beğendi: