Nginx MySQL PHP Development Tips

Mondo Technology Updated on 2024-01-29

Install nginx:

sudo apt-get updatesudo apt-get install nginx
Install MySQL

sudo apt-get install mysql-server mysql-client
Install the database structure:

sudo mysql_install_db
Make some security settings:

sudo mysql_secure_installation
Install php:

sudo apt-get install php5-fpm php5-mysql php5-cli
Configure the PHP process.

sudo nano /etc/php5/fpm/php.ini
willcgi.fix_pathinfoSet to

cgi.fix_pathinfo=0
sudo service php5-fpm restart
Configure nginx and php:

sudo nano /etc/nginx/sites-**ailable/default
server error_page 404 /404.html; error_page 500 502 503 504 /50x.html; location = /50x.html location ~ php$ }
sudo service nginx restart
sudo apt-get install php5-curl php5-mcrypt php5-intl php5-apcu php5-redis php5-memcached php5-mongo
sudo php5enmod mcrypt
In/var/wwwNew Site Directory:

sudo mkdir -p /var/www/example.com/html
Grant permissions:

sudo chown -r $user:$user /var/www/example.com/htmlsudo chmod -r 755 /var/www
sudo cp /etc/nginx/sites-**ailable/default /etc/nginx/sites-**ailable/example.com
example.com

server error_page 404 /404.html; error_page 500 502 503 504 /50x.html; location = /50x.html location ~ php$ }
Enable Site:

sudo ln -s /etc/nginx/sites-**ailable/example.com /etc/nginx/sites-enabled/
Remove Default Site:

sudo rm /etc/nginx/sites-enabled/default
Configuration:

sudo nano /etc/nginx/nginx.conf
server_names_hash_bucket_size 64;
sudo service nginx restart
server error_page 404 /404.html; error_page 500 502 503 504 /50x.html; location = /50x.html location ~ php$ }
gzip on; gzip_vary on; gzip_proxied any; gzip_comp_level 6; gzip_buffers 16 8k; gzip_http_version 1.1; gzip_types text/plain text/css application/json application/j**ascript text/xml application/xml application/xml+rss text/j**ascript;### virtual host configs##include /etc/nginx/conf.d/*.conf;include /etc/nginx/sites-enabled/*;

Related Pages