Bedrock – Importance of file
Composer.json: All of the plugins, all of the themes managed through composer so composer is a php package manager just like NPM is javascript manager.
Config: Have different php files for different environments if you work on suppose development environment so you simply wp_debug true for this environment.
Vendor: Where those composer.json. Basically it’s not wordpress related.
Web -> app: All themes, plugins, uploads folder managed by here.
wp-config / index.php: This is needed to order the WordPress first. It finds the wp folder if it is not found then they look up the directory and look for this there and basically wp-config file login the config folders file.
Wp: Core installation of WordPress.
Dependency management with Composer: Manage your WordPress install and plugins with Composer, a PHP dependency manager. Composer will make development more reliable, help with team collaboration, and it helps maintain a better Git repository.
How to Setup WordPress via Bedrock ?
Goto the folder and click right click and open the terminal where you need to install
(like : https://user5@user5/var/www/html$) and run the command.
$ composer create-project roots/bedrock [project_folder_name]
Update environment variables in the .env file : (Before this create database first)
DB_NAME – Database name
DB_USER – Database user
DB_PASSWORD – Database password
DB_HOST – Database host
Change the all parameters + WP_HOME (check below screenshot)
Now generate the salt key by using this url : WordPress Salts and replace with .env salt key.
(Why Salt key is important in wordpress: WordPress salts are long strings of random characters that are used by WordPress to secure the credentials of logged in users.)
- Add theme(s) in web/app/themes/ as you would for a normal WordPress site. Copy paste the theme here which you want to activate.
- Set the document root on your webserver to Bedrock’s web folder: /path/to/site/web/ (Need to setup virtual host in localhost first :
Here is the installation guide url:
Setup virtual host in localhost
Open the command prompt or terminal window and enter the command:
$ sudo nano /etc/hosts
: and enter the password (here you can see the domain name register on your localhost)
OR
$ sudo gedit /etc/hosts
: open in default notepad
$ cat /etc/hosts
: see content of file
127.0.0.1 localhost
127.0.0.6 bitcotpage.live
# add domain and ip like following
127.0.0.7 example.live
After add domain name press control+x for save and exit above screenshot window.
Configuration for our domain/set document root for our domain
Check ls (for list ) or ll (list with details)
$ cd /etc/apache2/sites-available
$ ls
Now enter command $ cp 000-default.conf example.live.conf
(copy default file with new file with the same name domain name) if permission issue then use sudo
$ sudo nano example.live.conf
(for file edit and its content)
or use $ sudo gedit example.live.conf
for open file in editor.
# Change with project domain name which is set in /etc/hosts
ServerName example.live
# if use www then use serveralias (optional)
ServerAlias www.example.live
ServerAdmin webmaster@example.live
# change with project path
DocumentRoot /var/www/html/example/web
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
<Directory "/var/www">
AllowOverride All
</Directory>
If we use folder outside the wamp/xamp
<VirtualHost *:80>
# Change with project domain name which is set in /etc/hosts
ServerName example.live
# if use www then use serveralias (optional)
ServerAlias www.example.live
ServerAdmin webmaster@example.live
# change with project path
DocumentRoot /home/bitcot/Documents/example/web
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
<Directory “/home/bitcot/Documents”>
AllowOverride All
</Directory>
Enable this virtual host or domain configuration:
$ sudo a2ensite wprock.local.conf
Server restart (if needed use sudo) :
$ systemctl reload apache2
Now goto project .env file:
How to Access WordPress Admin Panel
Access WordPress admin at https://example.live/wp/wp-admin/
Set the domain path in web server with the name http://example.live/
So I am able to wordpress admin with this url: http://example.live
[ Note : How can set virtual host in windows ]
Setting virutal host in windows xampp and wamp – Setup Bedrock for WordPress Development on Windows OS