How do I set up phpMyAdmin on a Laravel Homestead box? - nginx

I installed it by running sudo apt-get install phpymyadmin and then running
sudo ln -s /usr/share/phpmyadmin/ /usr/share/nginx/html and sudo service nginx restart
but it's not working.
Note: I didn't select any of the apache2 or lighttpd options when installing.

Option 1:
This will install the latest version of PhpMyAdmin from a shell script I've written. You are welcome to check it out on Github.
Run the following command from your code/projects directory:
curl -sS https://raw.githubusercontent.com/grrnikos/pma/master/pma.sh | bash
Option 2:
This will install PhpMyAdmin (not the latest version) from Ubuntu's repositories. Assuming that your projects live in /home/vagrant/Code :
sudo apt-get install phpmyadmin Do not select apache2 nor lighttpd when prompted. Just hit tab and enter.
sudo ln -s /usr/share/phpmyadmin/ /home/vagrant/code/phpmyadmin
cd ~/Code && serve phpmyadmin.test /home/vagrant/code/phpmyadmin
Note: If you encounter issues creating the symbolic link on step 2, try the first option or see Lyndon Watkins' answer below.
Final steps:
Open the /etc/hosts file on your main machine and add:
127.0.0.1 phpmyadmin.test
Go to http://phpmyadmin.test:8000

Step 1:
Go to the phpMyAdmin website, download the latest version and unzip it into your code directory
Step 2:
Open up homestead.yaml file and add these lines
folders:
- map: /Users/{yourName}/Code/phpMyAdmin
to: /home/vagrant/Code/phpMyAdmin
sites:
- map: phpmyadmin.test
to: /home/vagrant/Code/phpMyAdmin
Step 3:
Open your hosts file and add this line:
127.0.0.1 phpmyadmin.test
Step 4:
You may need to run vagrant provision to load the new configuration if vagrant is already running.
Thats it
Go to http://phpmyadmin.test:8000. It should work from there. Great thing about this method is that if you ever need to destroy your box, you won't ever have to set up phpMyAdmin again so long as you keep your homestead.yaml file and phpMyAdmin in your code directory.
===========
Important update from DaneSoul:
I tried this instruction on Homestead 5.3 and have met a problem "No input file specified" when trying open http://phpmyadmin.test.
And finnaly I found solution:
You need unpack phpmyadmin to
/home/vagrant/Code/phpMyAdmin/public
And write in homestead.yaml
- map: phpmyadmin.test
to: /home/vagrant/Code/phpMyAdmin/public
So almost all the same, but this /public directory in paths makes it working!
Also, in my configuration I use http://phpmyadmin.test, not http://phpmyadmin.test:8000.
Update Note: Follow this article to change your domain extension.

The answer from Nikos Gr worked for me; however I needed to amend steps 2 and 3 as my host system has issues creating the symlink.
I changed:
sudo ln -s /usr/share/phpmyadmin/ /home/vagrant/Code/phpmyadmin
cd ~/Code && serve phpmyadmin.app /home/vagrant/Code/phpmyadmin
To:
cd ~/Code && serve phpmyadmin.app /usr/share/phpmyadmin/
(Couldn't comment on the original solution as my rep isn't high enough!)

A simplified version of Jyeon's Answer. You don't need to share the ~/Code folder in the Homestead.yaml file:
folders:
- map: /Users/{yourName}/Code/phpMyAdmin
to: /home/vagrant/Code/phpMyAdmin
Just download the latest version of PhpMyAdmin from PhpMyAdmin and put the unzipped file in the ~/Code/phpMyAdmin folder and just follow the 2 step here:
Step 1:
Open up homestead.yaml file and add these lines
sites:
- map: phpmyadmin.app
to: /home/vagrant/Code/phpMyAdmin
Step 3:
Open up your hosts file and add this line:
192.168.10.10 phpmyadmin.app
Now run the vagrant reload --provision command and you're good to go.
Open up the phpmyadmin.app address in your browser and you'll see the phpmyadmin interface.

Install phpMyAdmin
SSH into Homestead vagrant box with vagrant ssh and type the following command:
sudo apt-get install phpmyadmin
When prompted to select the Web server, select apache2 and press Enter, just to get pass it.
When prompted to config database for phpmyadmin with dbconfig-common, select Yes and press Enter.
When prompted for Password of the database's administrative user, enter secret and press Enter.
When prompted for MySQL application password for phpmyadmin, enter secret and press Enter.
When prompted for Password confirmation, enter secret again and press Enter.
Then Create and config site for Nginx
sudo ln -s /usr/share/phpmyadmin/ /usr/share/nginx/html/phpmyadmin
cd /etc/nginx/sites-available
sudo cp homestead.app phpmyadmin.app
sudo sed -i 's/homestead.app/phpmyadmin.app/g' /etc/nginx/sites-available/phpmyadmin.app
sudo sed -i 's/home\/vagrant\/Code\/Laravel\/public/usr\/share\/nginx\/html\/phpmyadmin/g' /etc/nginx/sites-available/phpmyadmin.app
sudo ln -s /etc/nginx/sites-available/phpmyadmin.app /etc/nginx/sites-enabled/phpmyadmin.app
sudo service nginx restart
sudo service php5-fpm retart
Adding phpMyAdmin.app to your hosts file
127.0.0.1 phpmyadmin.app
Navigate to http://phpmyadmin.app:8000 and you should now see phpMyAdmin login page.
More info available here if you need it

A variation on Nikos Gr's answer that seemed a bit simpler (in that it doesn't require a new symbolic link for each project on your Homestead box) and worked for me.
Inside the Homestead box, run sudo apt-get install phpmyadmin. Don't select any of the options during install.
On your host machine, add the following lines to your Homestead.yaml file:
- map: phpmyadmin.dev
to: /usr/share/phpmyadmin
On your host machine, add the following line to your hosts file:
192.168.10.10 phpmyadmin.dev
...and Homestead's phpMyAdmin will be available at phpmyadmin.dev

You can install phpmyadmin automatically when you vagrant up or provision your homestead by adding the following snippet to your Homestead\scripts\homestead.rb file after # Update Composer On Every Provision
# Install phpMyAdmin on every provision
config.vm.provision "shell" do |s|
s.inline = "curl -sS https://raw.githubusercontent.com/grrnikos/pma/master/pma.sh | sh"
end
Your hoomestead.rb file should now look somehow like this
class Homestead
def Homestead.configure(config, settings)
# Configure The Box
config.vm.box = "laravel/homestead"
config.vm.hostname = "homestead"
# Configure A Private Network IP
config.vm.network :private_network, ip: settings["ip"] ||= "192.168.10.10"
some other entries are truncated to keep this short
# Update Composer On Every Provision
config.vm.provision "shell" do |s|
s.inline = "/usr/local/bin/composer self-update"
end
# Install phpMyAdmin on every provision
config.vm.provision "shell" do |s|
s.inline = "curl -sS https://raw.githubusercontent.com/grrnikos/pma/master/pma.sh | sh"
end
# Configure Blackfire.io
if settings.has_key?("blackfire")
config.vm.provision "shell" do |s|
s.path = "./scripts/blackfire.sh"
s.args = [settings["blackfire"][0]["id"], settings["blackfire"][0]["token"]]
end
end
end
end
Save file and run vagrant destroy then vagrant up or just vagrant reload
NB: This uses Nikos Gr script located here https://raw.githubusercontent.com/grrnikos/pma/master/pma.sh

Finally it worked for me, few things I had to fix:
Homestead.yaml file:
- map: phpmyadmin.test
to: /home/vagrant/code/phpmyadmin/
I had to delete /public from the end. I installed phpmyadmin (after vagrant ssh command from Homestead directory) into the 'code' folder where the other projects are. When 'code' is with lowercase, it has to be everywhere so (or other way around): folder name, yaml file or even after installation performing these commands:
sudo ln -s /usr/share/phpmyadmin/ /home/vagrant/code/phpmyadmin
cd ~/code && serve phpmyadmin.test /home/vagrant/code/phpmyadmin

This is the most simple solution. No mapping and all needed.
Download latest phpmyadmin version from here https://www.phpmyadmin.net/downloads
Make a folder named phpmyadmin inside your main root/public folder and unzip phpmyadmin here.
Run yourwebsite.com/phpmyadmin

I am writing here the way I followed to make my local vagrant environment work-friendly.
Step 1 - Start the vagrant and login
vagrant up
vagrant ssh
Step 2 - Go to your correct directory. (Depends on your file tree)
cd <VagrantDirectory>
Step 3 - Install phpmyadmin.
curl -sS https://raw.githubusercontent.com/grrnikos/pma/master/pma.sh | bash
Step 4 - Configure the Homestead.yaml
map: phpmyadmin.test
to: /home/vagrant/<VagrantDirectory>/phpmyadmin
Step 5 - Reload the vagrant.
vagrant reload
Step 6 - Configure phpmyadmin
Go to your phpmyadmin directory. Copy config.sample.inc.php to config.inc.php
cp config.sample.inc.php config.inc.php
Step 7 - Edit config.inc.php with your text editor and place your new configuration there.
//Comment out the old configuration that was already here.
$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['host'] = 'localhost'; // Also works with the IP address.
$cfg['Servers'][$i]['user'] = 'homestead'; // Username of MySQL, Default is homestead.
$cfg['Servers'][$i]['password'] = 'secret'; // Password. Default password is secret
$cfg['Servers'][$i]['extension'] = 'mysqli';
$cfg['Servers'][$i]['compress'] = false;
$cfg['Servers'][$i]['AllowNoPassword'] = false;
$cfg['CheckConfigurationPermissions'] = false; // Since you are on local, Leave this false.
Step 8 - Now browse your fresh PHPMyAdmin on your favorite browser.
http://phpmyadmin.test

For another alternative that I found super simple and that worked right out of the box I set up a new Nginx site from inside the Homestead box using the serve.sh script:
serve adminer.app /home/vagrant/Code/adminer/
And then in there I dropped the one page successor to phpmyadmin, Adminer. I also renamed it to "index.php" to make it just work. Then after adding the adminer.app entry to my hosts file I was good to go.
Had not used a web based MySQL interface in years since I just didn't like maintaining phpMyAdmin but this one is sweet. One file (plus an optional CSS file if you want a nicer theme) and that is all. Easy to maintain and update.

As I couldn't comment on the Jyeon solution as my rep isn't high enough, I contribute with this answer; worked for me in Linux (openSUSE Leap) with Vagrant 1.8.1 and laravel/homestead (virtualbox, 0.4.0):
Step 1:
Go to phpMyAdmin website, download the latest version and unzip it into your project directory.
Step 2:
Add to your Homestead.yaml file the following lines:
folders:
- map: ~/Code/phpMyAdmin
to: /home/vagrant/Code/phpMyAdmin
Sites:
- map: phpmyadmin.app
to: /home/vagrant/Code/phpMyAdmin
Step 3:
Add to your hosts file the following line:
192.168.10.10 phpmyadmin.app
Step 4:
After start your vagrant environment and connects to machine via SSH, set your virtual host to work with phpMyAdmin with the command serve:
cd ~/Code
serve phpmyadmin.app /home/vagrant/Code/phpMyAdmin/
Thats it!
Go to http://phpmyadmin.app it should work, and you can login with your user and password homestead default. The great thing about this method is that you can set up your phpmyadmin so long as you keep it in your Homestead.yaml file and phpMyAdmin in your Code directory.

In my case accepted solution works ok except:
$ cd ~/Code && serve phpmyadmin.app /home/vagrant/Code/phpmyadmin
dos2unix: converting file /vagrant/scripts/serve.sh to Unix format ...
* Restarting nginx nginx [fail]
php5-fpm stop/waiting
php5-fpm start/running, process 4112
For an unknown reason serve command files creating configuration file as seen in:
$ sudo tail -f /var/log/nginx/error.log
2015/03/18 11:54:16 [emerg] 3671#0: invalid number of arguments in "listen" directive in /etc/nginx/sites-enabled/phpmyadmin.app:2
Edit config:
$ editor /etc/nginx/sites-enabled/phpmyadmin.app
and add 80 to Listen directive at line 2. Apply changes with:
$ sudo service nginx reload

adminer index file is located in adminer/adminer so try :
serve adminer.app /home/vagrant/Code/adminer/adminer

I installed phpMyAdmin from here
then put these settings in config.inc.php:
/* Server parameters */
$cfg['Servers'][$i]['host'] = '127.0.0.1';
$cfg['Servers'][$i]['port'] = '33060';
$cfg['Servers'][$i]['compress'] = false;
$cfg['Servers'][$i]['AllowNoPassword'] = false;
and opened via Apache (I had a xampp). In my case i placed phpMyAdmin in D:\xampp\htdocs\pma which allowed me to open at localhost/pma url.
Everything worked!

Related

How to work with wordpress dévelopment server?

I'm testing WordPress for personnal project but i would like to install locally my development WordPress website and install on my Personnal production server the final website.
In order to do that, i search a plugin or program for syncronising wordpress dévelopment with new pages, templates, and configurations inside my production wordpress.
Is there a program or plugin to do that? How is much better to work with wordpress?
Thanks :)
There are two topics you can try:
-.By schedule copy files to production like linux CLI with crontab (every min):
* * * * * scp local_file remote_username#remote_ip:remote_file
But I don't recommend this way , and for you to easy understand.
-.By CICD, here is a blog link for you to know the concept first if you don't know this:
https://thecodingmachine.io/continuous-delivery-on-a-dedicated-server
Briefly, you can push your project to private repo on gitlab or github,
then make development(=development server),production(=production server) branches, the automate job will deploy to the servers if you have git push.
Here's an example main part from the link on the file .gitlab-ci.yml:
deploy_staging:
stage: deploy
image: kroniak/ssh-client:3.6
script:
# add the server as a known host
- mkdir ~/.ssh
- echo "$SSH_KNOWN_HOSTS" >> ~/.ssh/known_hosts
- chmod 644 ~/.ssh/known_hosts
# add ssh key stored in SSH_PRIVATE_KEY variable to the agent store
- eval $(ssh-agent -s)
- ssh-add <(echo "$SSH_PRIVATE_KEY")
# log into Docker registry
- ssh deployer#thecodingmachine.io "docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN registry.thecodingmachine.com"
# stop container, remove image.
- ssh deployer#thecodingmachine.io "docker stop thecodingmachine.io_${CI_COMMIT_REF_SLUG}" || true
- ssh deployer#thecodingmachine.io "docker rm thecodingmachine.io_${CI_COMMIT_REF_SLUG}" || true
- ssh deployer#thecodingmachine.io "docker rmi registry.thecodingmachine.com/tcm-projects/thecodingmachine.io:${CI_COMMIT_REF_SLUG}" || true
# start new container
- ssh deployer#thecodingmachine.io "docker run --name thecodingmachine.io_${CI_COMMIT_REF_SLUG} --network=web -d registry.thecodingmachine.com/tcm-projects/thecodingmachine.io:${CI_COMMIT_REF_SLUG}"
only:
- branches
except:
- master
It maybe hard for you to read this, but you can know there is a way which can work you need and you may take times to learn this part.
Hope it work for you.
Thanks for David Négrier sharing.

Logn in to one remote machine shows as -bash-4.2$ in terminal while user#host$ on other remote servers? How to fix this?

When I'm login in to one remote machine over ssh it logs in as -bash-4.2$ in terminal but on other remote hosts user#host$. How to correct this? I accidentally executed rm -rf *.
Looks like I delete some important files from home directory.
Note: I'm not the admin.
Assuming you want all your hosts to have a prompt of the form user#host$, you need to add to your $HOME/.bashrc on each of these machines the correct value of PS1:
PS1='\u#\h$ '
Maybe you have deleted the .bashrc file
vi .bashrc
put this code
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
now su root

Blank page on installing Grav

I have download grav zip file and extract it to my web server or local host.iam using fedora OS with PHP version 5.6.23.on navigating localhost/grav in browser,it shows a blank page.can anyone help me to solve this?
Check /var/log/httpd/error_log, if you see errors about file permission, maybe SELinux prevented web server from writing configuration files. This often happens to a fresh installation of Fedora/apache.
You can try this:
From terminal, run su -c "dnf install policycoreutils-python-utils" to install policycoreutils-python-utils package which provides semanage
Run su -c "semanage permissive -a httpd_t" to ask SELinux to monitor apache in permissive mode and allow apache to write to its public folder.
Now refresh the page to see if Grav is now running.
If this doesn't work and you want to reserve the command semanage permissive -a httpd_t, you run semanage permissive -d httpd_t (more details)

testlink installation failed: checking if /var/testlink/logs/ directory exists

Today, I installed testlink. And after I select 'new Installation' and choose 'I agree' option, it failed at the second step. The failed message are as following:
Read/write permissions
For security reason we suggest that directories tagged with [S] on following messages, will be made UNREACHEABLE from browser
Checking if C:\xampp\htdocs\testlink\gui\templates_c directory exists OK
Checking if C:\xampp\htdocs\testlink\gui\templates_c directory is writable (by user used to run webserver process) OK
Checking if /var/testlink/logs/ directory exists [S] Failed!
Checking if /var/testlink/upload_area/ directory exists [S] Failed!
So, can anyone give me a hand? Many thanks!
In C:\xampp\htdocs\testlink\config.inc.php file, change
$g_repositoryPath = 'C:\xampp\htdocs\testlink\upload_area';
$tlCfg->log_path = 'C:\xampp\htdocs\testlink\logs';
Worked for me , make sure you dont have the slash at the end.
i.e, make sure that it is NOT:
$g_repositoryPath = 'C:\xampp\htdocs\testlink\upload_area\';
$tlCfg->log_path = 'C:\xampp\htdocs\testlink\logs\';
If you installed the XAMPP or testlink in another directories, change the paths above accordingly.
Go to config.inc.php and log directory ($tlCfg->log_path) edit the path to C:\xampp\testlink\logs and upload directory ($g_repositoryPath) to C:\xampp\testlink\upload_area
In some cases, you would do like this:
Go to C:\xampp\htdocs\testlink\config.inc.php1
and log directory ($tlCfg->log_path) edit the path to C:\xampp\htdocs\testlink\logs
and upload directory ($g_repositoryPath) to C:\xampp\htdocs\testlink\upload_area
Then you have:
$g_repositoryPath = 'C:\xampp\htdocs\testlink\upload_area';
$tlCfg->log_path = 'C:\xampp\htdocs\testlink\logs';
I had paths set correct , also user, group and access are set correct and still can not get rid of issue. It took me very long to go to the root cause, the issue lies at- http daemon does not have access to file in concern due to SELinux policies. So simple chown, chmod would not help(group and user access). For testlink 1.16 I resolved it with re-installing with sudo user, but for upgrade, an issue arose again even with sudo user.
And resolved issue by executing following commands, I hope this helps. (Note: You might have to mend attributes to run it successfully)
$chcon -t httpd_sys_content_rw_t "<path_to_testlink_folder>/gui/templates_c/"
$chcon -t httpd_sys_content_rw_t "/<path_to_testlink_folder>/upload_area/"
$chcon -t httpd_sys_content_rw_t "<path_to_testlink_folder>/logs"
$semanage fcontext -a -t httpd_sys_content_rw_t "<path_to_testlink_folder>(/.*)?"
$restorecon -R -v path_to_testlink_folder
Ubuntu 12.04 - All you have to do is chmod 777 these directories, Fails will become Pass.
~$ cd into /var/www/testlink
~$ sudo chmod 777 ./gui/templates_c/
~$ sudo chmod 777 ./upload_area/
~$ sudo chmod 777 ./logs/
Whatever the instructions say is total BS. Making these directories unreachable from browser is optional, and that created a confusion. if you chmod 777 them, your Fails will turn into pass and now you'll be able to proceed to step 3 of your testlink installation. Tested with testlink version 1.9.5.
For Mac OS Users try this in 1.9.19 version:
Make Sure with your folder name.
In config.inc.php file:
$tlCfg->log_path = TL_ABS_PATH . 'logs' . DIRECTORY_SEPARATOR;
$g_repositoryPath= TL_ABS_PATH . 'upload_area' . DIRECTORY_SEPARATOR;
After this if you got read write permission issue failed.
Goto testlink -> logs / upload_area -> press Command + I -> in Permission Enable Read Write to Everyone.
on Linux; ensure the paths are as follows:
$tlCfg->log_path
$g_repositoryPath
are
/var/www/html/testlink/logs/
/var/www/html/testlink/upload_area/
Valid for ubuntu 16.04 LTS add permisions
Change:
$g_repositoryPath = 'var/www/html/testlink/upload_area'; //linux user
$tlCfg->log_path = 'var/www/html/testlink/logs';
~$ cd into /var/www/testlink
~$ sudo chmod 777 ./gui/templates_c/
~$ sudo chmod 777 ./upload_area/
~$ sudo chmod 777 ./logs/
In CentOS go to /var/www/html/testlink-code-1.9.16 and edit the file custom_config.inc.php replace these two lines
// $tlCfg->log_path = '/var/testlink-ga-testlink-code/logs/'; /* unix example */
// $g_repositoryPath = '/var/testlink-ga-testlink-code/upload_area/'; /* unix example */
with
$tlCfg->log_path = '/var/www/html/testlink-code-1.9.16/logs/';
$g_repositoryPath = '/var/www/html/testlink-code-1.9.16/upload_area/';
Make sure you have disabled the selinux. If not to do so edit the file /etc/sysconfig/selinux and change the variable SELINUX to disabled and reboot the machine. Now these errors should have gone.
on ubuntu 18.04, will need to run
apt-get remove apparmor
in order to install it
To solve the problem :
Checking if /var/www/html/testlink-1.9.16/gui/templates_c directory is writable (by user used to run webserver process) on Centos 7.
Disable SELinux, and then restart your system.
You should no longer have this error message.

Restart nginx without sudo?

So I want to be able to cap:deploy without having to type any passwords. I have setup all private keys so I can get to the remote servers fine, and am now using svn over ssh, so no passwords there.
I have one last problem, I need to be able to restart nginx. Right now I have sudo /etc/init.d/nginx reload. That is a problem b/c it uses the capistrano password, the one I just removed b/c I am using keys. Any ideas on how to restart nginx w\out a password?
I just spent a good hour looking at sudoer wildcards and the like trying to solve this exact problem. In truth, all you really need is a root executable script that restarts nginx.
Add this to the /etc/sudoers file
username hostname ALL=NOPASSWD: /path/to/script
Write script as root
#! /bin/bash
/bin/kill -HUP `cat /var/run/nginx.pid`
Make the script executable
Test.
sudo /path/to/script
There is a better answer on Stack Overflow that does not involve writing a custom script:
The best practice is to use /etc/sudoers.d/myusername
The /etc/sudoers.d/ folder can contain multiple files that allow users
to call stuff using sudo without being root.
The file usually contains a user and a list of commands that the user
can run without having to specify a password.
Instructions:
In all commands, replace myusername with the name of your user that you want to use to restart nginx without sudo.
Open sudoers file for your user:
$ sudo visudo -f /etc/sudoers.d/myusername
Editor will open. There you paste the following line. This will allow that user to run nginx start, restart, and stop:
myusername ALL=(ALL) NOPASSWD: /usr/sbin/service nginx start,/usr/sbin/service nginx stop,/usr/sbin/service nginx restart
Save by hitting ctrl+o. It will ask where you want to save, simply press enter to confirm the default. Then exit out of the editor with ctrl+x.
Now you can restart (and start and stop) nginx without password. Let's try it.
Open new session (otherwise, you might simply not be asked for your sudo password because it has not timed out):
$ ssh myusername#myserver
Stop nginx
$ sudo /usr/sbin/service nginx stop
Confirm that nginx has stopped by checking your website or running ps aux | grep nginx
Start nginx
$ sudo /usr/sbin/service nginx start
Confirm that nginx has started by checking your website or running ps aux | grep nginx
PS: Make sure to use sudo /usr/sbin/service nginx start|restart|stop, and not sudo service nginx start|restart|stop.
Run sudo visudo
Append with below lines (in this example you can add multiple scripts and services after comma)
# Run scripts without asking for pass
<your-user> ALL=(root) NOPASSWD: /opt/fixdns.sh,/usr/sbin/service nginx *,/usr/sbin/service docker *
Save and exit with :wq
Create a rake task in Rails_App/lib/capistrano/tasks/nginx.rake and paste below code.
namespace :nginx do
%w(start stop restart reload).each do |command|
desc "#{command.capitalize} Nginx"
task command do
on roles(:app) do
execute :sudo, "service nginx #{command}"
end
end
end
end
Then ssh to your remote server and open file
sudo vi /etc/sudoers
and the paste this line (after line %sudo ALL=(ALL:ALL) ALL)
deploy ALL=(ALL:ALL) NOPASSWD: /usr/sbin/service nginx *
Or, as in your case,
deploy ALL=(ALL:ALL) NOPASSWD: /etc/init.d/nginx *
Here I am assuming your deployment user is deploy.
You can add here other commands too for which you dont require to enter password. For example
deploy ALL=(ALL:ALL) NOPASSWD: /usr/sbin/service nginx *, /etc/init.d/mysqld, /etc/init.d/apache2

Resources